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