diff --git a/.woodpecker.yml b/.woodpecker.yml index 43e329e45..4102200f6 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,12 +7,6 @@ variables: - &install_pnpm "corepack enable pnpm" - &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 lsb-release - # Instructions taken from here: https://www.postgresql.org/download/linux/ubuntu/ - # - install -d /usr/share/postgresql-common/pgdg - # - curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc - # - sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' - # - apt-get update && apt-get -y install postgresql-client - apt-get update && apt-get -y install postgresql-client - cargo install diesel_cli --no-default-features --features postgres - export PATH="$CARGO_HOME/bin:$PATH" @@ -47,6 +41,40 @@ steps: when: - event: [pull_request, tag] + 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: + # 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) + - 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 + check_diesel_schema: image: *rust_image environment: @@ -187,40 +215,6 @@ steps: - cargo test --workspace --no-fail-fast when: *slow_check_paths - 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: - # 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) - - 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 - run_federation_tests: image: node:20-bookworm-slim environment: