]> Untitled Git - lemmy.git/blob - .woodpecker.yml
fe581ab426782b31faed7ec063a10b1daed6f309
[lemmy.git] / .woodpecker.yml
1 # TODO: The when: platform conditionals aren't working currently
2 # See https://github.com/woodpecker-ci/woodpecker/issues/1677
3
4 variables:
5   - &muslrust_image "clux/muslrust:1.70.0"
6
7 # Broken for cron jobs currently, see
8 # https://github.com/woodpecker-ci/woodpecker/issues/1716
9 # clone:
10 #   git:
11 #     image: woodpeckerci/plugin-git
12 #     settings:
13 #       recursive: true
14 #       submodule_update_remote: true
15
16 pipeline:
17   prepare_repo:
18     image: alpine:3
19     commands:
20       - apk add git
21       - git submodule init
22       - git submodule update
23
24   prettier_check:
25     image: tmknom/prettier:3.0.0
26     commands:
27       - prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'
28
29   restore-cache:
30     image: meltwater/drone-cache:v1
31     pull: true
32     settings:
33       restore: true
34       endpoint:
35         from_secret: MINIO_ENDPOINT
36       access-key:
37         from_secret: MINIO_WRITE_USER
38       secret-key:
39         from_secret: MINIO_WRITE_PASSWORD
40       bucket:
41         from_secret: MINIO_BUCKET
42       region: us-east-1
43       cache_key: "rust-cache"
44       path-style: true
45       mount:
46         - ".cargo"
47         - "target"
48         - "api_tests/node_modules"
49     secrets:
50       [MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET]
51
52   toml_fmt:
53     image: tamasfe/taplo:0.8.1
54     commands:
55       - taplo format --check
56
57   cargo_fmt:
58     image: *muslrust_image
59     environment:
60       # store cargo data in repo folder so that it gets cached between steps
61       CARGO_HOME: .cargo
62     commands:
63       # need make existing toolchain available
64       - cp -n ~/.cargo . -r
65       - rustup toolchain install nightly-2023-07-10
66       - rustup component add rustfmt --toolchain nightly-2023-07-10
67       - cargo +nightly-2023-07-10 fmt -- --check
68     # when:
69     #   platform: linux/amd64
70
71   cargo_clippy:
72     image: *muslrust_image
73     environment:
74       CARGO_HOME: .cargo
75     commands:
76       # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
77       - rustup component add clippy
78       - cargo clippy --workspace --tests --all-targets --features console --
79         -D warnings -D deprecated -D clippy::perf -D clippy::complexity
80         -D clippy::style -D clippy::correctness -D clippy::suspicious
81         -D clippy::dbg_macro -D clippy::inefficient_to_string
82         -D clippy::items-after-statements -D clippy::implicit_clone
83         -D clippy::cast_lossless -D clippy::manual_string_new
84         -D clippy::redundant_closure_for_method_calls
85         -D clippy::unused_self
86         -A clippy::uninlined_format_args
87         -D clippy::get_first
88         -D clippy::explicit_into_iter_loop
89         -D clippy::explicit_iter_loop
90         -D clippy::needless_collect
91         -D clippy::unwrap_used
92         -D clippy::indexing_slicing
93     # when:
94     #   platform: linux/amd64
95
96   # make sure api builds with default features (used by other crates relying on lemmy api)
97   check_api_common_default_features:
98     image: *muslrust_image
99     environment:
100       CARGO_HOME: .cargo
101     commands:
102       - cargo check --package lemmy_api_common
103     # when:
104     #   platform: linux/amd64
105
106   lemmy_api_common_doesnt_depend_on_diesel:
107     image: *muslrust_image
108     environment:
109       CARGO_HOME: .cargo
110     commands:
111       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
112     # when:
113     #   platform: linux/amd64
114
115   lemmy_api_common_works_with_wasm:
116     image: *muslrust_image
117     environment:
118       CARGO_HOME: .cargo
119     commands:
120       - "rustup target add wasm32-unknown-unknown"
121       - "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"
122
123   check_defaults_hjson_updated:
124     image: *muslrust_image
125     environment:
126       CARGO_HOME: .cargo
127     commands:
128       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
129       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
130       - diff config/defaults.hjson config/defaults_current.hjson
131     # when:
132     #   platform: linux/amd64
133
134   check_diesel_schema:
135     image: willsquire/diesel-cli
136     environment:
137       CARGO_HOME: .cargo
138       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
139     commands:
140       - diesel migration run
141       - diesel print-schema --config-file=diesel.toml > tmp.schema
142       - diff tmp.schema crates/db_schema/src/schema.rs
143
144   cargo_test:
145     image: *muslrust_image
146     environment:
147       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
148       RUST_BACKTRACE: "1"
149       CARGO_HOME: .cargo
150     commands:
151       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
152       - cargo test --workspace --no-fail-fast
153     # when:
154     #   platform: linux/amd64
155
156   cargo_build:
157     image: *muslrust_image
158     environment:
159       CARGO_HOME: .cargo
160     commands:
161       - cargo build
162       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
163     # when:
164     #   platform: linux/amd64
165
166   run_federation_tests:
167     image: node:alpine
168     environment:
169       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
170       DO_WRITE_HOSTS_FILE: "1"
171     commands:
172       - apk add bash curl postgresql-client
173       - bash api_tests/prepare-drone-federation-test.sh
174       - cd api_tests/
175       - yarn
176       - yarn api-test
177     # when:
178     #   platform: linux/amd64
179
180   rebuild-cache:
181     image: meltwater/drone-cache:v1
182     pull: true
183     settings:
184       rebuild: true
185       endpoint:
186         from_secret: MINIO_ENDPOINT
187       access-key:
188         from_secret: MINIO_WRITE_USER
189       secret-key:
190         from_secret: MINIO_WRITE_PASSWORD
191       bucket:
192         from_secret: MINIO_BUCKET
193       cache_key: "rust-cache"
194       region: us-east-1
195       path-style: true
196       mount:
197         - ".cargo"
198         - "target"
199         - "api_tests/node_modules"
200     secrets:
201       [MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET]
202
203   publish_release_docker:
204     image: woodpeckerci/plugin-docker-buildx
205     secrets: [docker_username, docker_password]
206     settings:
207       repo: dessalines/lemmy
208       dockerfile: docker/Dockerfile
209       platforms: linux/amd64
210       build_args:
211         - RUST_RELEASE_MODE=release
212       auto_tag: true
213     when:
214       event: tag
215
216   nightly_build:
217     image: woodpeckerci/plugin-docker-buildx
218     secrets: [docker_username, docker_password]
219     settings:
220       repo: dessalines/lemmy
221       dockerfile: docker/Dockerfile
222       platforms: linux/amd64
223       build_args:
224         - RUST_RELEASE_MODE=release
225       tag: dev
226     when:
227       event: cron
228
229   notify_on_failure:
230     image: alpine:3
231     commands:
232       - apk add curl
233       - "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
234     when:
235       status: [failure]
236
237   notify_on_tag_deploy:
238     image: alpine:3
239     commands:
240       - apk add curl
241       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
242     when:
243       event: tag
244
245 services:
246   database:
247     image: postgres:15.2-alpine
248     environment:
249       POSTGRES_USER: lemmy
250       POSTGRES_PASSWORD: password
251     # when:
252     #   platform: linux/amd64