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