]> Untitled Git - lemmy.git/blob - .drone.yml
Merge pull request 'Upgrade Rust version' (#181) from upgrade-rust into main
[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: chown repo
12     image: ekidd/rust-musl-builder:1.50.0
13     user: root
14     commands:
15       - chown 1000:1000 . -R
16
17   - name: check formatting
18     image: rustdocker/rust:nightly
19     commands:
20       - /root/.cargo/bin/cargo fmt -- --check
21
22   - name: cargo clippy
23     image: ekidd/rust-musl-builder:1.50.0
24     commands:
25       - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro
26
27   - name: cargo test
28     image: ekidd/rust-musl-builder:1.50.0
29     environment:
30       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
31       RUST_BACKTRACE: 1
32     commands:
33       - sudo apt-get update
34       - sudo apt-get -y install --no-install-recommends espeak postgresql-client
35       - cargo test --workspace --no-fail-fast
36
37   - name: cargo build
38     image: ekidd/rust-musl-builder:1.50.0
39     commands:
40       - cargo build
41       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
42
43   - name: run federation tests
44     image: node:15-alpine3.12
45     environment:
46       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
47       DO_WRITE_HOSTS_FILE: 1
48     commands:
49       - apk add bash curl postgresql-client
50       - bash api_tests/prepare-drone-federation-test.sh
51       - cd api_tests/
52       - yarn
53       - yarn api-test
54
55   - name: make release build and push to docker hub
56     image: plugins/docker
57     settings:
58       dockerfile: docker/prod/Dockerfile
59       username:
60         from_secret: docker_username
61       password:
62         from_secret: docker_password
63       repo: dessalines/lemmy
64       auto_tag: true
65       auto_tag_suffix: linux-amd64
66     when:
67       ref:
68       - refs/tags/*
69
70   - name: push to docker manifest
71     image: plugins/manifest
72     settings: 
73       username:
74         from_secret: docker_username
75       password:
76         from_secret: docker_password
77       target: "dessalines/lemmy:${DRONE_TAG}"
78       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
79       platforms:
80         - linux/amd64
81         - linux/arm64
82       ignore_missing: true
83     when:
84       ref:
85       - refs/tags/*
86
87 services:
88   - name: database
89     image: postgres:12-alpine
90     environment:
91       POSTGRES_USER: lemmy
92       POSTGRES_PASSWORD: password
93
94 ---
95 kind: pipeline
96 name: arm64
97
98 platform:
99   os: linux
100   arch: arm64
101
102 steps:
103
104   - name: cargo test
105     image: rust:1.50-slim-buster
106     environment:
107       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
108       RUST_BACKTRACE: 1
109     commands:
110       - apt-get update
111       - apt-get -y install --no-install-recommends espeak postgresql-client libssl-dev pkg-config libpq-dev
112       - cargo test --workspace --no-fail-fast
113       - cargo build
114
115   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
116   - name: cargo build
117     image: rust:1.50-slim-buster
118     commands:
119       - apt-get update
120       - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
121       - cargo build
122       - mv target/debug/lemmy_server target/lemmy_server
123
124   - name: run federation tests
125     image: node:15-buster-slim
126     environment:
127       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
128       DO_WRITE_HOSTS_FILE: 1
129     commands:
130       - mkdir -p /usr/share/man/man1 /usr/share/man/man7
131       - apt-get update
132       - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
133       - bash api_tests/prepare-drone-federation-test.sh
134       - cd api_tests/
135       - yarn
136       - yarn api-test
137
138   - name: make release build and push to docker hub
139     image: plugins/docker
140     settings:
141       dockerfile: docker/prod/Dockerfile.arm
142       username:
143         from_secret: docker_username
144       password:
145         from_secret: docker_password
146       repo: dessalines/lemmy
147       auto_tag: true
148       auto_tag_suffix: linux-arm64
149     when:
150       ref:
151         - refs/tags/*
152
153   - name: push to docker manifest
154     image: plugins/manifest
155     settings: 
156       username:
157         from_secret: docker_username
158       password:
159         from_secret: docker_password
160       target: "dessalines/lemmy:${DRONE_TAG}"
161       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
162       platforms:
163         - linux/amd64
164         - linux/arm64
165       ignore_missing: true
166     when:
167       ref:
168       - refs/tags/*
169
170 services:
171   - name: database
172     image: postgres:12-alpine
173     environment:
174       POSTGRES_USER: lemmy
175       POSTGRES_PASSWORD: password