]> Untitled Git - lemmy.git/blob - .woodpecker.yml
740614094c1a96761a8f01f7adc98ec4905cd9d0
[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   check_diesel_schema:
99     image: jameshiew/diesel-cli
100     environment:
101       CARGO_HOME: .cargo
102       DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
103     commands:
104       - diesel migration run
105       - diesel print-schema --config-file=diesel.toml > tmp.schema
106       - diff tmp.schema crates/db_schema/src/schema.rs
107
108   cargo_test:
109     image: *muslrust_image
110     environment:
111       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
112       RUST_BACKTRACE: "1"
113       RUST_TEST_THREADS: "1"
114       CARGO_HOME: .cargo
115     commands:
116       - export LEMMY_CONFIG_LOCATION=../../config/config.hjson
117       - cargo test --workspace --no-fail-fast
118     # when:
119     #   platform: linux/amd64
120
121   cargo_build:
122     image: *muslrust_image
123     environment:
124       CARGO_HOME: .cargo
125     commands:
126       - cargo build
127       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
128     # when:
129     #   platform: linux/amd64
130
131   run_federation_tests:
132     image: node:alpine
133     environment:
134       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
135       DO_WRITE_HOSTS_FILE: "1"
136     commands:
137       - apk add bash curl postgresql-client
138       - bash api_tests/prepare-drone-federation-test.sh
139       - cd api_tests/
140       - yarn
141       - yarn api-test
142     # when:
143     #   platform: linux/amd64
144
145   nightly_build:
146     image: woodpeckerci/plugin-docker-buildx
147     settings:
148       repo: dessalines/lemmy
149       dockerfile: docker/Dockerfile.multiarch
150       platforms: linux/amd64
151       build_args: RUST_RELEASE_MODE=release
152       username:
153         from_secret: docker_username
154       password:
155         from_secret: docker_password
156       # 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
157       tag: dev
158     when:
159       event:
160         - cron
161           #platform: linux/amd64
162
163   publish_release_docker_image_amd:
164     image: woodpeckerci/plugin-docker-buildx
165     settings:
166       repo: dessalines/lemmy
167       dockerfile: docker/Dockerfile.multiarch
168       platforms: linux/amd64
169       build_args: RUST_RELEASE_MODE=release
170       username:
171         from_secret: docker_username
172       password:
173         from_secret: docker_password
174       # 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
175       auto_tag: true
176       # auto_tag_suffix: linux-amd64
177     when:
178       event: tag
179         #platform: linux/amd64
180
181   publish_release_docker_image_arm:
182     image: woodpeckerci/plugin-docker-buildx
183     settings:
184       repo: dessalines/lemmy
185       dockerfile: docker/Dockerfile.multiarch
186       platforms: linux/arm64
187       build_args: RUST_RELEASE_MODE=release
188       username:
189         from_secret: docker_username
190       password:
191         from_secret: docker_password
192       # 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
193       auto_tag: true
194       # auto_tag_suffix: linux-arm64
195     when:
196       event: tag
197         #platform: linux/arm64
198
199   #publish_release_docker_manifest:
200   #  image: plugins/manifest
201   #  settings:
202   #    username:
203   #      from_secret: docker_username
204   #    password:
205   #      from_secret: docker_password
206   #    target: "dessalines/lemmy:${CI_COMMIT_TAG}"
207   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
208   #    platforms:
209   #      - linux/amd64
210   #      - linux/arm64
211   #    ignore_missing: true
212   #  when:
213   #    event: tag
214
215   #publish_latest_release_docker_manifest:
216   #  image: plugins/manifest
217   #  settings:
218   #    username:
219   #      from_secret: docker_username
220   #    password:
221   #      from_secret: docker_password
222   #    target: "dessalines/lemmy:latest"
223   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
224   #    platforms:
225   #      - linux/amd64
226   #      - linux/arm64
227   #    ignore_missing: true
228   #  when:
229   #    event: tag
230   #      #platform: linux/amd64
231
232   # using https://github.com/pksunkara/cargo-workspaces
233   publish_to_crates_io:
234     image: *muslrust_image
235     commands:
236       - cargo install cargo-workspaces
237       - cp -r migrations crates/db_schema/
238       - cargo login "$CARGO_API_TOKEN"
239       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
240     secrets: [cargo_api_token]
241     when:
242       event: tag
243       #platform: linux/amd64
244
245   notify_on_failure:
246     image: alpine:3
247     commands: 
248       - apk add curl
249       - "curl -d'Drone build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
250     when:
251       status: [ failure ]
252
253   notify_on_tag_deploy:
254     image: alpine:3
255     commands: 
256       - apk add curl
257       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
258     when:
259       event: tag
260
261 services:
262   database:
263     image: postgres:15-alpine
264     environment:
265       POSTGRES_USER: lemmy
266       POSTGRES_PASSWORD: password
267     # when:
268     #   platform: linux/amd64