]> Untitled Git - lemmy.git/blob - .drone.yml
Upgrade to postgres 15. (#2659)
[lemmy.git] / .drone.yml
1 ---
2 kind: pipeline
3 name: amd64
4
5 platform:
6   os: linux
7   arch: amd64
8
9 steps:
10
11   # use minimum supported rust version for most steps
12   - name: prepare repo
13     image: clux/muslrust:1.64.0
14     commands:
15       - git fetch --tags
16       - git submodule init
17       - git submodule update --recursive --remote
18       - chown 1000:1000 . -R
19
20   - name: check formatting
21     image: rustdocker/rust:nightly
22     commands:
23       - /root/.cargo/bin/cargo fmt -- --check
24
25   # latest rust for clippy to get extra checks
26   # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
27   - name: cargo clippy
28     image: rust:1.65-buster
29     environment:
30       CARGO_HOME: .cargo
31     commands:
32       - rustup component add clippy
33       - cargo clippy --workspace --tests --all-targets --all-features -- 
34           -D warnings -D deprecated -D clippy::perf -D clippy::complexity 
35           -D clippy::style -D clippy::correctness -D clippy::suspicious
36           -D clippy::dbg_macro -D clippy::inefficient_to_string 
37           -D clippy::items-after-statements -D clippy::implicit_clone 
38           -D clippy::wildcard_imports -D clippy::cast_lossless 
39           -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls 
40           -D clippy::unused_self
41       - cargo clippy --workspace --all-features -- -D clippy::unwrap_used
42
43   - name: cargo test
44     image: clux/muslrust:1.64.0
45     environment:
46       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
47       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
48       RUST_BACKTRACE: 1
49       RUST_TEST_THREADS: 1
50       CARGO_HOME: .cargo
51     commands:
52       - apt-get update
53       - apt-get -y install --no-install-recommends postgresql-client protobuf-compiler libprotobuf-dev
54       - cargo test --workspace --no-fail-fast --all-features
55
56   - name: check defaults.hjson updated
57     image: clux/muslrust:1.64.0
58     environment:
59       CARGO_HOME: .cargo
60     commands:
61       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
62       - diff config/defaults.hjson config/defaults_current.hjson
63
64   - name: check with different features
65     image: clux/muslrust:1.64.0
66     environment:
67       CARGO_HOME: .cargo
68     commands:
69       - cargo install cargo-workspaces
70       - cargo workspaces exec cargo check --no-default-features
71       - cargo workspaces exec cargo check --all-features
72
73   - name: lemmy_api_common doesnt depend on diesel
74     image: rust:1.64-buster
75     commands:
76       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
77
78   - name: cargo build
79     image: clux/muslrust:1.64.0
80     environment:
81       CARGO_HOME: .cargo
82     commands:
83       - cargo build
84       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
85
86   - name: run federation tests
87     image: node:alpine
88     environment:
89       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
90       DO_WRITE_HOSTS_FILE: 1
91     commands:
92       - apk add bash curl postgresql-client
93       - bash api_tests/prepare-drone-federation-test.sh
94       - cd api_tests/
95       - yarn
96       - yarn api-test
97
98   - name: nightly build
99     image: plugins/docker
100     settings:
101       dockerfile: docker/prod/Dockerfile
102       username:
103         from_secret: docker_username
104       password:
105         from_secret: docker_password
106       repo: dessalines/lemmy
107       tags:
108         - dev
109     when:
110       event:
111         - cron
112
113   - name: publish release docker image
114     image: plugins/docker
115     settings:
116       dockerfile: docker/prod/Dockerfile
117       username:
118         from_secret: docker_username
119       password:
120         from_secret: docker_password
121       repo: dessalines/lemmy
122       auto_tag: true
123       auto_tag_suffix: linux-amd64
124     when:
125       ref:
126         - refs/tags/*
127
128   - name: publish release docker manifest
129     image: plugins/manifest
130     settings:
131       username:
132         from_secret: docker_username
133       password:
134         from_secret: docker_password
135       target: "dessalines/lemmy:${DRONE_TAG}"
136       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
137       platforms:
138         - linux/amd64
139         - linux/arm64
140       ignore_missing: true
141     when:
142       ref:
143         - refs/tags/*
144
145   - name: publish latest release docker manifest
146     image: plugins/manifest
147     settings:
148       username:
149         from_secret: docker_username
150       password:
151         from_secret: docker_password
152       target: "dessalines/lemmy:latest"
153       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
154       platforms:
155         - linux/amd64
156         - linux/arm64
157       ignore_missing: true
158     when:
159       ref:
160         - refs/tags/*
161
162   # using https://github.com/pksunkara/cargo-workspaces
163   - name: publish to crates.io
164     image: rustlang/rust:nightly
165     environment:
166       CARGO_TOKEN:
167         from_secret: cargo_api_token
168     commands:
169       - cargo install cargo-workspaces
170       - cp -r migrations crates/db_schema/
171       - cargo login "$CARGO_TOKEN"
172       - cargo workspaces publish --from-git --allow-dirty --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
173     when:
174       ref:
175         - refs/tags/*
176
177 services:
178   - name: database
179     image: postgres:14-alpine
180     environment:
181       POSTGRES_USER: lemmy
182       POSTGRES_PASSWORD: password
183
184 ---
185 kind: pipeline
186 name: arm64
187
188 platform:
189   os: linux
190   arch: arm64
191
192 steps:
193
194   - name: prepare repo
195     image: rust:1.57-slim
196     user: root
197     commands:
198       - chown 1000:1000 . -R
199       - apt update
200       - apt install --no-install-recommends --yes git
201       - git fetch --tags
202       - git submodule init
203       - git submodule update --recursive --remote
204
205   # TODO temporarily disable arm tests
206   # - name: cargo test
207   #   image: rust:1.57-slim
208   #   environment:
209   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
210   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
211   #     RUST_BACKTRACE: 1
212   #     RUST_TEST_THREADS: 1
213   #   commands:
214   #     - apt-get update
215   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
216   #     - cargo test --workspace --no-fail-fast
217   #     - cargo build
218
219   # TODO temporarily disable arm tests
220   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
221   # - name: cargo build
222   #   image: rust:1.57-slim
223   #   commands:
224   #     - apt-get update
225   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
226   #     - cargo build
227   #     - mv target/debug/lemmy_server target/lemmy_server
228
229   # TODO temporarily disable arm tests
230   # - name: run federation tests
231   #   image: node:16-slim
232   #   environment:
233   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
234   #     DO_WRITE_HOSTS_FILE: 1
235   #   commands:
236   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
237   #     - apt-get update
238   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
239   #     - bash api_tests/prepare-drone-federation-test.sh
240   #     - cd api_tests/
241   #     - yarn
242   #     - yarn api-test
243
244   - name: publish release docker image
245     image: plugins/docker
246     settings:
247       dockerfile: docker/prod/Dockerfile.arm
248       username:
249         from_secret: docker_username
250       password:
251         from_secret: docker_password
252       repo: dessalines/lemmy
253       auto_tag: true
254       auto_tag_suffix: linux-arm64
255     when:
256       ref:
257         - refs/tags/*
258
259   - name: publish release docker manifest
260     image: plugins/manifest
261     settings:
262       username:
263         from_secret: docker_username
264       password:
265         from_secret: docker_password
266       target: "dessalines/lemmy:${DRONE_TAG}"
267       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
268       platforms:
269         - linux/amd64
270         - linux/arm64
271       ignore_missing: true
272     when:
273       ref:
274         - refs/tags/*
275
276   - name: publish latest release docker manifest
277     image: plugins/manifest
278     settings:
279       username:
280         from_secret: docker_username
281       password:
282         from_secret: docker_password
283       target: "dessalines/lemmy:latest"
284       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
285       platforms:
286         - linux/amd64
287         - linux/arm64
288       ignore_missing: true
289     when:
290       ref:
291         - refs/tags/*
292
293 # TODO temporarily disable arm tests
294 # services:
295 #   - name: database
296 #     image: postgres:12-alpine
297 #     environment:
298 #       POSTGRES_USER: lemmy
299 #       POSTGRES_PASSWORD: password