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