]> Untitled Git - lemmy.git/blob - .drone.yml
Adding a site option to email admins for new reports. (#2730)
[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: alpine:3
14     commands:
15       - apk add git
16       - git fetch --tags
17       - git submodule init
18       - git submodule update --recursive --remote
19
20   - name: cargo fmt
21     image: clux/muslrust:1.67.0
22     environment:
23       # store cargo data in repo folder so that it gets cached between steps
24       CARGO_HOME: .cargo
25     commands:
26       # need make existing toolchain available
27       - cp ~/.cargo . -r
28       - rustup toolchain install nightly
29       - rustup component add rustfmt --toolchain nightly
30       - cargo +nightly fmt -- --check
31
32   # check each package to make sure they compile with default features.
33   # this is required for crates.io
34   - name: cargo check
35     image: clux/muslrust:1.67.0
36     environment:
37       CARGO_HOME: .cargo
38     commands:
39       - cargo check --package lemmy_utils
40       - cargo check --package lemmy_db_schema
41       - cargo check --package lemmy_db_views
42       - cargo check --package lemmy_db_views_actor
43       - cargo check --package lemmy_db_views_moderator
44       - cargo check --package lemmy_api_common
45       - cargo check --package lemmy_api
46       - cargo check --package lemmy_api_crud
47       - cargo check --package lemmy_apub
48       - cargo check --package lemmy_routes
49       - cargo check --workspace
50       - cargo check --workspace --features console
51       # disabled because it takes too long with pict-rs
52       #- cargo check --workspace --all-features
53
54   - name: cargo clippy
55     image: clux/muslrust:1.67.0
56     environment:
57       CARGO_HOME: .cargo
58     commands:
59         # latest rust for clippy to get extra checks
60         # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
61       - rustup component add clippy
62       - cargo clippy --workspace --tests --all-targets --features console --
63           -D warnings -D deprecated -D clippy::perf -D clippy::complexity 
64           -D clippy::style -D clippy::correctness -D clippy::suspicious
65           -D clippy::dbg_macro -D clippy::inefficient_to_string 
66           -D clippy::items-after-statements -D clippy::implicit_clone 
67           -D clippy::wildcard_imports -D clippy::cast_lossless 
68           -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls 
69           -D clippy::unused_self
70           -A clippy::uninlined_format_args
71       - cargo clippy --workspace --features console -- -D clippy::unwrap_used
72
73   - name: lemmy_api_common doesnt depend on diesel
74     image: clux/muslrust:1.67.0
75     environment:
76       CARGO_HOME: .cargo
77     commands:
78       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
79
80   - name: check defaults.hjson updated
81     image: clux/muslrust:1.67.0
82     environment:
83       CARGO_HOME: .cargo
84     commands:
85       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
86       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
87       - diff config/defaults.hjson config/defaults_current.hjson
88
89   - name: cargo test
90     image: clux/muslrust:1.67.0
91     environment:
92       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
93       RUST_BACKTRACE: 1
94       RUST_TEST_THREADS: 1
95       CARGO_HOME: .cargo
96     commands:
97       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
98       - cargo test --workspace --no-fail-fast
99
100   - name: cargo build
101     image: clux/muslrust:1.67.0
102     environment:
103       CARGO_HOME: .cargo
104     commands:
105       - cargo build
106       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
107
108   - name: run federation tests
109     image: node:alpine
110     environment:
111       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
112       DO_WRITE_HOSTS_FILE: 1
113     commands:
114       - apk add bash curl postgresql-client
115       - bash api_tests/prepare-drone-federation-test.sh
116       - cd api_tests/
117       - yarn
118       - yarn api-test
119
120   - name: nightly build
121     image: plugins/docker
122     settings:
123       dockerfile: docker/prod/Dockerfile
124       username:
125         from_secret: docker_username
126       password:
127         from_secret: docker_password
128       repo: dessalines/lemmy
129       add_host: github.com:140.82.112.3,static.crates.io:18.154.227.73,crates.io:108.138.64.68,dl-cdn.alpinelinux.org:146.75.30.133
130       tags:
131         - dev
132     when:
133       event:
134         - cron
135
136   - name: publish release docker image
137     image: plugins/docker
138     settings:
139       dockerfile: docker/prod/Dockerfile
140       username:
141         from_secret: docker_username
142       password:
143         from_secret: docker_password
144       repo: dessalines/lemmy
145       add_host: github.com:140.82.112.3,static.crates.io:18.154.227.73,crates.io:108.138.64.68,dl-cdn.alpinelinux.org:146.75.30.133
146       auto_tag: true
147       auto_tag_suffix: linux-amd64
148     when:
149       ref:
150         - refs/tags/*
151
152   - name: publish release docker manifest
153     image: plugins/manifest
154     settings:
155       username:
156         from_secret: docker_username
157       password:
158         from_secret: docker_password
159       target: "dessalines/lemmy:${DRONE_TAG}"
160       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
161       platforms:
162         - linux/amd64
163         - linux/arm64
164       ignore_missing: true
165     when:
166       ref:
167         - refs/tags/*
168
169   - name: publish latest release docker manifest
170     image: plugins/manifest
171     settings:
172       username:
173         from_secret: docker_username
174       password:
175         from_secret: docker_password
176       target: "dessalines/lemmy:latest"
177       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
178       platforms:
179         - linux/amd64
180         - linux/arm64
181       ignore_missing: true
182     when:
183       ref:
184         - refs/tags/*
185
186   # using https://github.com/pksunkara/cargo-workspaces
187   - name: publish to crates.io
188     image: clux/muslrust:1.67.0
189     environment:
190       CARGO_TOKEN:
191         from_secret: cargo_api_token
192     commands:
193       - cargo install cargo-workspaces
194       - cp -r migrations crates/db_schema/
195       - cargo login "$CARGO_TOKEN"
196       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
197     when:
198       ref:
199         - refs/tags/*
200
201   - name: Notify on failure
202     image: alpine:3
203     commands: 
204       - apk add curl
205       - "curl -d'Drone build failed: ${DRONE_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
206     when:
207       status:
208         - failure
209
210   - name: Notify on tag deploy
211     image: alpine:3
212     commands: 
213       - apk add curl
214       - "curl -d'lemmy:${DRONE_TAG} deployed' ntfy.sh/lemmy_drone_ci"
215     when:
216       ref:
217         - refs/tags/*
218
219 services:
220   - name: database
221     image: postgres:15-alpine
222     environment:
223       POSTGRES_USER: lemmy
224       POSTGRES_PASSWORD: password
225
226 ---
227 kind: pipeline
228 name: arm64
229
230 platform:
231   os: linux
232   arch: arm64
233
234 steps:
235
236   - name: prepare repo
237     image: rust:1.57-slim
238     user: root
239     commands:
240       - apt update
241       - apt install --no-install-recommends --yes git
242       - git fetch --tags
243       - git submodule init
244       - git submodule update --recursive --remote
245
246   # TODO temporarily disable arm tests
247   # - name: cargo test
248   #   image: rust:1.57-slim
249   #   environment:
250   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
251   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
252   #     RUST_BACKTRACE: 1
253   #     RUST_TEST_THREADS: 1
254   #   commands:
255   #     - apt-get update
256   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
257   #     - cargo test --workspace --no-fail-fast
258   #     - cargo build
259
260   # TODO temporarily disable arm tests
261   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
262   # - name: cargo build
263   #   image: rust:1.57-slim
264   #   commands:
265   #     - apt-get update
266   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
267   #     - cargo build
268   #     - mv target/debug/lemmy_server target/lemmy_server
269
270   # TODO temporarily disable arm tests
271   # - name: run federation tests
272   #   image: node:16-slim
273   #   environment:
274   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
275   #     DO_WRITE_HOSTS_FILE: 1
276   #   commands:
277   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
278   #     - apt-get update
279   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
280   #     - bash api_tests/prepare-drone-federation-test.sh
281   #     - cd api_tests/
282   #     - yarn
283   #     - yarn api-test
284
285   - name: publish release docker image
286     image: plugins/docker
287     settings:
288       dockerfile: docker/prod/Dockerfile.arm
289       username:
290         from_secret: docker_username
291       password:
292         from_secret: docker_password
293       repo: dessalines/lemmy
294       auto_tag: true
295       auto_tag_suffix: linux-arm64
296     when:
297       ref:
298         - refs/tags/*
299
300   - name: publish release docker manifest
301     image: plugins/manifest
302     settings:
303       username:
304         from_secret: docker_username
305       password:
306         from_secret: docker_password
307       target: "dessalines/lemmy:${DRONE_TAG}"
308       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
309       platforms:
310         - linux/amd64
311         - linux/arm64
312       ignore_missing: true
313     when:
314       ref:
315         - refs/tags/*
316
317   - name: publish latest release docker manifest
318     image: plugins/manifest
319     settings:
320       username:
321         from_secret: docker_username
322       password:
323         from_secret: docker_password
324       target: "dessalines/lemmy:latest"
325       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
326       platforms:
327         - linux/amd64
328         - linux/arm64
329       ignore_missing: true
330     when:
331       ref:
332         - refs/tags/*
333
334 # TODO temporarily disable arm tests
335 # services:
336 #   - name: database
337 #     image: postgres:12-alpine
338 #     environment:
339 #       POSTGRES_USER: lemmy
340 #       POSTGRES_PASSWORD: password