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