]> Untitled Git - lemmy.git/blob - .drone.yml
Drone release main (ref #1556) (#1557)
[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: chown repo
12     image: ekidd/rust-musl-builder:1.50.0
13     user: root
14     commands:
15       - chown 1000:1000 . -R
16
17   - name: check formatting
18     image: rustdocker/rust:nightly
19     commands:
20       - /root/.cargo/bin/cargo fmt -- --check
21
22   - name: cargo clippy
23     image: ekidd/rust-musl-builder:1.50.0
24     commands:
25       - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro
26       - cargo clippy --workspace -- -D clippy::unwrap_used
27
28   - name: cargo test
29     image: ekidd/rust-musl-builder:1.50.0
30     environment:
31       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
32       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
33       RUST_BACKTRACE: 1
34       RUST_TEST_THREADS: 1
35     commands:
36       - sudo apt-get update
37       - sudo apt-get -y install --no-install-recommends espeak postgresql-client
38       - cargo test --workspace --no-fail-fast
39
40   - name: cargo build
41     image: ekidd/rust-musl-builder:1.50.0
42     commands:
43       - cargo build
44       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
45
46   - name: run federation tests
47     image: node:15-alpine3.12
48     environment:
49       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
50       DO_WRITE_HOSTS_FILE: 1
51     commands:
52       - apk add bash curl postgresql-client
53       - bash api_tests/prepare-drone-federation-test.sh
54       - cd api_tests/
55       - yarn
56       - yarn api-test
57
58   - name: publish dev docker image
59     image: plugins/docker
60     settings:
61       dockerfile: docker/prod/Dockerfile
62       username:
63         from_secret: docker_username
64       password:
65         from_secret: docker_password
66       repo: dessalines/lemmy
67       tags:
68         - dev-linux-amd64
69     when:
70       ref:
71         - refs/heads/main
72
73   - name: publish dev docker manifest
74     image: plugins/manifest
75     settings:
76       username:
77         from_secret: docker_username
78       password:
79         from_secret: docker_password
80       target: "dessalines/lemmy:dev"
81       template: "dessalines/lemmy:dev-OS-ARCH"
82       platforms:
83         - linux/amd64
84         - linux/arm64
85       ignore_missing: true
86     when:
87       ref:
88         - refs/heads/main
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 services:
123   - name: database
124     image: postgres:12-alpine
125     environment:
126       POSTGRES_USER: lemmy
127       POSTGRES_PASSWORD: password
128
129 ---
130 kind: pipeline
131 name: arm64
132
133 platform:
134   os: linux
135   arch: arm64
136
137 steps:
138
139   - name: cargo test
140     image: rust:1.50-slim-buster
141     environment:
142       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
143       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
144       RUST_BACKTRACE: 1
145       RUST_TEST_THREADS: 1
146     commands:
147       - apt-get update
148       - apt-get -y install --no-install-recommends espeak postgresql-client libssl-dev pkg-config libpq-dev
149       - cargo test --workspace --no-fail-fast
150       - cargo build
151
152   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
153   - name: cargo build
154     image: rust:1.50-slim-buster
155     commands:
156       - apt-get update
157       - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
158       - cargo build
159       - mv target/debug/lemmy_server target/lemmy_server
160
161   - name: run federation tests
162     image: node:15-buster-slim
163     environment:
164       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
165       DO_WRITE_HOSTS_FILE: 1
166     commands:
167       - mkdir -p /usr/share/man/man1 /usr/share/man/man7
168       - apt-get update
169       - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
170       - bash api_tests/prepare-drone-federation-test.sh
171       - cd api_tests/
172       - yarn
173       - yarn api-test
174
175   - name: publish dev docker image
176     image: plugins/docker
177     settings:
178       dockerfile: docker/prod/Dockerfile.arm
179       username:
180         from_secret: docker_username
181       password:
182         from_secret: docker_password
183       repo: dessalines/lemmy
184       tags:
185         - dev-linux-arm64
186     when:
187       ref:
188         - refs/heads/main
189
190   - name: publish dev docker manifest
191     image: plugins/manifest
192     settings:
193       username:
194         from_secret: docker_username
195       password:
196         from_secret: docker_password
197       target: "dessalines/lemmy:dev"
198       template: "dessalines/lemmy:dev-OS-ARCH"
199       platforms:
200         - linux/amd64
201         - linux/arm64
202       ignore_missing: true
203     when:
204       ref:
205         - refs/heads/main
206
207   - name: publish release docker image
208     image: plugins/docker
209     settings:
210       dockerfile: docker/prod/Dockerfile.arm
211       username:
212         from_secret: docker_username
213       password:
214         from_secret: docker_password
215       repo: dessalines/lemmy
216       auto_tag: true
217       auto_tag_suffix: linux-arm64
218     when:
219       ref:
220         - refs/tags/*
221
222   - name: publish release docker manifest
223     image: plugins/manifest
224     settings: 
225       username:
226         from_secret: docker_username
227       password:
228         from_secret: docker_password
229       target: "dessalines/lemmy:${DRONE_TAG}"
230       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
231       platforms:
232         - linux/amd64
233         - linux/arm64
234       ignore_missing: true
235     when:
236       ref:
237         - refs/tags/*
238
239 services:
240   - name: database
241     image: postgres:12-alpine
242     environment:
243       POSTGRES_USER: lemmy
244       POSTGRES_PASSWORD: password