]> Untitled Git - lemmy.git/blob - .woodpecker.yml
Fix wrong SMTP port when TLS is being used (fixes #3574) (#3607)
[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:3.0.0
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-2023-07-10
40       - rustup component add rustfmt --toolchain nightly-2023-07-10
41       - cargo +nightly-2023-07-10 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         -D clippy::explicit_into_iter_loop
64         -D clippy::explicit_iter_loop
65         -D clippy::needless_collect
66       - cargo clippy --workspace --features console --
67         -D clippy::unwrap_used
68         -D clippy::indexing_slicing
69     # when:
70     #   platform: linux/amd64
71
72   # make sure api builds with default features (used by other crates relying on lemmy api)
73   cargo_check:
74     image: *muslrust_image
75     environment:
76       CARGO_HOME: .cargo
77     commands:
78       - cargo check --package lemmy_api_common
79     # when:
80     #   platform: linux/amd64
81
82   lemmy_api_common_doesnt_depend_on_diesel:
83     image: *muslrust_image
84     environment:
85       CARGO_HOME: .cargo
86     commands:
87       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
88     # when:
89     #   platform: linux/amd64
90
91   check_defaults_hjson_updated:
92     image: *muslrust_image
93     environment:
94       CARGO_HOME: .cargo
95     commands:
96       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
97       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
98       - diff config/defaults.hjson config/defaults_current.hjson
99     # when:
100     #   platform: linux/amd64
101
102   check_diesel_schema:
103     image: willsquire/diesel-cli
104     environment:
105       CARGO_HOME: .cargo
106       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
107     commands:
108       - diesel migration run
109       - diesel print-schema --config-file=diesel.toml > tmp.schema
110       - diff tmp.schema crates/db_schema/src/schema.rs
111
112   cargo_test:
113     image: *muslrust_image
114     environment:
115       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
116       RUST_BACKTRACE: "1"
117       RUST_TEST_THREADS: "1"
118       CARGO_HOME: .cargo
119     commands:
120       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
121       - cargo test --workspace --no-fail-fast
122     # when:
123     #   platform: linux/amd64
124
125   cargo_build:
126     image: *muslrust_image
127     environment:
128       CARGO_HOME: .cargo
129     commands:
130       - cargo build
131       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
132     # when:
133     #   platform: linux/amd64
134
135   run_federation_tests:
136     image: node:alpine
137     environment:
138       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
139       DO_WRITE_HOSTS_FILE: "1"
140     commands:
141       - apk add bash curl postgresql-client
142       - bash api_tests/prepare-drone-federation-test.sh
143       - cd api_tests/
144       - yarn
145       - yarn api-test
146     # when:
147     #   platform: linux/amd64
148
149   publish_release_docker:
150     image: woodpeckerci/plugin-docker-buildx
151     secrets: [docker_username, docker_password]
152     settings:
153       repo: dessalines/lemmy
154       dockerfile: docker/Dockerfile
155       platforms: linux/amd64
156       build_args:
157         - RUST_RELEASE_MODE=release
158       auto_tag: true
159     when:
160       event: tag
161
162   nightly_build:
163     image: woodpeckerci/plugin-docker-buildx
164     secrets: [docker_username, docker_password]
165     settings:
166       repo: dessalines/lemmy
167       dockerfile: docker/Dockerfile
168       platforms: linux/amd64
169       build_args:
170         - RUST_RELEASE_MODE=release
171       tag: dev
172     when:
173       event: cron
174
175   # using https://github.com/pksunkara/cargo-workspaces
176   publish_to_crates_io:
177     image: *muslrust_image
178     commands:
179       - 'echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"'
180       - cargo install cargo-workspaces
181       - cp -r migrations crates/db_schema/
182       - cargo login "$CARGO_API_TOKEN"
183       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
184     secrets: [cargo_api_token]
185     when:
186       event: tag
187       #platform: linux/amd64
188
189   notify_on_failure:
190     image: alpine:3
191     commands:
192       - apk add curl
193       - "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
194     when:
195       status: [failure]
196
197   notify_on_tag_deploy:
198     image: alpine:3
199     commands:
200       - apk add curl
201       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
202     when:
203       event: tag
204
205 services:
206   database:
207     image: postgres:15.2-alpine
208     environment:
209       POSTGRES_USER: lemmy
210       POSTGRES_PASSWORD: password
211     # when:
212     #   platform: linux/amd64