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