2023-04-05 20:29:35 +00:00
|
|
|
# TODO: The when: platform conditionals aren't working currently
|
|
|
|
# See https://github.com/woodpecker-ci/woodpecker/issues/1677
|
|
|
|
|
2023-04-13 20:33:00 +00:00
|
|
|
variables:
|
2024-11-01 13:34:12 +00:00
|
|
|
- &rust_image "rust:1.81"
|
2024-05-16 20:41:36 +00:00
|
|
|
- &rust_nightly_image "rustlang/rust:nightly"
|
2024-01-29 10:38:39 +00:00
|
|
|
- &install_pnpm "corepack enable pnpm"
|
2024-07-31 22:54:44 +00:00
|
|
|
- &install_binstall "wget -O- https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz | tar -xvz -C /usr/local/cargo/bin"
|
|
|
|
- install_diesel_cli: &install_diesel_cli
|
|
|
|
- apt-get update && apt-get install -y postgresql-client
|
|
|
|
- cargo install diesel_cli --no-default-features --features postgres
|
|
|
|
- export PATH="$CARGO_HOME/bin:$PATH"
|
2023-08-02 16:29:21 +00:00
|
|
|
- &slow_check_paths
|
2024-03-27 15:09:44 +00:00
|
|
|
- event: pull_request
|
|
|
|
path:
|
2024-03-26 09:17:42 +00:00
|
|
|
include: [
|
|
|
|
# rust source code
|
|
|
|
"crates/**",
|
|
|
|
"src/**",
|
|
|
|
"**/Cargo.toml",
|
|
|
|
"Cargo.lock",
|
|
|
|
# database migrations
|
|
|
|
"migrations/**",
|
|
|
|
# typescript tests
|
|
|
|
"api_tests/**",
|
|
|
|
# config files and scripts used by ci
|
|
|
|
".woodpecker.yml",
|
|
|
|
".rustfmt.toml",
|
|
|
|
"scripts/update_config_defaults.sh",
|
|
|
|
"diesel.toml",
|
|
|
|
".gitmodules",
|
|
|
|
]
|
2023-04-13 20:33:00 +00:00
|
|
|
|
2023-08-10 12:15:30 +00:00
|
|
|
steps:
|
2023-04-24 19:40:36 +00:00
|
|
|
prepare_repo:
|
|
|
|
image: alpine:3
|
|
|
|
commands:
|
|
|
|
- apk add git
|
|
|
|
- git submodule init
|
2023-06-08 11:12:40 +00:00
|
|
|
- git submodule update
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
2024-04-04 14:14:59 +00:00
|
|
|
- event: [pull_request, tag]
|
2023-04-24 19:40:36 +00:00
|
|
|
|
2023-05-13 20:50:58 +00:00
|
|
|
prettier_check:
|
2024-10-06 08:02:18 +00:00
|
|
|
image: tmknom/prettier:3.2.5
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
2024-01-29 10:38:39 +00:00
|
|
|
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations' '!api_tests/pnpm-lock.yaml'
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-05-13 20:50:58 +00:00
|
|
|
|
2023-07-19 14:25:46 +00:00
|
|
|
toml_fmt:
|
2024-10-06 05:17:46 +00:00
|
|
|
image: tamasfe/taplo:0.9.3
|
2023-07-14 08:45:18 +00:00
|
|
|
commands:
|
|
|
|
- taplo format --check
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-07-14 08:45:18 +00:00
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
sql_fmt:
|
2024-04-03 21:29:24 +00:00
|
|
|
image: backplane/pgformatter
|
2023-08-08 14:35:03 +00:00
|
|
|
commands:
|
|
|
|
- ./scripts/sql_format_check.sh
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-08-08 14:35:03 +00:00
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
cargo_fmt:
|
2024-05-16 20:41:36 +00:00
|
|
|
image: *rust_nightly_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
# store cargo data in repo folder so that it gets cached between steps
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 20:29:35 +00:00
|
|
|
commands:
|
2024-02-26 10:22:22 +00:00
|
|
|
- rustup component add rustfmt
|
2023-10-11 15:57:05 +00:00
|
|
|
- cargo +nightly fmt -- --check
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2024-10-28 15:41:09 +00:00
|
|
|
cargo_shear:
|
2024-05-16 20:41:36 +00:00
|
|
|
image: *rust_nightly_image
|
2023-10-31 10:11:12 +00:00
|
|
|
commands:
|
2024-07-31 22:54:44 +00:00
|
|
|
- *install_binstall
|
2024-10-28 15:41:09 +00:00
|
|
|
- cargo binstall -y cargo-shear
|
|
|
|
- cargo shear
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-10-31 10:11:12 +00:00
|
|
|
|
2023-12-12 13:54:06 +00: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
|
2024-03-27 15:09:44 +00:00
|
|
|
when:
|
|
|
|
- event: pull_request
|
2023-12-12 13:54:06 +00:00
|
|
|
|
2023-06-21 11:57:01 +00:00
|
|
|
# make sure api builds with default features (used by other crates relying on lemmy api)
|
2023-07-19 14:25:46 +00:00
|
|
|
check_api_common_default_features:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-06-21 11:57:01 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-06-21 11:57:01 +00:00
|
|
|
commands:
|
|
|
|
- cargo check --package lemmy_api_common
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-06-21 11:57:01 +00:00
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
lemmy_api_common_doesnt_depend_on_diesel:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 20:29:35 +00:00
|
|
|
commands:
|
|
|
|
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-07-19 14:25:46 +00:00
|
|
|
|
2023-07-14 08:45:18 +00:00
|
|
|
lemmy_api_common_works_with_wasm:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-07-14 08:45:18 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-07-14 08:45:18 +00:00
|
|
|
commands:
|
|
|
|
- "rustup target add wasm32-unknown-unknown"
|
|
|
|
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
check_defaults_hjson_updated:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 20:29:35 +00:00
|
|
|
commands:
|
|
|
|
- ./scripts/update_config_defaults.sh config/defaults_current.hjson
|
|
|
|
- diff config/defaults.hjson config/defaults_current.hjson
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-04-17 19:19:51 +00:00
|
|
|
check_diesel_schema:
|
2024-05-16 20:41:36 +00:00
|
|
|
image: *rust_image
|
2023-04-17 19:19:51 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-17 19:19:51 +00:00
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
commands:
|
2024-05-16 20:41:36 +00:00
|
|
|
- <<: *install_diesel_cli
|
2024-11-07 10:49:05 +00:00
|
|
|
- cp crates/db_schema/src/schema.rs tmp.schema
|
2023-04-17 19:19:51 +00:00
|
|
|
- diesel migration run
|
|
|
|
- diff tmp.schema crates/db_schema/src/schema.rs
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-17 19:19:51 +00:00
|
|
|
|
2024-11-14 08:50:32 +00:00
|
|
|
docker_check:
|
|
|
|
image: docker/dockerfile:1.11
|
|
|
|
commands:
|
|
|
|
- docker build --check . -f docker/Dockerfile
|
|
|
|
|
2023-07-21 09:46:10 +00:00
|
|
|
cargo_clippy:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-07-21 09:46:10 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-07-21 09:46:10 +00:00
|
|
|
commands:
|
|
|
|
- rustup component add clippy
|
2024-09-10 17:36:03 +00:00
|
|
|
- cargo clippy --workspace --tests --all-targets -- -D warnings
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-07-21 09:46:10 +00:00
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
cargo_build:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2023-04-05 20:29:35 +00:00
|
|
|
commands:
|
2023-08-08 14:35:03 +00:00
|
|
|
- cargo build
|
2023-10-11 15:57:05 +00:00
|
|
|
- mv target/debug/lemmy_server target/lemmy_server
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-08-08 14:35:03 +00:00
|
|
|
cargo_test:
|
2023-10-11 15:57:05 +00:00
|
|
|
image: *rust_image
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
2023-08-08 14:35:03 +00:00
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
RUST_BACKTRACE: "1"
|
2023-11-24 16:26:21 +00:00
|
|
|
CARGO_HOME: .cargo_home
|
2024-07-21 15:50:50 +00:00
|
|
|
LEMMY_TEST_FAST_FEDERATION: "1"
|
2024-11-06 15:58:40 +00:00
|
|
|
LEMMY_CONFIG_LOCATION: ../../config/config.hjson
|
2023-04-05 20:29:35 +00:00
|
|
|
commands:
|
2023-08-08 14:35:03 +00:00
|
|
|
- cargo test --workspace --no-fail-fast
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2024-11-06 14:50:13 +00:00
|
|
|
check_ts_bindings:
|
|
|
|
image: *rust_image
|
|
|
|
environment:
|
|
|
|
CARGO_HOME: .cargo_home
|
|
|
|
commands:
|
|
|
|
- ./scripts/ts_bindings_check.sh
|
|
|
|
when:
|
|
|
|
- event: pull_request
|
|
|
|
|
2024-04-18 00:58:44 +00:00
|
|
|
check_diesel_migration:
|
|
|
|
# TODO: use willsquire/diesel-cli image when shared libraries become optional in lemmy_server
|
|
|
|
image: *rust_image
|
|
|
|
environment:
|
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
RUST_BACKTRACE: "1"
|
|
|
|
CARGO_HOME: .cargo_home
|
|
|
|
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
PGUSER: lemmy
|
|
|
|
PGPASSWORD: password
|
|
|
|
PGHOST: database
|
|
|
|
PGDATABASE: lemmy
|
|
|
|
commands:
|
2024-05-16 20:41:36 +00:00
|
|
|
# Install diesel_cli
|
|
|
|
- <<: *install_diesel_cli
|
2024-04-18 00:58:44 +00:00
|
|
|
# Run all migrations
|
|
|
|
- diesel migration run
|
|
|
|
- psql -c "DROP SCHEMA IF EXISTS r CASCADE;"
|
|
|
|
- pg_dump --no-owner --no-privileges --no-table-access-method --schema-only --no-sync -f before.sqldump
|
|
|
|
# Make sure that the newest migration is revertable without the `r` schema
|
|
|
|
- diesel migration redo
|
|
|
|
# Run schema setup twice, which fails on the 2nd time if `DROP SCHEMA IF EXISTS r CASCADE` drops the wrong things
|
|
|
|
- alias lemmy_schema_setup="target/lemmy_server --disable-scheduled-tasks --disable-http-server --disable-activity-sending"
|
|
|
|
- lemmy_schema_setup
|
|
|
|
- lemmy_schema_setup
|
|
|
|
# Make sure that the newest migration is revertable with the `r` schema
|
|
|
|
- diesel migration redo
|
|
|
|
# Check for changes in the schema, which would be caused by an incorrect migration
|
|
|
|
- psql -c "DROP SCHEMA IF EXISTS r CASCADE;"
|
|
|
|
- pg_dump --no-owner --no-privileges --no-table-access-method --schema-only --no-sync -f after.sqldump
|
|
|
|
- diff before.sqldump after.sqldump
|
|
|
|
when: *slow_check_paths
|
|
|
|
|
2024-11-13 15:05:16 +00:00
|
|
|
check_db_perf_tool:
|
|
|
|
image: *rust_image
|
|
|
|
environment:
|
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
|
|
RUST_BACKTRACE: "1"
|
|
|
|
CARGO_HOME: .cargo_home
|
|
|
|
commands:
|
|
|
|
# same as scripts/db_perf.sh but without creating a new database server
|
|
|
|
- cargo run --package lemmy_db_perf -- --posts 10 --read-post-pages 1
|
|
|
|
when: *slow_check_paths
|
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
run_federation_tests:
|
2024-11-01 13:57:33 +00:00
|
|
|
image: node:22-bookworm-slim
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
|
|
|
|
DO_WRITE_HOSTS_FILE: "1"
|
|
|
|
commands:
|
2024-01-29 10:38:39 +00:00
|
|
|
- *install_pnpm
|
2024-07-31 22:54:44 +00:00
|
|
|
- apt-get update && apt-get install -y bash curl postgresql-client
|
2023-04-05 20:29:35 +00:00
|
|
|
- bash api_tests/prepare-drone-federation-test.sh
|
|
|
|
- cd api_tests/
|
2024-01-29 10:38:39 +00:00
|
|
|
- pnpm i
|
|
|
|
- pnpm api-test
|
2023-08-02 16:29:21 +00:00
|
|
|
when: *slow_check_paths
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2024-01-26 09:38:15 +00:00
|
|
|
federation_tests_server_output:
|
|
|
|
image: alpine:3
|
|
|
|
commands:
|
|
|
|
# `|| true` prevents this step from appearing to fail if the server output files don't exist
|
|
|
|
- cat target/log/lemmy_*.out || true
|
|
|
|
- "# If you can't see all output, then use the download button"
|
|
|
|
when:
|
2024-03-27 15:09:44 +00:00
|
|
|
- event: pull_request
|
|
|
|
status: failure
|
2024-01-26 09:38:15 +00:00
|
|
|
|
2023-06-20 14:29:24 +00:00
|
|
|
publish_release_docker:
|
2023-04-05 20:29:35 +00:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
|
|
settings:
|
2023-04-16 16:56:12 +00:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 20:21:31 +00:00
|
|
|
dockerfile: docker/Dockerfile
|
2024-09-10 21:42:20 +00:00
|
|
|
username:
|
|
|
|
from_secret: docker_username
|
|
|
|
password:
|
|
|
|
from_secret: docker_password
|
2023-11-24 17:52:19 +00:00
|
|
|
platforms: linux/amd64, linux/arm64
|
2023-06-21 00:29:48 +00:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-10-04 22:34:56 +00:00
|
|
|
tag: ${CI_COMMIT_TAG}
|
2023-04-05 20:29:35 +00:00
|
|
|
when:
|
2024-03-26 09:17:42 +00:00
|
|
|
- event: tag
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-06-20 14:29:24 +00:00
|
|
|
nightly_build:
|
2023-04-05 20:29:35 +00:00
|
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
|
|
settings:
|
2023-04-16 16:56:12 +00:00
|
|
|
repo: dessalines/lemmy
|
2023-04-18 20:21:31 +00:00
|
|
|
dockerfile: docker/Dockerfile
|
2024-09-10 21:42:20 +00:00
|
|
|
username:
|
|
|
|
from_secret: docker_username
|
|
|
|
password:
|
|
|
|
from_secret: docker_password
|
2023-08-31 13:02:59 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2023-06-21 00:29:48 +00:00
|
|
|
build_args:
|
|
|
|
- RUST_RELEASE_MODE=release
|
2023-06-20 14:29:24 +00:00
|
|
|
tag: dev
|
2023-04-05 20:29:35 +00:00
|
|
|
when:
|
2024-03-26 09:17:42 +00:00
|
|
|
- event: cron
|
2023-04-05 20:29:35 +00:00
|
|
|
|
2023-12-20 13:18:54 +00:00
|
|
|
# using https://github.com/pksunkara/cargo-workspaces
|
|
|
|
publish_to_crates_io:
|
|
|
|
image: *rust_image
|
|
|
|
commands:
|
2024-07-31 22:54:44 +00:00
|
|
|
- *install_binstall
|
2024-05-16 20:41:36 +00:00
|
|
|
# Install cargo-workspaces
|
|
|
|
- cargo binstall -y cargo-workspaces
|
2023-12-20 13:18:54 +00:00
|
|
|
- cp -r migrations crates/db_schema/
|
2024-04-30 00:07:03 +00:00
|
|
|
- cargo workspaces publish --token "$CARGO_API_TOKEN" --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}"
|
2023-12-20 13:18:54 +00:00
|
|
|
secrets: [cargo_api_token]
|
|
|
|
when:
|
2024-03-26 09:17:42 +00:00
|
|
|
- event: tag
|
2023-12-20 13:18:54 +00:00
|
|
|
|
2023-04-05 20:29:35 +00:00
|
|
|
notify_on_failure:
|
|
|
|
image: alpine:3
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
2023-04-05 20:29:35 +00:00
|
|
|
- apk add curl
|
2023-08-09 09:14:09 +00:00
|
|
|
- "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci"
|
2023-04-05 20:29:35 +00:00
|
|
|
when:
|
2024-04-04 08:21:31 +00:00
|
|
|
- event: [pull_request, tag]
|
2024-03-27 15:09:44 +00:00
|
|
|
status: failure
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
notify_on_tag_deploy:
|
|
|
|
image: alpine:3
|
2023-05-13 20:50:58 +00:00
|
|
|
commands:
|
2023-04-05 20:29:35 +00:00
|
|
|
- apk add curl
|
|
|
|
- "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci"
|
|
|
|
when:
|
2024-03-26 09:17:42 +00:00
|
|
|
- event: tag
|
2023-04-05 20:29:35 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
database:
|
2024-07-31 22:54:44 +00:00
|
|
|
# 15-alpine image necessary because of diesel tests
|
|
|
|
image: pgautoupgrade/pgautoupgrade:15-alpine
|
2023-04-05 20:29:35 +00:00
|
|
|
environment:
|
|
|
|
POSTGRES_USER: lemmy
|
|
|
|
POSTGRES_PASSWORD: password
|