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
72 - cargo clippy --workspace --features console --
73 -D clippy::unwrap_used
74 -D clippy::indexing_slicing
76 - name: lemmy_api_common doesnt depend on diesel
77 image: clux/muslrust:1.67.0
81 - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
83 - name: check defaults.hjson updated
84 image: clux/muslrust:1.67.0
88 - export LEMMY_CONFIG_LOCATION=./config/config.hjson
89 - ./scripts/update_config_defaults.sh config/defaults_current.hjson
90 - diff config/defaults.hjson config/defaults_current.hjson
93 image: clux/muslrust:1.67.0
95 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
100 - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
101 - cargo test --workspace --no-fail-fast
104 image: clux/muslrust:1.67.0
109 - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
111 - name: run federation tests
114 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
115 DO_WRITE_HOSTS_FILE: 1
117 - apk add bash curl postgresql-client
118 - bash api_tests/prepare-drone-federation-test.sh
123 - name: nightly build
124 image: plugins/docker
126 dockerfile: docker/Dockerfile
127 build_args: RUST_RELEASE_MODE=release
129 from_secret: docker_username
131 from_secret: docker_password
132 repo: dessalines/lemmy
133 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
140 - name: publish release docker image
141 image: plugins/docker
143 dockerfile: docker/Dockerfile
144 build_args: RUST_RELEASE_MODE=release
146 from_secret: docker_username
148 from_secret: docker_password
149 repo: dessalines/lemmy
150 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
152 auto_tag_suffix: linux-amd64
157 - name: publish release docker manifest
158 image: plugins/manifest
161 from_secret: docker_username
163 from_secret: docker_password
164 target: "dessalines/lemmy:${DRONE_TAG}"
165 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
174 - name: publish latest release docker manifest
175 image: plugins/manifest
178 from_secret: docker_username
180 from_secret: docker_password
181 target: "dessalines/lemmy:latest"
182 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
191 # using https://github.com/pksunkara/cargo-workspaces
192 - name: publish to crates.io
193 image: clux/muslrust:1.67.0
196 from_secret: cargo_api_token
198 - cargo install cargo-workspaces
199 - cp -r migrations crates/db_schema/
200 - cargo login "$CARGO_TOKEN"
201 - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
206 - name: Notify on failure
210 - "curl -d'Drone build failed: ${DRONE_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
215 - name: Notify on tag deploy
219 - "curl -d'lemmy:${DRONE_TAG} deployed' ntfy.sh/lemmy_drone_ci"
226 image: postgres:15-alpine
229 POSTGRES_PASSWORD: password
242 image: rust:1.57-slim
246 - apt install --no-install-recommends --yes git
249 - git submodule update --recursive --remote
251 # TODO temporarily disable arm tests
253 # image: rust:1.57-slim
255 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
256 # LEMMY_CONFIG_LOCATION: ../../config/config.hjson
258 # RUST_TEST_THREADS: 1
261 # - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
262 # - cargo test --workspace --no-fail-fast
265 # TODO temporarily disable arm tests
266 # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
267 # - name: cargo build
268 # image: rust:1.57-slim
271 # - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
273 # - mv target/debug/lemmy_server target/lemmy_server
275 # TODO temporarily disable arm tests
276 # - name: run federation tests
277 # image: node:16-slim
279 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
280 # DO_WRITE_HOSTS_FILE: 1
282 # - mkdir -p /usr/share/man/man1 /usr/share/man/man7
284 # - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
285 # - bash api_tests/prepare-drone-federation-test.sh
290 - name: publish release docker image
291 image: plugins/docker
293 dockerfile: docker/Dockerfile.arm
295 from_secret: docker_username
297 from_secret: docker_password
298 repo: dessalines/lemmy
300 auto_tag_suffix: linux-arm64
305 - name: publish release docker manifest
306 image: plugins/manifest
309 from_secret: docker_username
311 from_secret: docker_password
312 target: "dessalines/lemmy:${DRONE_TAG}"
313 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
322 - name: publish latest release docker manifest
323 image: plugins/manifest
326 from_secret: docker_username
328 from_secret: docker_password
329 target: "dessalines/lemmy:latest"
330 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
339 # TODO temporarily disable arm tests
342 # image: postgres:12-alpine
344 # POSTGRES_USER: lemmy
345 # POSTGRES_PASSWORD: password