]> Untitled Git - lemmy.git/blob - .drone.yml
Adding 0.17.1 Release notes.
[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 services:
211   - name: database
212     image: postgres:15-alpine
213     environment:
214       POSTGRES_USER: lemmy
215       POSTGRES_PASSWORD: password
216
217 ---
218 kind: pipeline
219 name: arm64
220
221 platform:
222   os: linux
223   arch: arm64
224
225 steps:
226
227   - name: prepare repo
228     image: rust:1.57-slim
229     user: root
230     commands:
231       - apt update
232       - apt install --no-install-recommends --yes git
233       - git fetch --tags
234       - git submodule init
235       - git submodule update --recursive --remote
236
237   # TODO temporarily disable arm tests
238   # - name: cargo test
239   #   image: rust:1.57-slim
240   #   environment:
241   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
242   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
243   #     RUST_BACKTRACE: 1
244   #     RUST_TEST_THREADS: 1
245   #   commands:
246   #     - apt-get update
247   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
248   #     - cargo test --workspace --no-fail-fast
249   #     - cargo build
250
251   # TODO temporarily disable arm tests
252   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
253   # - name: cargo build
254   #   image: rust:1.57-slim
255   #   commands:
256   #     - apt-get update
257   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
258   #     - cargo build
259   #     - mv target/debug/lemmy_server target/lemmy_server
260
261   # TODO temporarily disable arm tests
262   # - name: run federation tests
263   #   image: node:16-slim
264   #   environment:
265   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
266   #     DO_WRITE_HOSTS_FILE: 1
267   #   commands:
268   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
269   #     - apt-get update
270   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
271   #     - bash api_tests/prepare-drone-federation-test.sh
272   #     - cd api_tests/
273   #     - yarn
274   #     - yarn api-test
275
276   - name: publish release docker image
277     image: plugins/docker
278     settings:
279       dockerfile: docker/prod/Dockerfile.arm
280       username:
281         from_secret: docker_username
282       password:
283         from_secret: docker_password
284       repo: dessalines/lemmy
285       auto_tag: true
286       auto_tag_suffix: linux-arm64
287     when:
288       ref:
289         - refs/tags/*
290
291   - name: publish release docker manifest
292     image: plugins/manifest
293     settings:
294       username:
295         from_secret: docker_username
296       password:
297         from_secret: docker_password
298       target: "dessalines/lemmy:${DRONE_TAG}"
299       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
300       platforms:
301         - linux/amd64
302         - linux/arm64
303       ignore_missing: true
304     when:
305       ref:
306         - refs/tags/*
307
308   - name: publish latest release docker manifest
309     image: plugins/manifest
310     settings:
311       username:
312         from_secret: docker_username
313       password:
314         from_secret: docker_password
315       target: "dessalines/lemmy:latest"
316       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
317       platforms:
318         - linux/amd64
319         - linux/arm64
320       ignore_missing: true
321     when:
322       ref:
323         - refs/tags/*
324
325 # TODO temporarily disable arm tests
326 # services:
327 #   - name: database
328 #     image: postgres:12-alpine
329 #     environment:
330 #       POSTGRES_USER: lemmy
331 #       POSTGRES_PASSWORD: password