From 152ae50bc579c9eb766e364b41b1ac69bc0ee673 Mon Sep 17 00:00:00 2001 From: dlf-dds Date: Mon, 16 Nov 2026 06:38:40 +0000 Subject: [PATCH] ci(postgres): run the encoding-migrate container test on every change to the roles it drives ops/ansible/roles/postgres-encoding-migrate/tests/run-test.sh migrates a founder, a joiner and a physical standby on one Docker host, with a real pg_basebackup rebuild of the standby, and no workflow ran it. The new workflow runs it on a GitHub-hosted runner, which may become root as the standby rebuild needs, against the postgres-spock fleet pin the test reads. It runs on a pull request or a push to main that changes the migration role or playbook, postgres-streaming-replication, spock-mesh-peering, spock-mesh-wire.yml or the workflow itself. Actions are pinned by commit, permissions are contents: read, and the run's logs are kept on failure. Signed-off-by: dlf-dds --- .../workflows/postgres-encoding-migrate.yml | 83 +++++++++++++++++++ .../roles/postgres-encoding-migrate/README.md | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/postgres-encoding-migrate.yml diff --git a/.github/workflows/postgres-encoding-migrate.yml b/.github/workflows/postgres-encoding-migrate.yml new file mode 100644 index 000000000..dce700df3 --- /dev/null +++ b/.github/workflows/postgres-encoding-migrate.yml @@ -0,0 +1,83 @@ +name: postgres-encoding-migrate + +# The functional test of the SQL_ASCII to UTF8 migration, +# ops/ansible/roles/postgres-encoding-migrate/tests/run-test.sh: a founder and +# a joiner wired with the real spock-mesh-peering role, a stopped peer, and a +# physical standby of the founder that postgres-streaming-replication rebuilds +# with pg_basebackup. It migrates, resumes, re-runs, rolls back and migrates +# again with a repair. The parse-only checks (tests/syntax-check.sh) run in +# ansible-syntax-check.yml; this workflow runs the containers. +# +# A GitHub-hosted runner, because the standby host becomes root: the streaming +# role wipes and chowns the standby volume's directory on the Docker host. The +# image is the postgres-spock fleet pin (ops/pins/fleet-pins.yaml), which the +# test reads itself, so the run covers the image a goatnet deploys. +# +# Triggers: a change to the migration role and playbook, to the two roles it +# drives (postgres-streaming-replication for the standby, spock-mesh-peering +# for the re-wire), to the wiring playbook the fixture uses, or to this file. + +on: + pull_request: + paths: + - 'ops/ansible/roles/postgres-encoding-migrate/**' + - 'ops/ansible/roles/postgres-streaming-replication/**' + - 'ops/ansible/roles/spock-mesh-peering/**' + - 'ops/ansible/postgres-encoding-migrate.yml' + - 'ops/ansible/spock-mesh-wire.yml' + - '.github/workflows/postgres-encoding-migrate.yml' + push: + branches: [main] + paths: + - 'ops/ansible/roles/postgres-encoding-migrate/**' + - 'ops/ansible/roles/postgres-streaming-replication/**' + - 'ops/ansible/roles/spock-mesh-peering/**' + - 'ops/ansible/postgres-encoding-migrate.yml' + - 'ops/ansible/spock-mesh-wire.yml' + - '.github/workflows/postgres-encoding-migrate.yml' + workflow_dispatch: + +# A newer push to the same pull request cancels the older run; a run on main +# is never cancelled. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +permissions: + contents: read + +jobs: + container-test: + name: migrate, resume, rebuild the standby, roll back and repair on Docker + runs-on: ubuntu-24.04 + timeout-minutes: 45 + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: '3.12' + - name: ansible-core and the collections the roles use + run: | + set -euo pipefail + python3 -m pip install --quiet 'ansible-core==2.20.3' 'requests==2.32.3' + ansible-galaxy collection install \ + 'ansible.posix:>=1.5,<3.0' \ + 'community.general:>=8.0,<11.0' \ + 'community.docker:>=3.4,<5.0' + ansible-playbook --version + docker compose version + - name: run-test.sh + env: + WORK: ${{ runner.temp }}/pem-test + run: | + set -euo pipefail + mkdir -p "$WORK" + bash ops/ansible/roles/postgres-encoding-migrate/tests/run-test.sh + - name: the run's logs, on failure + if: failure() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: postgres-encoding-migrate-logs + path: ${{ runner.temp }}/pem-test/*.log + retention-days: 7 + if-no-files-found: ignore diff --git a/ops/ansible/roles/postgres-encoding-migrate/README.md b/ops/ansible/roles/postgres-encoding-migrate/README.md index d55f5e1df..0fa13f485 100644 --- a/ops/ansible/roles/postgres-encoding-migrate/README.md +++ b/ops/ansible/roles/postgres-encoding-migrate/README.md @@ -27,4 +27,4 @@ phases, gates, rollback, cleanup) is | `tasks/reconcile.yml`, `tasks/rollback.yml`, `tasks/cleanup.yml`, `tasks/status.yml` | actions | | `files/pg-utf8-stream.py` | byte scan of a dump; the restore filter (encoding declarations, optional LATIN1 repair) | -Tests: `tests/syntax-check.sh` (CI), `tests/run-test.sh` (Docker: two members, a stopped peer, a physical standby; `tests/standby-wire.yml` builds the standby). +Tests: `tests/syntax-check.sh` (CI), `tests/run-test.sh` (Docker: two members, a stopped peer, a physical standby; `tests/standby-wire.yml` builds the standby), run in CI by `.github/workflows/postgres-encoding-migrate.yml`.