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