]> Untitled Git - lemmy.git/blob - .drone.yml
WIP: Email localization (fixes #500) (#2053)
[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
158   # TODO temporarily disable arm tests
159   # - name: cargo test
160   #   image: rust:1.56-slim
161   #   environment:
162   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
163   #     LEMMY_CONFIG_LOCATION: ../../config/config.hjson
164   #     RUST_BACKTRACE: 1
165   #     RUST_TEST_THREADS: 1
166   #   commands:
167   #     - apt-get update
168   #     - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
169   #     - cargo test --workspace --no-fail-fast
170   #     - cargo build
171
172   # TODO temporarily disable arm tests
173   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
174   # - name: cargo build
175   #   image: rust:1.56-slim
176   #   commands:
177   #     - apt-get update
178   #     - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
179   #     - cargo build
180   #     - mv target/debug/lemmy_server target/lemmy_server
181
182   # TODO temporarily disable arm tests
183   # - name: run federation tests
184   #   image: node:16-slim
185   #   environment:
186   #     LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
187   #     DO_WRITE_HOSTS_FILE: 1
188   #   commands:
189   #     - mkdir -p /usr/share/man/man1 /usr/share/man/man7
190   #     - apt-get update
191   #     - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
192   #     - bash api_tests/prepare-drone-federation-test.sh
193   #     - cd api_tests/
194   #     - yarn
195   #     - yarn api-test
196
197   - name: publish release docker image
198     image: plugins/docker
199     settings:
200       dockerfile: docker/prod/Dockerfile.arm
201       username:
202         from_secret: docker_username
203       password:
204         from_secret: docker_password
205       repo: dessalines/lemmy
206       auto_tag: true
207       auto_tag_suffix: linux-arm64
208     when:
209       ref:
210         - refs/tags/*
211
212   - name: publish release docker manifest
213     image: plugins/manifest
214     settings:
215       username:
216         from_secret: docker_username
217       password:
218         from_secret: docker_password
219       target: "dessalines/lemmy:${DRONE_TAG}"
220       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
221       platforms:
222         - linux/amd64
223         - linux/arm64
224       ignore_missing: true
225     when:
226       ref:
227         - refs/tags/*
228
229   - name: publish latest release docker manifest
230     image: plugins/manifest
231     settings:
232       username:
233         from_secret: docker_username
234       password:
235         from_secret: docker_password
236       target: "dessalines/lemmy:latest"
237       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
238       platforms:
239         - linux/amd64
240         - linux/arm64
241       ignore_missing: true
242     when:
243       ref:
244         - refs/tags/*
245
246 # TODO temporarily disable arm tests
247 # services:
248 #   - name: database
249 #     image: postgres:12-alpine
250 #     environment:
251 #       POSTGRES_USER: lemmy
252 #       POSTGRES_PASSWORD: password