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/prod/Dockerfile
125 from_secret: docker_username
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
136 - name: publish release docker image
137 image: plugins/docker
139 dockerfile: docker/prod/Dockerfile
141 from_secret: docker_username
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
147 auto_tag_suffix: linux-amd64
152 - name: publish release docker manifest
153 image: plugins/manifest
156 from_secret: docker_username
158 from_secret: docker_password
159 target: "dessalines/lemmy:${DRONE_TAG}"
160 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
169 - name: publish latest release docker manifest
170 image: plugins/manifest
173 from_secret: docker_username
175 from_secret: docker_password
176 target: "dessalines/lemmy:latest"
177 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
186 # using https://github.com/pksunkara/cargo-workspaces
187 - name: publish to crates.io
188 image: clux/muslrust:1.67.0
191 from_secret: cargo_api_token
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}"
201 - name: Notify on failure
205 - "curl -d'Drone build failed: ${DRONE_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
210 - name: Notify on tag deploy
214 - "curl -d'lemmy:${DRONE_TAG} deployed' ntfy.sh/lemmy_drone_ci"
221 image: postgres:15-alpine
224 POSTGRES_PASSWORD: password
237 image: rust:1.57-slim
241 - apt install --no-install-recommends --yes git
244 - git submodule update --recursive --remote
246 # TODO temporarily disable arm tests
248 # image: rust:1.57-slim
250 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
251 # LEMMY_CONFIG_LOCATION: ../../config/config.hjson
253 # RUST_TEST_THREADS: 1
256 # - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
257 # - cargo test --workspace --no-fail-fast
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
266 # - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
268 # - mv target/debug/lemmy_server target/lemmy_server
270 # TODO temporarily disable arm tests
271 # - name: run federation tests
272 # image: node:16-slim
274 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
275 # DO_WRITE_HOSTS_FILE: 1
277 # - mkdir -p /usr/share/man/man1 /usr/share/man/man7
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
285 - name: publish release docker image
286 image: plugins/docker
288 dockerfile: docker/prod/Dockerfile.arm
290 from_secret: docker_username
292 from_secret: docker_password
293 repo: dessalines/lemmy
295 auto_tag_suffix: linux-arm64
300 - name: publish release docker manifest
301 image: plugins/manifest
304 from_secret: docker_username
306 from_secret: docker_password
307 target: "dessalines/lemmy:${DRONE_TAG}"
308 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
317 - name: publish latest release docker manifest
318 image: plugins/manifest
321 from_secret: docker_username
323 from_secret: docker_password
324 target: "dessalines/lemmy:latest"
325 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
334 # TODO temporarily disable arm tests
337 # image: postgres:12-alpine
339 # POSTGRES_USER: lemmy
340 # POSTGRES_PASSWORD: password