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