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