]> Untitled Git - lemmy.git/blob - .woodpecker.yml
adeeffd87f2a507cc1f7e95ab11974d37c668413
[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       dockerfile: docker/Dockerfile
139       build_args: RUST_RELEASE_MODE=release
140       username:
141         from_secret: docker_username
142       password:
143         from_secret: docker_password
144       repo: dessalines/lemmy
145       # 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
146       tag: dev
147     when:
148       event:
149         - cron
150           #platform: linux/amd64
151
152   publish_release_docker_image_amd:
153     image: woodpeckerci/plugin-docker-buildx
154     settings:
155       dockerfile: docker/Dockerfile
156       build_args: RUST_RELEASE_MODE=release
157       username:
158         from_secret: docker_username
159       password:
160         from_secret: docker_password
161       repo: dessalines/lemmy
162       # 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
163       auto_tag: true
164       # auto_tag_suffix: linux-amd64
165     when:
166       event: tag
167         #platform: linux/amd64
168
169   publish_release_docker_image_arm:
170     image: woodpeckerci/plugin-docker-buildx
171     settings:
172       dockerfile: docker/Dockerfile
173       build_args: RUST_RELEASE_MODE=release
174       username:
175         from_secret: docker_username
176       password:
177         from_secret: docker_password
178       repo: dessalines/lemmy
179       # 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
180       auto_tag: true
181       # auto_tag_suffix: linux-arm64
182     when:
183       event: tag
184         #platform: linux/arm64
185
186   #publish_release_docker_manifest:
187   #  image: plugins/manifest
188   #  settings:
189   #    username:
190   #      from_secret: docker_username
191   #    password:
192   #      from_secret: docker_password
193   #    target: "dessalines/lemmy:${CI_COMMIT_TAG}"
194   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
195   #    platforms:
196   #      - linux/amd64
197   #      - linux/arm64
198   #    ignore_missing: true
199   #  when:
200   #    event: tag
201
202   #publish_latest_release_docker_manifest:
203   #  image: plugins/manifest
204   #  settings:
205   #    username:
206   #      from_secret: docker_username
207   #    password:
208   #      from_secret: docker_password
209   #    target: "dessalines/lemmy:latest"
210   #    template: "dessalines/lemmy:${CI_COMMIT_TAG}-OS-ARCH"
211   #    platforms:
212   #      - linux/amd64
213   #      - linux/arm64
214   #    ignore_missing: true
215   #  when:
216   #    event: tag
217   #      #platform: linux/amd64
218
219   # using https://github.com/pksunkara/cargo-workspaces
220   publish_to_crates_io:
221     image: *muslrust_image
222     commands:
223       - cargo install cargo-workspaces
224       - cp -r migrations crates/db_schema/
225       - cargo login "$CARGO_API_TOKEN"
226       - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
227     secrets: [cargo_api_token]
228     when:
229       event: tag
230         #platform: linux/amd64
231
232   notify_on_failure:
233     image: alpine:3
234     commands: 
235       - apk add curl
236       - "curl -d'Drone build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
237     when:
238       status: [ failure ]
239
240   notify_on_tag_deploy:
241     image: alpine:3
242     commands: 
243       - apk add curl
244       - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
245     when:
246       event: tag
247
248 services:
249   database:
250     image: postgres:15-alpine
251     environment:
252       POSTGRES_USER: lemmy
253       POSTGRES_PASSWORD: password
254     # when:
255     #   platform: linux/amd64