]> Untitled Git - lemmy.git/blob - .woodpecker.yml
Fixing empty req issue. (#2849)
[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 --recursive --remote
24
25   # use minimum supported rust version for most steps
26   cargo_fmt:
27     image: *muslrust_image
28     environment:
29       # store cargo data in repo folder so that it gets cached between steps
30       CARGO_HOME: .cargo
31     commands:
32       # need make existing toolchain available
33       - cp ~/.cargo . -r
34       - rustup toolchain install nightly
35       - rustup component add rustfmt --toolchain nightly
36       - cargo +nightly fmt -- --check
37     # when:
38     #   platform: linux/amd64
39
40   # check each package to make sure they compile with default features.
41   # this is required for crates.io
42   cargo_check:
43     image: *muslrust_image
44     environment:
45       CARGO_HOME: .cargo
46     commands:
47       - cargo check --package lemmy_utils
48       - cargo check --package lemmy_db_schema
49       - cargo check --package lemmy_db_views
50       - cargo check --package lemmy_db_views_actor
51       - cargo check --package lemmy_db_views_moderator
52       - cargo check --package lemmy_api_common
53       - cargo check --package lemmy_api
54       - cargo check --package lemmy_api_crud
55       - cargo check --package lemmy_apub
56       - cargo check --package lemmy_routes
57       - cargo check --workspace
58       - cargo check --workspace --features console
59       # disabled because it takes too long with pict-rs
60       #- cargo check --workspace --all-features
61     # when:
62     #   platform: linux/amd64
63
64   cargo_clippy:
65     image: *muslrust_image
66     environment:
67       CARGO_HOME: .cargo
68     commands:
69         # latest rust for clippy to get extra checks
70         # when adding new clippy lints, make sure to also add them in scripts/fix-clippy.sh
71       - rustup component add clippy
72       - cargo clippy --workspace --tests --all-targets --features console --
73           -D warnings -D deprecated -D clippy::perf -D clippy::complexity 
74           -D clippy::style -D clippy::correctness -D clippy::suspicious
75           -D clippy::dbg_macro -D clippy::inefficient_to_string 
76           -D clippy::items-after-statements -D clippy::implicit_clone 
77           -D clippy::wildcard_imports -D clippy::cast_lossless 
78           -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls 
79           -D clippy::unused_self
80           -A clippy::uninlined_format_args
81           -D clippy::get_first
82       - cargo clippy --workspace --features console -- 
83         -D clippy::unwrap_used
84         -D clippy::indexing_slicing
85     # when:
86     #   platform: linux/amd64
87
88   lemmy_api_common_doesnt_depend_on_diesel:
89     image: *muslrust_image
90     environment:
91       CARGO_HOME: .cargo
92     commands:
93       - "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
94     # when:
95     #   platform: linux/amd64
96
97   check_defaults_hjson_updated:
98     image: *muslrust_image
99     environment:
100       CARGO_HOME: .cargo
101     commands:
102       - export LEMMY_CONFIG_LOCATION=./config/config.hjson
103       - ./scripts/update_config_defaults.sh config/defaults_current.hjson
104       - diff config/defaults.hjson config/defaults_current.hjson
105     # when:
106     #   platform: linux/amd64
107
108   check_diesel_schema:
109     image: jameshiew/diesel-cli
110     environment:
111       CARGO_HOME: .cargo
112       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
113     commands:
114       - diesel migration run
115       - diesel print-schema --config-file=diesel.toml > tmp.schema
116       - diff tmp.schema crates/db_schema/src/schema.rs
117
118   cargo_test:
119     image: *muslrust_image
120     environment:
121       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
122       RUST_BACKTRACE: "1"
123       RUST_TEST_THREADS: "1"
124       CARGO_HOME: .cargo
125     commands:
126       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
127       - cargo test --workspace --no-fail-fast
128     # when:
129     #   platform: linux/amd64
130
131   cargo_build:
132     image: *muslrust_image
133     environment:
134       CARGO_HOME: .cargo
135     commands:
136       - cargo build
137       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
138     # when:
139     #   platform: linux/amd64
140
141   run_federation_tests:
142     image: node:alpine
143     environment:
144       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
145       DO_WRITE_HOSTS_FILE: "1"
146     commands:
147       - apk add bash curl postgresql-client
148       - bash api_tests/prepare-drone-federation-test.sh
149       - cd api_tests/
150       - yarn
151       - yarn api-test
152     # when:
153     #   platform: linux/amd64
154
155   nightly_build:
156     image: woodpeckerci/plugin-docker-buildx
157     settings:
158       repo: dessalines/lemmy
159       dockerfile: docker/Dockerfile
160       platforms: linux/amd64
161       build_args: RUST_RELEASE_MODE=release
162       username:
163         from_secret: docker_username
164       password:
165         from_secret: docker_password
166       # add_host: github.com:140.82.112.3,static.crates.io:18.154.227.73,crates.io:108.138.64.68,dl-cdn.alpinelinux.org:146.75.30.133
167       tag: dev
168     when:
169       event:
170         - cron
171           #platform: linux/amd64
172
173   publish_release_docker_image_amd:
174     image: woodpeckerci/plugin-docker-buildx
175     settings:
176       repo: dessalines/lemmy
177       dockerfile: docker/Dockerfile
178       platforms: linux/amd64
179       build_args: RUST_RELEASE_MODE=release
180       username:
181         from_secret: docker_username
182       password:
183         from_secret: docker_password
184       # add_host: github.com:140.82.112.3,static.crates.io:18.154.227.73,crates.io:108.138.64.68,dl-cdn.alpinelinux.org:146.75.30.133
185       auto_tag: true
186       # auto_tag_suffix: linux-amd64
187     when:
188       event: tag
189         #platform: linux/amd64
190
191   publish_release_docker_image_arm:
192     image: woodpeckerci/plugin-docker-buildx
193     settings:
194       repo: dessalines/lemmy
195       dockerfile: docker/Dockerfile
196       platforms: linux/arm64
197       build_args: RUST_RELEASE_MODE=release
198       username:
199         from_secret: docker_username
200       password:
201         from_secret: docker_password
202       # add_host: github.com:140.82.112.3,static.crates.io:18.154.227.73,crates.io:108.138.64.68,dl-cdn.alpinelinux.org:146.75.30.133
203       auto_tag: true
204       # auto_tag_suffix: linux-arm64
205     when:
206       event: tag
207         #platform: linux/arm64
208
209   #publish_release_docker_manifest:
210   #  image: plugins/manifest
211   #  settings:
212   #    username:
213   #      from_secret: docker_username
214   #    password:
215   #      from_secret: docker_password
216   #    target: "dessalines/lemmy:${CI_COMMIT_TAG}"
217   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
218   #    platforms:
219   #      - linux/amd64
220   #      - linux/arm64
221   #    ignore_missing: true
222   #  when:
223   #    event: tag
224
225   #publish_latest_release_docker_manifest:
226   #  image: plugins/manifest
227   #  settings:
228   #    username:
229   #      from_secret: docker_username
230   #    password:
231   #      from_secret: docker_password
232   #    target: "dessalines/lemmy:latest"
233   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
234   #    platforms:
235   #      - linux/amd64
236   #      - linux/arm64
237   #    ignore_missing: true
238   #  when:
239   #    event: tag
240   #      #platform: linux/amd64
241
242   # using https://github.com/pksunkara/cargo-workspaces
243   publish_to_crates_io:
244     image: *muslrust_image
245     commands:
246       - cargo install cargo-workspaces
247       - cp -r migrations crates/db_schema/
248       - cargo login "$CARGO_API_TOKEN"
249       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
250     secrets: [cargo_api_token]
251     when:
252       event: tag
253       #platform: linux/amd64
254
255   notify_on_failure:
256     image: alpine:3
257     commands: 
258       - apk add curl
259       - "curl -d'Drone build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
260     when:
261       status: [ failure ]
262
263   notify_on_tag_deploy:
264     image: alpine:3
265     commands: 
266       - apk add curl
267       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
268     when:
269       event: tag
270
271 services:
272   database:
273     image: postgres:15-alpine
274     environment:
275       POSTGRES_USER: lemmy
276       POSTGRES_PASSWORD: password
277     # when:
278     #   platform: linux/amd64