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