2023-04-05 16:29:35 -04:00
|
|
|
# TODO: The when: platform conditionals aren't working currently
|
|
|
|
# See https://github.com/woodpecker-ci/woodpecker/issues/1677
|
|
|
|
|
2023-04-13 16:33:00 -04:00
|
|
|
variables:
|
2024-01-09 11:48:29 -05:00
|
|
|
- &rust_image "rust:1.75"
|
2023-08-02 12:29:21 -04:00
|
|
|
- &slow_check_paths
|
|
|
|
- path:
|
|
|
|
# rust source code
|
2023-12-14 07:25:47 -05:00
|
|
|
- "crates/**"
|
|
|
|
- "src/**"
|
2023-08-02 12:29:21 -04:00
|
|
|
- "**/Cargo.toml"
|
|
|
|
- "Cargo.lock"
|
|
|
|
# database migrations
|
2023-08-28 06:23:45 -04:00
|
|
|
- "migrations/**"
|
2023-08-02 12:29:21 -04:00
|
|
|
# typescript tests
|
2023-08-28 06:23:45 -04:00
|
|
|
- "api_tests/**"
|
2023-08-02 12:29:21 -04:00
|
|
|
# config files and scripts used by ci
|
|
|
|
- ".woodpecker.yml"
|
|
|
|
- ".rustfmt.toml"
|
|
|
|
- "scripts/update_config_defaults.sh"
|
|
|
|
- "diesel.toml"
|
|
|
|
- ".gitmodules"
|
2023-04-13 16:33:00 -04:00
|
|
|
|
2023-04-24 15:40:36 -04:00
|
|
|
# Broken for cron jobs currently, see
|
|
|
|
# https://github.com/woodpecker-ci/woodpecker/issues/1716
|
|
|
|
# clone:
|
|
|
|
# git:
|
|
|
|
# image: woodpeckerci/plugin-git
|
|
|
|
# settings:
|
|
|
|
# recursive: true
|
|
|
|
# submodule_update_remote: true
|
2023-04-13 16:33:00 -04:00
|
|
|
|
2023-08-10 08:15:30 -04:00
|
|
|
steps:
|
2023-04-24 15:40:36 -04:00
|
|
|
prepare_repo:
|
|
|
|
image: alpine:3
|
|
|
|
commands:
|
|
|
|
- apk add git
|
|
|
|
- git submodule init
|
2023-06-08 07:12:40 -04:00
|
|
|
- git submodule update
|
2023-04-24 15:40:36 -04:00
|
|
|
|
2023-05-13 16:50:58 -04:00
|
|
|
prettier_check:
|
2023-07-06 09:10:38 -04:00
|
|
|
image: tmknom/prettier:3.0.0
|
2023-05-13 16:50:58 -04:00
|
|
|
commands:
|
|
|
|
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'
|
|
|
|
|
2023-07-19 10:25:46 -04:00
|
|
|
toml_fmt:
|
2023-07-14 04:45:18 -04:00
|
|
|
image: tamasfe/taplo:0.8.1
|
|
|
|
commands:
|
|
|
|
- taplo format --check
|
|
|
|
|
2023-08-08 10:35:03 -04:00
|
|
|
sql_fmt:
|
|
|
|
image: backplane/pgformatter:latest
|
|
|
|
commands:
|
|
|
|
- ./scripts/sql_format_check.sh
|
|
|
|
|
2023-04-05 16:29:35 -04:00
|
|
|
cargo_fmt:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: rustlang/rust:nightly
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
|
|
|
# store cargo data in repo folder so that it gets cached between steps
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 16:29:35 -04:00
|
|
|
commands:
|
|
|
|
# need make existing toolchain available
|
2023-10-11 11:57:05 -04:00
|
|
|
- cargo +nightly fmt -- --check
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-10-31 06:11:12 -04:00
|
|
|
cargo_machete:
|
|
|
|
image: rustlang/rust:nightly
|
|
|
|
commands:
|
|
|
|
- wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
|
|
|
|
- tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
|
|
|
|
- cp cargo-binstall /usr/local/cargo/bin
|
|
|
|
- cargo binstall -y cargo-machete
|
|
|
|
- cargo machete
|
|
|
|
|
2023-12-12 08:54:06 -05:00
|
|
|
ignored_files:
|
|
|
|
image: alpine:3
|
|
|
|
commands:
|
|
|
|
- apk add git
|
|
|
|
- IGNORED=$(git ls-files --cached -i --exclude-standard)
|
|
|
|
- if [[ "$IGNORED" ]]; then echo "Ignored files present:\n$IGNORED\n"; exit 1; fi
|
|
|
|
|
2023-06-21 07:57:01 -04:00
|
|
|
# make sure api builds with default features (used by other crates relying on lemmy api)
|
2023-07-19 10:25:46 -04:00
|
|
|
check_api_common_default_features:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-06-21 07:57:01 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-06-21 07:57:01 -04:00
|
|
|
commands:
|
|
|
|
- cargo check --package lemmy_api_common
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-06-21 07:57:01 -04:00
|
|
|
|
2023-04-05 16:29:35 -04:00
|
|
|
lemmy_api_common_doesnt_depend_on_diesel:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 16:29:35 -04:00
|
|
|
commands:
|
|
|
|
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-07-19 10:25:46 -04:00
|
|
|
|
2023-07-14 04:45:18 -04:00
|
|
|
lemmy_api_common_works_with_wasm:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-07-14 04:45:18 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-07-14 04:45:18 -04:00
|
|
|
commands:
|
|
|
|
- "rustup target add wasm32-unknown-unknown"
|
|
|
|
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-05 16:29:35 -04:00
|
|
|
|
|
|
|
check_defaults_hjson_updated:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 16:29:35 -04:00
|
|
|
commands:
|
|
|
|
- export LEMMY_CONFIG_LOCATION=./config/config.hjson
|
|
|
|
- ./scripts/update_config_defaults.sh config/defaults_current.hjson
|
|
|
|
- diff config/defaults.hjson config/defaults_current.hjson
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-04-17 15:19:51 -04:00
|
|
|
check_diesel_schema:
|
2023-06-07 06:54:40 -04:00
|
|
|
image: willsquire/diesel-cli
|
2023-04-17 15:19:51 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-17 15:19:51 -04:00
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
commands:
|
|
|
|
- diesel migration run
|
|
|
|
- diesel print-schema --config-file=diesel.toml > tmp.schema
|
|
|
|
- diff tmp.schema crates/db_schema/src/schema.rs
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-17 15:19:51 -04:00
|
|
|
|
2023-07-21 05:46:10 -04:00
|
|
|
check_diesel_migration_revertable:
|
|
|
|
image: willsquire/diesel-cli
|
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-07-21 05:46:10 -04:00
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
commands:
|
|
|
|
- diesel migration run
|
|
|
|
- diesel migration redo
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-07-21 05:46:10 -04:00
|
|
|
|
|
|
|
cargo_clippy:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-07-21 05:46:10 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-07-21 05:46:10 -04:00
|
|
|
commands:
|
2023-08-02 12:44:51 -04:00
|
|
|
# when adding new clippy lints, make sure to also add them in scripts/lint.sh
|
2023-07-21 05:46:10 -04:00
|
|
|
- rustup component add clippy
|
2023-11-21 08:51:22 -05:00
|
|
|
- cargo clippy --workspace --tests --all-targets --features console -- -D warnings
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-07-21 05:46:10 -04:00
|
|
|
|
2023-08-08 10:35:03 -04:00
|
|
|
cargo_build:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 16:29:35 -04:00
|
|
|
commands:
|
2023-08-08 10:35:03 -04:00
|
|
|
- cargo build
|
2023-10-11 11:57:05 -04:00
|
|
|
- mv target/debug/lemmy_server target/lemmy_server
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-08-08 10:35:03 -04:00
|
|
|
cargo_test:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: *rust_image
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
2023-08-08 10:35:03 -04:00
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
RUST_BACKTRACE: "1"
|
2023-11-24 11:26:21 -05:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 16:29:35 -04:00
|
|
|
commands:
|
2023-08-08 10:35:03 -04:00
|
|
|
- export LEMMY_CONFIG_LOCATION=../../config/config.hjson
|
|
|
|
- cargo test --workspace --no-fail-fast
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-05 16:29:35 -04:00
|
|
|
|
|
|
|
run_federation_tests:
|
2023-10-11 11:57:05 -04:00
|
|
|
image: node:20-bookworm-slim
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
|
|
|
|
DO_WRITE_HOSTS_FILE: "1"
|
|
|
|
commands:
|
2023-10-11 11:57:05 -04:00
|
|
|
- apt update && apt install -y bash curl postgresql-client
|
2023-04-05 16:29:35 -04:00
|
|
|
- bash api_tests/prepare-drone-federation-test.sh
|
|
|
|
- cd api_tests/
|
|
|
|
- yarn
|
|
|
|
- yarn api-test
|
2023-08-02 12:29:21 -04:00
|
|
|
when: *slow_check_paths
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-06-20 10:29:24 -04:00
|
|
|
publish_release_docker:
|
2023-04-05 16:29:35 -04:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
2023-06-20 10:29:24 -04:00
|
|
|
secrets: [docker_username, docker_password]
|
2023-04-05 16:29:35 -04:00
|
|
|
settings:
|
2023-04-16 12:56:12 -04:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 16:21:31 -04:00
|
|
|
dockerfile: docker/Dockerfile
|
2023-11-24 12:52:19 -05:00
|
|
|
platforms: linux/amd64, linux/arm64
|
2023-06-20 20:29:48 -04:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-10-04 18:34:56 -04:00
|
|
|
tag: ${CI_COMMIT_TAG}
|
2023-04-05 16:29:35 -04:00
|
|
|
when:
|
2023-06-20 10:29:24 -04:00
|
|
|
event: tag
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-06-20 10:29:24 -04:00
|
|
|
nightly_build:
|
2023-04-05 16:29:35 -04:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
2023-06-20 10:29:24 -04:00
|
|
|
secrets: [docker_username, docker_password]
|
2023-04-05 16:29:35 -04:00
|
|
|
settings:
|
2023-04-16 12:56:12 -04:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 16:21:31 -04:00
|
|
|
dockerfile: docker/Dockerfile
|
2023-08-31 09:02:59 -04:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2023-06-20 20:29:48 -04:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-06-20 10:29:24 -04:00
|
|
|
tag: dev
|
2023-04-05 16:29:35 -04:00
|
|
|
when:
|
2023-06-20 10:29:24 -04:00
|
|
|
event: cron
|
2023-04-05 16:29:35 -04:00
|
|
|
|
2023-12-20 08:18:54 -05:00
|
|
|
# using https://github.com/pksunkara/cargo-workspaces
|
|
|
|
publish_to_crates_io:
|
|
|
|
image: *rust_image
|
|
|
|
commands:
|
|
|
|
- 'echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"'
|
|
|
|
- cargo install cargo-workspaces
|
|
|
|
- cp -r migrations crates/db_schema/
|
|
|
|
- cargo login "$CARGO_API_TOKEN"
|
|
|
|
- cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
|
|
|
|
secrets: [cargo_api_token]
|
|
|
|
when:
|
|
|
|
event: tag
|
|
|
|
|
2023-04-05 16:29:35 -04:00
|
|
|
notify_on_failure:
|
|
|
|
image: alpine:3
|
2023-05-13 16:50:58 -04:00
|
|
|
commands:
|
2023-04-05 16:29:35 -04:00
|
|
|
- apk add curl
|
2023-08-09 05:14:09 -04:00
|
|
|
- "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci"
|
2023-04-05 16:29:35 -04:00
|
|
|
when:
|
2023-05-13 16:50:58 -04:00
|
|
|
status: [failure]
|
2023-04-05 16:29:35 -04:00
|
|
|
|
|
|
|
notify_on_tag_deploy:
|
|
|
|
image: alpine:3
|
2023-05-13 16:50:58 -04:00
|
|
|
commands:
|
2023-04-05 16:29:35 -04:00
|
|
|
- apk add curl
|
|
|
|
- "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
|
|
|
|
when:
|
|
|
|
event: tag
|
|
|
|
|
|
|
|
services:
|
|
|
|
database:
|
2023-05-12 19:08:32 -04:00
|
|
|
image: postgres:15.2-alpine
|
2023-04-05 16:29:35 -04:00
|
|
|
environment:
|
|
|
|
POSTGRES_USER: lemmy
|
|
|
|
POSTGRES_PASSWORD: password
|