]> Untitled Git - lemmy.git/blob - .drone.yml
Add some more clippy lints (#2586)
[lemmy.git] / .drone.yml
1 ---
2 kind: pipeline
3 name: amd64
4
5 platform:
6   os: linux
7   arch: amd64
8
9 steps:
10
11   # use minimum supported rust version for most steps
12   - name: prepare repo
13     image: clux/muslrust:1.64.0
14     commands:
15       - git fetch --tags
16       - git submodule init
17       - git submodule update --recursive --remote
18       - chown 1000:1000 . -R
19
20   - name: check formatting
21     image: rustdocker/rust:nightly
22     commands:
23       - /root/.cargo/bin/cargo fmt -- --check
24
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
27   - name: cargo clippy
28     image: rust:1.65-buster
29     commands:
30       - apt-get update
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
42
43   - name: cargo test
44     image: clux/muslrust:1.64.0
45     environment:
46       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
47       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
48       RUST_BACKTRACE: 1
49       RUST_TEST_THREADS: 1
50     commands:
51       - apt-get update
52       - apt-get -y install --no-install-recommends postgresql-client protobuf-compiler libprotobuf-dev
53       - cargo test --workspace --no-fail-fast --all-features
54
55   - name: check defaults.hjson updated
56     image: clux/muslrust:1.64.0
57     commands:
58       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
59       - diff config/defaults.hjson config/defaults_current.hjson
60
61   - name: check with different features
62     image: clux/muslrust:1.64.0
63     commands:
64       - cargo install cargo-workspaces
65       - cargo workspaces exec cargo check --no-default-features
66       - cargo workspaces exec cargo check --all-features
67
68   - name: lemmy_api_common doesnt depend on diesel
69     image: rust:1.64-buster
70     commands:
71       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
72
73   - name: cargo build
74     image: clux/muslrust:1.64.0
75     commands:
76       - cargo build
77       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
78
79   - name: run federation tests
80     image: node:alpine
81     environment:
82       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
83       DO_WRITE_HOSTS_FILE: 1
84     commands:
85       - apk add bash curl postgresql-client
86       - bash api_tests/prepare-drone-federation-test.sh
87       - cd api_tests/
88       - yarn
89       - yarn api-test
90
91   - name: nightly build
92     image: plugins/docker
93     settings:
94       dockerfile: docker/prod/Dockerfile
95       username:
96         from_secret: docker_username
97       password:
98         from_secret: docker_password
99       repo: dessalines/lemmy
100       tags:
101         - dev
102     when:
103       event:
104         - cron
105
106   - name: publish release docker image
107     image: plugins/docker
108     settings:
109       dockerfile: docker/prod/Dockerfile
110       username:
111         from_secret: docker_username
112       password:
113         from_secret: docker_password
114       repo: dessalines/lemmy
115       auto_tag: true
116       auto_tag_suffix: linux-amd64
117     when:
118       ref:
119         - refs/tags/*
120
121   - name: publish release docker manifest
122     image: plugins/manifest
123     settings:
124       username:
125         from_secret: docker_username
126       password:
127         from_secret: docker_password
128       target: "dessalines/lemmy:${DRONE_TAG}"
129       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
130       platforms:
131         - linux/amd64
132         - linux/arm64
133       ignore_missing: true
134     when:
135       ref:
136         - refs/tags/*
137
138   - name: publish latest release docker manifest
139     image: plugins/manifest
140     settings:
141       username:
142         from_secret: docker_username
143       password:
144         from_secret: docker_password
145       target: "dessalines/lemmy:latest"
146       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
147       platforms:
148         - linux/amd64
149         - linux/arm64
150       ignore_missing: true
151     when:
152       ref:
153         - refs/tags/*
154
155   # using https://github.com/pksunkara/cargo-workspaces
156   - name: publish to crates.io
157     image: rustlang/rust:nightly
158     environment:
159       CARGO_TOKEN:
160         from_secret: cargo_api_token
161     commands:
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}"
166     when:
167       ref:
168         - refs/tags/*
169
170 services:
171   - name: database
172     image: postgres:14-alpine
173     environment:
174       POSTGRES_USER: lemmy
175       POSTGRES_PASSWORD: password
176
177 ---
178 kind: pipeline
179 name: arm64
180
181 platform:
182   os: linux
183   arch: arm64
184
185 steps:
186
187   - name: prepare repo
188     image: rust:1.57-slim
189     user: root
190     commands:
191       - chown 1000:1000 . -R
192       - apt update
193       - apt install --no-install-recommends --yes git
194       - git fetch --tags
195       - git submodule init
196       - git submodule update --recursive --remote
197
198   # TODO temporarily disable arm tests
199   # - name: cargo test
200   #   image: rust:1.57-slim
201   #   environment:
202   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
203   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
204   #     RUST_BACKTRACE: 1
205   #     RUST_TEST_THREADS: 1
206   #   commands:
207   #     - apt-get update
208   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
209   #     - cargo test --workspace --no-fail-fast
210   #     - cargo build
211
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
216   #   commands:
217   #     - apt-get update
218   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
219   #     - cargo build
220   #     - mv target/debug/lemmy_server target/lemmy_server
221
222   # TODO temporarily disable arm tests
223   # - name: run federation tests
224   #   image: node:16-slim
225   #   environment:
226   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
227   #     DO_WRITE_HOSTS_FILE: 1
228   #   commands:
229   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
230   #     - apt-get update
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
233   #     - cd api_tests/
234   #     - yarn
235   #     - yarn api-test
236
237   - name: publish release docker image
238     image: plugins/docker
239     settings:
240       dockerfile: docker/prod/Dockerfile.arm
241       username:
242         from_secret: docker_username
243       password:
244         from_secret: docker_password
245       repo: dessalines/lemmy
246       auto_tag: true
247       auto_tag_suffix: linux-arm64
248     when:
249       ref:
250         - refs/tags/*
251
252   - name: publish release docker manifest
253     image: plugins/manifest
254     settings:
255       username:
256         from_secret: docker_username
257       password:
258         from_secret: docker_password
259       target: "dessalines/lemmy:${DRONE_TAG}"
260       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
261       platforms:
262         - linux/amd64
263         - linux/arm64
264       ignore_missing: true
265     when:
266       ref:
267         - refs/tags/*
268
269   - name: publish latest release docker manifest
270     image: plugins/manifest
271     settings:
272       username:
273         from_secret: docker_username
274       password:
275         from_secret: docker_password
276       target: "dessalines/lemmy:latest"
277       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
278       platforms:
279         - linux/amd64
280         - linux/arm64
281       ignore_missing: true
282     when:
283       ref:
284         - refs/tags/*
285
286 # TODO temporarily disable arm tests
287 # services:
288 #   - name: database
289 #     image: postgres:12-alpine
290 #     environment:
291 #       POSTGRES_USER: lemmy
292 #       POSTGRES_PASSWORD: password