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