]> Untitled Git - lemmy.git/blob - .drone.yml
Speeding up comment-ltree migration, fixing index creation. Fixes #2664 (#2670)
[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     environment:
30       CARGO_HOME: .cargo
31     commands:
32       - apt-get update
33       - apt-get install -y --no-install-recommends protobuf-compiler libprotobuf-dev
34       - rustup component add clippy
35       - cargo clippy --workspace --tests --all-targets --all-features -- 
36           -D warnings -D deprecated -D clippy::perf -D clippy::complexity 
37           -D clippy::style -D clippy::correctness -D clippy::suspicious
38           -D clippy::dbg_macro -D clippy::inefficient_to_string 
39           -D clippy::items-after-statements -D clippy::implicit_clone 
40           -D clippy::wildcard_imports -D clippy::cast_lossless 
41           -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls 
42           -D clippy::unused_self
43       - cargo clippy --workspace --all-features -- -D clippy::unwrap_used
44
45   - name: cargo test
46     image: clux/muslrust:1.64.0
47     environment:
48       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
49       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
50       RUST_BACKTRACE: 1
51       RUST_TEST_THREADS: 1
52       CARGO_HOME: .cargo
53     commands:
54       - apt-get update
55       - apt-get -y install --no-install-recommends postgresql-client protobuf-compiler libprotobuf-dev
56       - cargo test --workspace --no-fail-fast --all-features
57
58   - name: check defaults.hjson updated
59     image: clux/muslrust:1.64.0
60     environment:
61       CARGO_HOME: .cargo
62     commands:
63       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
64       - diff config/defaults.hjson config/defaults_current.hjson
65
66   - name: check with different features
67     image: clux/muslrust:1.64.0
68     environment:
69       CARGO_HOME: .cargo
70     commands:
71       - cargo install cargo-workspaces
72       - cargo workspaces exec cargo check --no-default-features
73       - cargo workspaces exec cargo check --all-features
74
75   - name: lemmy_api_common doesnt depend on diesel
76     image: rust:1.64-buster
77     commands:
78       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
79
80   - name: cargo build
81     image: clux/muslrust:1.64.0
82     environment:
83       CARGO_HOME: .cargo
84     commands:
85       - cargo build
86       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
87
88   - name: run federation tests
89     image: node:alpine
90     environment:
91       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
92       DO_WRITE_HOSTS_FILE: 1
93     commands:
94       - apk add bash curl postgresql-client
95       - bash api_tests/prepare-drone-federation-test.sh
96       - cd api_tests/
97       - yarn
98       - yarn api-test
99
100   - name: nightly build
101     image: plugins/docker
102     settings:
103       dockerfile: docker/prod/Dockerfile
104       username:
105         from_secret: docker_username
106       password:
107         from_secret: docker_password
108       repo: dessalines/lemmy
109       tags:
110         - dev
111     when:
112       event:
113         - cron
114
115   - name: publish release docker image
116     image: plugins/docker
117     settings:
118       dockerfile: docker/prod/Dockerfile
119       username:
120         from_secret: docker_username
121       password:
122         from_secret: docker_password
123       repo: dessalines/lemmy
124       auto_tag: true
125       auto_tag_suffix: linux-amd64
126     when:
127       ref:
128         - refs/tags/*
129
130   - name: publish release docker manifest
131     image: plugins/manifest
132     settings:
133       username:
134         from_secret: docker_username
135       password:
136         from_secret: docker_password
137       target: "dessalines/lemmy:${DRONE_TAG}"
138       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
139       platforms:
140         - linux/amd64
141         - linux/arm64
142       ignore_missing: true
143     when:
144       ref:
145         - refs/tags/*
146
147   - name: publish latest release docker manifest
148     image: plugins/manifest
149     settings:
150       username:
151         from_secret: docker_username
152       password:
153         from_secret: docker_password
154       target: "dessalines/lemmy:latest"
155       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
156       platforms:
157         - linux/amd64
158         - linux/arm64
159       ignore_missing: true
160     when:
161       ref:
162         - refs/tags/*
163
164   # using https://github.com/pksunkara/cargo-workspaces
165   - name: publish to crates.io
166     image: rustlang/rust:nightly
167     environment:
168       CARGO_TOKEN:
169         from_secret: cargo_api_token
170     commands:
171       - cargo install cargo-workspaces
172       - cp -r migrations crates/db_schema/
173       - cargo login "$CARGO_TOKEN"
174       - cargo workspaces publish --from-git --allow-dirty --allow-branch "${DRONE_TAG}" --yes custom "${DRONE_TAG}"
175     when:
176       ref:
177         - refs/tags/*
178
179 services:
180   - name: database
181     image: postgres:14-alpine
182     environment:
183       POSTGRES_USER: lemmy
184       POSTGRES_PASSWORD: password
185
186 ---
187 kind: pipeline
188 name: arm64
189
190 platform:
191   os: linux
192   arch: arm64
193
194 steps:
195
196   - name: prepare repo
197     image: rust:1.57-slim
198     user: root
199     commands:
200       - chown 1000:1000 . -R
201       - apt update
202       - apt install --no-install-recommends --yes git
203       - git fetch --tags
204       - git submodule init
205       - git submodule update --recursive --remote
206
207   # TODO temporarily disable arm tests
208   # - name: cargo test
209   #   image: rust:1.57-slim
210   #   environment:
211   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
212   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
213   #     RUST_BACKTRACE: 1
214   #     RUST_TEST_THREADS: 1
215   #   commands:
216   #     - apt-get update
217   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
218   #     - cargo test --workspace --no-fail-fast
219   #     - cargo build
220
221   # TODO temporarily disable arm tests
222   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
223   # - name: cargo build
224   #   image: rust:1.57-slim
225   #   commands:
226   #     - apt-get update
227   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
228   #     - cargo build
229   #     - mv target/debug/lemmy_server target/lemmy_server
230
231   # TODO temporarily disable arm tests
232   # - name: run federation tests
233   #   image: node:16-slim
234   #   environment:
235   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
236   #     DO_WRITE_HOSTS_FILE: 1
237   #   commands:
238   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
239   #     - apt-get update
240   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
241   #     - bash api_tests/prepare-drone-federation-test.sh
242   #     - cd api_tests/
243   #     - yarn
244   #     - yarn api-test
245
246   - name: publish release docker image
247     image: plugins/docker
248     settings:
249       dockerfile: docker/prod/Dockerfile.arm
250       username:
251         from_secret: docker_username
252       password:
253         from_secret: docker_password
254       repo: dessalines/lemmy
255       auto_tag: true
256       auto_tag_suffix: linux-arm64
257     when:
258       ref:
259         - refs/tags/*
260
261   - name: publish release docker manifest
262     image: plugins/manifest
263     settings:
264       username:
265         from_secret: docker_username
266       password:
267         from_secret: docker_password
268       target: "dessalines/lemmy:${DRONE_TAG}"
269       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
270       platforms:
271         - linux/amd64
272         - linux/arm64
273       ignore_missing: true
274     when:
275       ref:
276         - refs/tags/*
277
278   - name: publish latest release docker manifest
279     image: plugins/manifest
280     settings:
281       username:
282         from_secret: docker_username
283       password:
284         from_secret: docker_password
285       target: "dessalines/lemmy:latest"
286       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
287       platforms:
288         - linux/amd64
289         - linux/arm64
290       ignore_missing: true
291     when:
292       ref:
293         - refs/tags/*
294
295 # TODO temporarily disable arm tests
296 # services:
297 #   - name: database
298 #     image: postgres:12-alpine
299 #     environment:
300 #       POSTGRES_USER: lemmy
301 #       POSTGRES_PASSWORD: password