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