]> Untitled Git - lemmy.git/blob - .drone.yml
Implement separate mod activities for feature, lock post (#2716)
[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/Dockerfile
124       build_args: RUST_RELEASE_MODE=release
125       username:
126         from_secret: docker_username
127       password:
128         from_secret: docker_password
129       repo: dessalines/lemmy
130       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
131       tags:
132         - dev
133     when:
134       event:
135         - cron
136
137   - name: publish release docker image
138     image: plugins/docker
139     settings:
140       dockerfile: docker/Dockerfile
141       build_args: RUST_RELEASE_MODE=release
142       username:
143         from_secret: docker_username
144       password:
145         from_secret: docker_password
146       repo: dessalines/lemmy
147       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
148       auto_tag: true
149       auto_tag_suffix: linux-amd64
150     when:
151       ref:
152         - refs/tags/*
153
154   - name: publish release docker manifest
155     image: plugins/manifest
156     settings:
157       username:
158         from_secret: docker_username
159       password:
160         from_secret: docker_password
161       target: "dessalines/lemmy:${DRONE_TAG}"
162       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
163       platforms:
164         - linux/amd64
165         - linux/arm64
166       ignore_missing: true
167     when:
168       ref:
169         - refs/tags/*
170
171   - name: publish latest release docker manifest
172     image: plugins/manifest
173     settings:
174       username:
175         from_secret: docker_username
176       password:
177         from_secret: docker_password
178       target: "dessalines/lemmy:latest"
179       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
180       platforms:
181         - linux/amd64
182         - linux/arm64
183       ignore_missing: true
184     when:
185       ref:
186         - refs/tags/*
187
188   # using https://github.com/pksunkara/cargo-workspaces
189   - name: publish to crates.io
190     image: clux/muslrust:1.67.0
191     environment:
192       CARGO_TOKEN:
193         from_secret: cargo_api_token
194     commands:
195       - cargo install cargo-workspaces
196       - cp -r migrations crates/db_schema/
197       - cargo login "$CARGO_TOKEN"
198       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
199     when:
200       ref:
201         - refs/tags/*
202
203   - name: Notify on failure
204     image: alpine:3
205     commands: 
206       - apk add curl
207       - "curl -d'Drone build failed: ${DRONE_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
208     when:
209       status:
210         - failure
211
212   - name: Notify on tag deploy
213     image: alpine:3
214     commands: 
215       - apk add curl
216       - "curl -d'lemmy:${DRONE_TAG} deployed' ntfy.sh/lemmy_drone_ci"
217     when:
218       ref:
219         - refs/tags/*
220
221 services:
222   - name: database
223     image: postgres:15-alpine
224     environment:
225       POSTGRES_USER: lemmy
226       POSTGRES_PASSWORD: password
227
228 ---
229 kind: pipeline
230 name: arm64
231
232 platform:
233   os: linux
234   arch: arm64
235
236 steps:
237
238   - name: prepare repo
239     image: rust:1.57-slim
240     user: root
241     commands:
242       - apt update
243       - apt install --no-install-recommends --yes git
244       - git fetch --tags
245       - git submodule init
246       - git submodule update --recursive --remote
247
248   # TODO temporarily disable arm tests
249   # - name: cargo test
250   #   image: rust:1.57-slim
251   #   environment:
252   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
253   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
254   #     RUST_BACKTRACE: 1
255   #     RUST_TEST_THREADS: 1
256   #   commands:
257   #     - apt-get update
258   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
259   #     - cargo test --workspace --no-fail-fast
260   #     - cargo build
261
262   # TODO temporarily disable arm tests
263   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
264   # - name: cargo build
265   #   image: rust:1.57-slim
266   #   commands:
267   #     - apt-get update
268   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
269   #     - cargo build
270   #     - mv target/debug/lemmy_server target/lemmy_server
271
272   # TODO temporarily disable arm tests
273   # - name: run federation tests
274   #   image: node:16-slim
275   #   environment:
276   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
277   #     DO_WRITE_HOSTS_FILE: 1
278   #   commands:
279   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
280   #     - apt-get update
281   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
282   #     - bash api_tests/prepare-drone-federation-test.sh
283   #     - cd api_tests/
284   #     - yarn
285   #     - yarn api-test
286
287   - name: publish release docker image
288     image: plugins/docker
289     settings:
290       dockerfile: docker/Dockerfile.arm
291       username:
292         from_secret: docker_username
293       password:
294         from_secret: docker_password
295       repo: dessalines/lemmy
296       auto_tag: true
297       auto_tag_suffix: linux-arm64
298     when:
299       ref:
300         - refs/tags/*
301
302   - name: publish release docker manifest
303     image: plugins/manifest
304     settings:
305       username:
306         from_secret: docker_username
307       password:
308         from_secret: docker_password
309       target: "dessalines/lemmy:${DRONE_TAG}"
310       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
311       platforms:
312         - linux/amd64
313         - linux/arm64
314       ignore_missing: true
315     when:
316       ref:
317         - refs/tags/*
318
319   - name: publish latest release docker manifest
320     image: plugins/manifest
321     settings:
322       username:
323         from_secret: docker_username
324       password:
325         from_secret: docker_password
326       target: "dessalines/lemmy:latest"
327       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
328       platforms:
329         - linux/amd64
330         - linux/arm64
331       ignore_missing: true
332     when:
333       ref:
334         - refs/tags/*
335
336 # TODO temporarily disable arm tests
337 # services:
338 #   - name: database
339 #     image: postgres:12-alpine
340 #     environment:
341 #       POSTGRES_USER: lemmy
342 #       POSTGRES_PASSWORD: password