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