11 # use minimum supported rust version for most steps
18 - git submodule update --recursive --remote
21 image: clux/muslrust:1.67.0
23 # store cargo data in repo folder so that it gets cached between steps
26 # need make existing toolchain available
28 - rustup toolchain install nightly
29 - rustup component add rustfmt --toolchain nightly
30 - cargo +nightly fmt -- --check
32 # check each package to make sure they compile with default features.
33 # this is required for crates.io
35 image: clux/muslrust:1.67.0
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
55 image: clux/muslrust:1.67.0
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
73 - name: lemmy_api_common doesnt depend on diesel
74 image: clux/muslrust:1.67.0
78 - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
80 - name: check defaults.hjson updated
81 image: clux/muslrust:1.67.0
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
90 image: clux/muslrust:1.67.0
92 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
97 - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
98 - cargo test --workspace --no-fail-fast
101 image: clux/muslrust:1.67.0
106 - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
108 - name: run federation tests
111 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
112 DO_WRITE_HOSTS_FILE: 1
114 - apk add bash curl postgresql-client
115 - bash api_tests/prepare-drone-federation-test.sh
120 - name: nightly build
121 image: plugins/docker
123 dockerfile: docker/Dockerfile
124 build_args: RUST_RELEASE_MODE=release
126 from_secret: docker_username
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
137 - name: publish release docker image
138 image: plugins/docker
140 dockerfile: docker/Dockerfile
141 build_args: RUST_RELEASE_MODE=release
143 from_secret: docker_username
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
149 auto_tag_suffix: linux-amd64
154 - name: publish release docker manifest
155 image: plugins/manifest
158 from_secret: docker_username
160 from_secret: docker_password
161 target: "dessalines/lemmy:${DRONE_TAG}"
162 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
171 - name: publish latest release docker manifest
172 image: plugins/manifest
175 from_secret: docker_username
177 from_secret: docker_password
178 target: "dessalines/lemmy:latest"
179 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
188 # using https://github.com/pksunkara/cargo-workspaces
189 - name: publish to crates.io
190 image: clux/muslrust:1.67.0
193 from_secret: cargo_api_token
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}"
203 - name: Notify on failure
207 - "curl -d'Drone build failed: ${DRONE_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
212 - name: Notify on tag deploy
216 - "curl -d'lemmy:${DRONE_TAG} deployed' ntfy.sh/lemmy_drone_ci"
223 image: postgres:15-alpine
226 POSTGRES_PASSWORD: password
239 image: rust:1.57-slim
243 - apt install --no-install-recommends --yes git
246 - git submodule update --recursive --remote
248 # TODO temporarily disable arm tests
250 # image: rust:1.57-slim
252 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
253 # LEMMY_CONFIG_LOCATION: ../../config/config.hjson
255 # RUST_TEST_THREADS: 1
258 # - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
259 # - cargo test --workspace --no-fail-fast
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
268 # - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
270 # - mv target/debug/lemmy_server target/lemmy_server
272 # TODO temporarily disable arm tests
273 # - name: run federation tests
274 # image: node:16-slim
276 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
277 # DO_WRITE_HOSTS_FILE: 1
279 # - mkdir -p /usr/share/man/man1 /usr/share/man/man7
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
287 - name: publish release docker image
288 image: plugins/docker
290 dockerfile: docker/Dockerfile.arm
292 from_secret: docker_username
294 from_secret: docker_password
295 repo: dessalines/lemmy
297 auto_tag_suffix: linux-arm64
302 - name: publish release docker manifest
303 image: plugins/manifest
306 from_secret: docker_username
308 from_secret: docker_password
309 target: "dessalines/lemmy:${DRONE_TAG}"
310 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
319 - name: publish latest release docker manifest
320 image: plugins/manifest
323 from_secret: docker_username
325 from_secret: docker_password
326 target: "dessalines/lemmy:latest"
327 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
336 # TODO temporarily disable arm tests
339 # image: postgres:12-alpine
341 # POSTGRES_USER: lemmy
342 # POSTGRES_PASSWORD: password