11 # use minimum supported rust version for most steps
13 image: clux/muslrust:1.64.0
17 - git submodule update --recursive --remote
18 - chown 1000:1000 . -R
20 - name: check formatting
21 image: rustdocker/rust:nightly
23 - /root/.cargo/bin/cargo fmt -- --check
25 # latest rust for clippy to get extra checks
26 # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
28 image: rust:1.65-buster
31 - apt-get -y install protobuf-compiler libprotobuf-dev
32 - rustup component add clippy
33 - cargo clippy --workspace --tests --all-targets --all-features --
34 -D warnings -D deprecated -D clippy::perf -D clippy::complexity
35 -D clippy::style -D clippy::correctness -D clippy::suspicious
36 -D clippy::dbg_macro -D clippy::inefficient_to_string
37 -D clippy::items-after-statements -D clippy::implicit_clone
38 -D clippy::wildcard_imports -D clippy::cast_lossless
39 -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls
40 -D clippy::unused_self
41 - cargo clippy --workspace --all-features -- -D clippy::unwrap_used
44 image: clux/muslrust:1.64.0
46 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
47 LEMMY_CONFIG_LOCATION: ../../config/config.hjson
52 - apt-get -y install --no-install-recommends postgresql-client protobuf-compiler libprotobuf-dev
53 - cargo test --workspace --no-fail-fast --all-features
55 - name: check defaults.hjson updated
56 image: clux/muslrust:1.64.0
58 - ./scripts/update_config_defaults.sh config/defaults_current.hjson
59 - diff config/defaults.hjson config/defaults_current.hjson
61 - name: check with different features
62 image: clux/muslrust:1.64.0
64 - cargo install cargo-workspaces
65 - cargo workspaces exec cargo check --no-default-features
66 - cargo workspaces exec cargo check --all-features
68 - name: lemmy_api_common doesnt depend on diesel
69 image: rust:1.64-buster
71 - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
74 image: clux/muslrust:1.64.0
77 - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
79 - name: run federation tests
82 LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
83 DO_WRITE_HOSTS_FILE: 1
85 - apk add bash curl postgresql-client
86 - bash api_tests/prepare-drone-federation-test.sh
94 dockerfile: docker/prod/Dockerfile
96 from_secret: docker_username
98 from_secret: docker_password
99 repo: dessalines/lemmy
106 - name: publish release docker image
107 image: plugins/docker
109 dockerfile: docker/prod/Dockerfile
111 from_secret: docker_username
113 from_secret: docker_password
114 repo: dessalines/lemmy
116 auto_tag_suffix: linux-amd64
121 - name: publish release docker manifest
122 image: plugins/manifest
125 from_secret: docker_username
127 from_secret: docker_password
128 target: "dessalines/lemmy:${DRONE_TAG}"
129 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
138 - name: publish latest release docker manifest
139 image: plugins/manifest
142 from_secret: docker_username
144 from_secret: docker_password
145 target: "dessalines/lemmy:latest"
146 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
155 # using https://github.com/pksunkara/cargo-workspaces
156 - name: publish to crates.io
157 image: rustlang/rust:nightly
160 from_secret: cargo_api_token
162 - cargo install cargo-workspaces
163 - cp -r migrations crates/db_schema/
164 - cargo login "$CARGO_TOKEN"
165 - cargo workspaces publish --from-git --allow-dirty --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
172 image: postgres:14-alpine
175 POSTGRES_PASSWORD: password
188 image: rust:1.57-slim
191 - chown 1000:1000 . -R
193 - apt install --no-install-recommends --yes git
196 - git submodule update --recursive --remote
198 # TODO temporarily disable arm tests
200 # image: rust:1.57-slim
202 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
203 # LEMMY_CONFIG_LOCATION: ../../config/config.hjson
205 # RUST_TEST_THREADS: 1
208 # - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
209 # - cargo test --workspace --no-fail-fast
212 # TODO temporarily disable arm tests
213 # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
214 # - name: cargo build
215 # image: rust:1.57-slim
218 # - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
220 # - mv target/debug/lemmy_server target/lemmy_server
222 # TODO temporarily disable arm tests
223 # - name: run federation tests
224 # image: node:16-slim
226 # LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
227 # DO_WRITE_HOSTS_FILE: 1
229 # - mkdir -p /usr/share/man/man1 /usr/share/man/man7
231 # - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
232 # - bash api_tests/prepare-drone-federation-test.sh
237 - name: publish release docker image
238 image: plugins/docker
240 dockerfile: docker/prod/Dockerfile.arm
242 from_secret: docker_username
244 from_secret: docker_password
245 repo: dessalines/lemmy
247 auto_tag_suffix: linux-arm64
252 - name: publish release docker manifest
253 image: plugins/manifest
256 from_secret: docker_username
258 from_secret: docker_password
259 target: "dessalines/lemmy:${DRONE_TAG}"
260 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
269 - name: publish latest release docker manifest
270 image: plugins/manifest
273 from_secret: docker_username
275 from_secret: docker_password
276 target: "dessalines/lemmy:latest"
277 template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
286 # TODO temporarily disable arm tests
289 # image: postgres:12-alpine
291 # POSTGRES_USER: lemmy
292 # POSTGRES_PASSWORD: password