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