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"
212 image: postgres:15-alpine
215 POSTGRES_PASSWORD: password
228 image: rust:1.57-slim
232 - apt install --no-install-recommends --yes git
235 - git submodule update --recursive --remote
237 # TODO temporarily disable arm tests
239 # image: rust:1.57-slim
241 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
242 # LEMMY_CONFIG_LOCATION: ../../config/config.hjson
244 # RUST_TEST_THREADS: 1
247 # - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
248 # - cargo test --workspace --no-fail-fast
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
257 # - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
259 # - mv target/debug/lemmy_server target/lemmy_server
261 # TODO temporarily disable arm tests
262 # - name: run federation tests
263 # image: node:16-slim
265 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
266 # DO_WRITE_HOSTS_FILE: 1
268 # - mkdir -p /usr/share/man/man1 /usr/share/man/man7
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
276 - name: publish release docker image
277 image: plugins/docker
279 dockerfile: docker/prod/Dockerfile.arm
281 from_secret: docker_username
283 from_secret: docker_password
284 repo: dessalines/lemmy
286 auto_tag_suffix: linux-arm64
291 - name: publish release docker manifest
292 image: plugins/manifest
295 from_secret: docker_username
297 from_secret: docker_password
298 target: "dessalines/lemmy:${DRONE_TAG}"
299 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
308 - name: publish latest release docker manifest
309 image: plugins/manifest
312 from_secret: docker_username
314 from_secret: docker_password
315 target: "dessalines/lemmy:latest"
316 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
325 # TODO temporarily disable arm tests
328 # image: postgres:12-alpine
330 # POSTGRES_USER: lemmy
331 # POSTGRES_PASSWORD: password