]> Untitled Git - lemmy.git/blob - .woodpecker.yml
Reduce memory usage of rate limiting (#3111)
[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.67.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   # check each package to make sure they compile with default features.
46   # this is required for crates.io
47   cargo_check:
48     image: *muslrust_image
49     environment:
50       CARGO_HOME: .cargo
51     commands:
52       - cargo check --package lemmy_utils
53       - cargo check --package lemmy_db_schema
54       - cargo check --package lemmy_db_views
55       - cargo check --package lemmy_db_views_actor
56       - cargo check --package lemmy_db_views_moderator
57       - cargo check --package lemmy_api_common
58       - cargo check --package lemmy_api
59       - cargo check --package lemmy_api_crud
60       - cargo check --package lemmy_apub
61       - cargo check --package lemmy_routes
62       - cargo check --workspace
63       - cargo check --workspace --features console
64       # disabled because it takes too long with pict-rs
65       #- cargo check --workspace --all-features
66     # when:
67     #   platform: linux/amd64
68
69   cargo_clippy:
70     image: *muslrust_image
71     environment:
72       CARGO_HOME: .cargo
73     commands:
74       # latest rust for clippy to get extra checks
75       # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
76       - rustup component add clippy
77       - cargo clippy --workspace --tests --all-targets --features console --
78         -D warnings -D deprecated -D clippy::perf -D clippy::complexity
79         -D clippy::style -D clippy::correctness -D clippy::suspicious
80         -D clippy::dbg_macro -D clippy::inefficient_to_string
81         -D clippy::items-after-statements -D clippy::implicit_clone
82         -D clippy::cast_lossless -D clippy::manual_string_new
83         -D clippy::redundant_closure_for_method_calls
84         -D clippy::unused_self
85         -A clippy::uninlined_format_args
86         -D clippy::get_first
87       - cargo clippy --workspace --features console --
88         -D clippy::unwrap_used
89         -D clippy::indexing_slicing
90     # when:
91     #   platform: linux/amd64
92
93   lemmy_api_common_doesnt_depend_on_diesel:
94     image: *muslrust_image
95     environment:
96       CARGO_HOME: .cargo
97     commands:
98       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
99     # when:
100     #   platform: linux/amd64
101
102   check_defaults_hjson_updated:
103     image: *muslrust_image
104     environment:
105       CARGO_HOME: .cargo
106     commands:
107       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
108       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
109       - diff config/defaults.hjson config/defaults_current.hjson
110     # when:
111     #   platform: linux/amd64
112
113   check_diesel_schema:
114     image: willsquire/diesel-cli
115     environment:
116       CARGO_HOME: .cargo
117       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
118     commands:
119       - diesel migration run
120       - diesel print-schema --config-file=diesel.toml > tmp.schema
121       - diff tmp.schema crates/db_schema/src/schema.rs
122
123   cargo_test:
124     image: *muslrust_image
125     environment:
126       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
127       RUST_BACKTRACE: "1"
128       RUST_TEST_THREADS: "1"
129       CARGO_HOME: .cargo
130     commands:
131       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
132       - cargo test --workspace --no-fail-fast
133     # when:
134     #   platform: linux/amd64
135
136   cargo_build:
137     image: *muslrust_image
138     environment:
139       CARGO_HOME: .cargo
140     commands:
141       - cargo build
142       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
143     # when:
144     #   platform: linux/amd64
145
146   run_federation_tests:
147     image: node:alpine
148     environment:
149       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
150       DO_WRITE_HOSTS_FILE: "1"
151     commands:
152       - apk add bash curl postgresql-client
153       - bash api_tests/prepare-drone-federation-test.sh
154       - cd api_tests/
155       - yarn
156       - yarn api-test
157     # when:
158     #   platform: linux/amd64
159
160   publish_release_docker:
161     image: woodpeckerci/plugin-docker-buildx
162     secrets: [docker_username, docker_password]
163     settings:
164       repo: dessalines/lemmy
165       dockerfile: docker/Dockerfile
166       platforms: linux/amd64
167       build_args:
168         - RUST_RELEASE_MODE=release
169       auto_tag: true
170     when:
171       event: tag
172
173   nightly_build:
174     image: woodpeckerci/plugin-docker-buildx
175     secrets: [docker_username, docker_password]
176     settings:
177       repo: dessalines/lemmy
178       dockerfile: docker/Dockerfile
179       platforms: linux/amd64
180       build_args:
181         - RUST_RELEASE_MODE=release
182       tag: dev
183     when:
184       event: cron
185
186   # using https://github.com/pksunkara/cargo-workspaces
187   publish_to_crates_io:
188     image: *muslrust_image
189     commands:
190       - 'echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"'
191       - cargo install cargo-workspaces
192       - cp -r migrations crates/db_schema/
193       - cargo login "$CARGO_API_TOKEN"
194       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
195     secrets: [cargo_api_token]
196     when:
197       event: tag
198       #platform: linux/amd64
199
200   notify_on_failure:
201     image: alpine:3
202     commands:
203       - apk add curl
204       - "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
205     when:
206       status: [failure]
207
208   notify_on_tag_deploy:
209     image: alpine:3
210     commands:
211       - apk add curl
212       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
213     when:
214       event: tag
215
216 services:
217   database:
218     image: postgres:15.2-alpine
219     environment:
220       POSTGRES_USER: lemmy
221       POSTGRES_PASSWORD: password
222     # when:
223     #   platform: linux/amd64