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