diff --git a/.woodpecker.yml b/.woodpecker.yml index 65dc8a8a..f8f4eb5f 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -3,6 +3,7 @@ variables: - &rust_image "rust:1.77" + - &rust_nightly_image "rustlang/rust:nightly" - &install_pnpm "corepack enable pnpm" - &slow_check_paths - event: pull_request @@ -24,15 +25,17 @@ variables: "diesel.toml", ".gitmodules", ] - -# 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 + - install_binstall: &install_binstall + - 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 + - install_diesel_cli: &install_diesel_cli + - apt update && apt install -y lsb-release build-essential + - sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - + - apt update && apt install -y postgresql-client-16 + - cargo install diesel_cli --no-default-features --features postgres + - export PATH="$CARGO_HOME/bin:$PATH" steps: prepare_repo: @@ -66,7 +69,7 @@ steps: - event: pull_request cargo_fmt: - image: rustlang/rust:nightly + image: *rust_nightly_image environment: # store cargo data in repo folder so that it gets cached between steps CARGO_HOME: .cargo_home @@ -77,11 +80,9 @@ steps: - event: pull_request cargo_machete: - image: rustlang/rust:nightly + image: *rust_nightly_image 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 + - <<: *install_binstall - cargo binstall -y cargo-machete - cargo machete when: @@ -133,11 +134,12 @@ steps: when: *slow_check_paths check_diesel_schema: - image: willsquire/diesel-cli + image: *rust_image environment: CARGO_HOME: .cargo_home DATABASE_URL: postgres://lemmy:password@database:5432/lemmy commands: + - <<: *install_diesel_cli - diesel migration run - diesel print-schema --config-file=diesel.toml > tmp.schema - diff tmp.schema crates/db_schema/src/schema.rs @@ -197,8 +199,8 @@ steps: PGHOST: database PGDATABASE: lemmy commands: - - cargo install diesel_cli - - export PATH="$CARGO_HOME/bin:$PATH" + # Install diesel_cli + - <<: *install_diesel_cli # Run all migrations - diesel migration run # Dump schema to before.sqldump (PostgreSQL apt repo is used to prevent pg_dump version mismatch error) @@ -276,7 +278,9 @@ steps: publish_to_crates_io: image: *rust_image commands: - - cargo install cargo-workspaces + - <<: *install_binstall + # Install cargo-workspaces + - cargo binstall -y cargo-workspaces - cp -r migrations crates/db_schema/ - cargo workspaces publish --token "$CARGO_API_TOKEN" --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}" secrets: [cargo_api_token]