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