]> Untitled Git - lemmy.git/blob - .woodpecker.yml
Adjust the config check to be a separate faster to compile binary (#3313)
[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 fetch --tags
22       - git submodule init
23       - git submodule update
24
25   prettier_check:
26     image: tmknom/prettier
27     commands:
28       - prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'
29
30   # use minimum supported rust version for most steps
31   cargo_fmt:
32     image: *muslrust_image
33     environment:
34       # store cargo data in repo folder so that it gets cached between steps
35       CARGO_HOME: .cargo
36     commands:
37       # need make existing toolchain available
38       - cp ~/.cargo . -r
39       - rustup toolchain install nightly
40       - rustup component add rustfmt --toolchain nightly
41       - cargo +nightly fmt -- --check
42     # when:
43     #   platform: linux/amd64
44
45   cargo_clippy:
46     image: *muslrust_image
47     environment:
48       CARGO_HOME: .cargo
49     commands:
50       # latest rust for clippy to get extra checks
51       # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
52       - rustup component add clippy
53       - cargo clippy --workspace --tests --all-targets --features console --
54         -D warnings -D deprecated -D clippy::perf -D clippy::complexity
55         -D clippy::style -D clippy::correctness -D clippy::suspicious
56         -D clippy::dbg_macro -D clippy::inefficient_to_string
57         -D clippy::items-after-statements -D clippy::implicit_clone
58         -D clippy::cast_lossless -D clippy::manual_string_new
59         -D clippy::redundant_closure_for_method_calls
60         -D clippy::unused_self
61         -A clippy::uninlined_format_args
62         -D clippy::get_first
63       - cargo clippy --workspace --features console --
64         -D clippy::unwrap_used
65         -D clippy::indexing_slicing
66     # when:
67     #   platform: linux/amd64
68
69   # make sure api builds with default features (used by other crates relying on lemmy api)
70   cargo_check:
71     image: *muslrust_image
72     environment:
73       CARGO_HOME: .cargo
74     commands:
75       - cargo check --package lemmy_api_common
76     # when:
77     #   platform: linux/amd64
78
79   lemmy_api_common_doesnt_depend_on_diesel:
80     image: *muslrust_image
81     environment:
82       CARGO_HOME: .cargo
83     commands:
84       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
85     # when:
86     #   platform: linux/amd64
87
88   check_defaults_hjson_updated:
89     image: *muslrust_image
90     environment:
91       CARGO_HOME: .cargo
92     commands:
93       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
94       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
95       - diff config/defaults.hjson config/defaults_current.hjson
96     # when:
97     #   platform: linux/amd64
98
99   check_diesel_schema:
100     image: willsquire/diesel-cli
101     environment:
102       CARGO_HOME: .cargo
103       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
104     commands:
105       - diesel migration run
106       - diesel print-schema --config-file=diesel.toml > tmp.schema
107       - diff tmp.schema crates/db_schema/src/schema.rs
108
109   cargo_test:
110     image: *muslrust_image
111     environment:
112       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
113       RUST_BACKTRACE: "1"
114       RUST_TEST_THREADS: "1"
115       CARGO_HOME: .cargo
116     commands:
117       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
118       - cargo test --workspace --no-fail-fast
119     # when:
120     #   platform: linux/amd64
121
122   cargo_build:
123     image: *muslrust_image
124     environment:
125       CARGO_HOME: .cargo
126     commands:
127       - cargo build
128       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
129     # when:
130     #   platform: linux/amd64
131
132   run_federation_tests:
133     image: node:alpine
134     environment:
135       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
136       DO_WRITE_HOSTS_FILE: "1"
137     commands:
138       - apk add bash curl postgresql-client
139       - bash api_tests/prepare-drone-federation-test.sh
140       - cd api_tests/
141       - yarn
142       - yarn api-test
143     # when:
144     #   platform: linux/amd64
145
146   publish_release_docker:
147     image: woodpeckerci/plugin-docker-buildx
148     secrets: [docker_username, docker_password]
149     settings:
150       repo: dessalines/lemmy
151       dockerfile: docker/Dockerfile
152       platforms: linux/amd64
153       build_args:
154         - RUST_RELEASE_MODE=release
155       auto_tag: true
156     when:
157       event: tag
158
159   nightly_build:
160     image: woodpeckerci/plugin-docker-buildx
161     secrets: [docker_username, docker_password]
162     settings:
163       repo: dessalines/lemmy
164       dockerfile: docker/Dockerfile
165       platforms: linux/amd64
166       build_args:
167         - RUST_RELEASE_MODE=release
168       tag: dev
169     when:
170       event: cron
171
172   # using https://github.com/pksunkara/cargo-workspaces
173   publish_to_crates_io:
174     image: *muslrust_image
175     commands:
176       - 'echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"'
177       - cargo install cargo-workspaces
178       - cp -r migrations crates/db_schema/
179       - cargo login "$CARGO_API_TOKEN"
180       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
181     secrets: [cargo_api_token]
182     when:
183       event: tag
184       #platform: linux/amd64
185
186   notify_on_failure:
187     image: alpine:3
188     commands:
189       - apk add curl
190       - "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
191     when:
192       status: [failure]
193
194   notify_on_tag_deploy:
195     image: alpine:3
196     commands:
197       - apk add curl
198       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
199     when:
200       event: tag
201
202 services:
203   database:
204     image: postgres:15.2-alpine
205     environment:
206       POSTGRES_USER: lemmy
207       POSTGRES_PASSWORD: password
208     # when:
209     #   platform: linux/amd64