1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-10-23 21:28:56 +03:00
Files
pgbackrest/.github/workflows/test-arch.yml
David Steele 59bd2cd96c Migrate the build and documentation code from C to Python.
The build tool in src/build becomes build/build.py with its library in build/lib, and the C part of the documentation tool in doc/src becomes doc/doc.py with its library in doc/lib. They migrate together because doc/src was built on src/build, linking its config and help parsing along with its extensions to the core types. doc.pl runs doc.py rather than building and running a C binary, and meson runs build.py for the code it generates as it builds.

The three libraries form the hierarchy the C include path did: build/lib is the base, doc/lib sits on it, and test/lib sits on both. They are implicit namespace packages so a package spans them, and a module lives in exactly one library and holds the union of what the tools need from it, since Python resolves a module name to a single file and cannot extend one the way the C included a core module and added to it. define.yaml declares which libraries each tool may import and the test runner puts only those on the path, so a test of the build library cannot reach the doc or test library any more than the build tool can.

The declarations move with the code. config.yaml, error.yaml, and postgres.yaml are now at the root of build, and help.xml becomes doc/xml/reference.xml since it is documentation that the help happens to be generated from, so the generator is told where it is rather than knowing. dist.sh moves to build as well. The documentation tool's own option declarations are gone because they existed only to generate the option parser for the C binary and doc.py parses its command line directly.

Three modules in src/build/common were never build tool code. exec, regExp, and string extend the core types for the test harness and the unit tests, which were their only users, so they move to test/src/harness. The json and xml extensions had no users outside the two tools and are removed with them, and the tests for both are trimmed to the core functions that remain.

The help unit test built its fixture by calling the generator's C functions directly, which was the last thing outside the tools that depended on them. It now runs build.py help-data to write the packed help and loads that, so it still runs against the current declarations without needing the generated C, which may not have been written when the test runs.

The manual page wrapping is a port of the wrapper the binary uses for its own help, so the manual page and pgbackrest help break lines the same way, including where a word longer than a line is left unbroken.

libyaml is no longer needed to build pgBackRest since the only thing that read yaml was the C generator. It is dropped from the development container and from every CI platform, and meson no longer looks for it. Code generation needs nothing compiled first either, so a test run no longer builds a generator before it can select the tests.

The common source list is merged into the pgbackrest source list since it existed only so the generator could be built from the same files, and the entries that were out of alphabetical order are put in order while the list is being rewritten anyway.

Every file the generator writes is byte identical to what the C wrote, for the project declarations and for the documentation's own. The documentation is checked the same way: the HTML rendered on this branch is byte identical to the HTML rendered on integration, every file of it, which exercises the whole pipeline on the real content rather than only the four files the tool writes.

Every module in both libraries is declared in define.yaml and has full line and branch coverage. The coverage list is keyed by file rather than by module name, since the same name in two languages is two files and one of them would have silently lost its requirement while both existed.

TestError becomes ToolError, since it is the error type for three tools now rather than for the harness alone.
2026-07-30 19:37:43 +07:00

112 lines
4.8 KiB
YAML

# Tests on architectures other than x86_64. The aarch64 tests run natively on an ARM runner while the rest are emulated.
name: arch
on: workflow_call
# Limit permissions on the repository
permissions:
contents: read
jobs:
# Unit tests on aarch64 with valgrind
aarch64:
runs-on: ubuntu-22.04-arm
# Allow pushing base images to the GHCR container cache
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
path: pgbackrest
- name: Login to GHCR
continue-on-error: true
run: echo "${{secrets.GITHUB_TOKEN}}" | docker login ghcr.io -u ${{github.actor}} --password-stdin
- name: Run Test
run: cd ${HOME?} && ${GITHUB_WORKSPACE?}/pgbackrest/test/ci.py test --vm=u22 --param=c-only --param=no-coverage --param=no-back-trace
# Basic tests on other architectures using emulation. The emulation is so slow that running all the unit tests would be too
# expensive, but this at least shows that the build works and some of the more complex tests run. In particular, it is good to
# test on one big-endian architecture to be sure that checksums are correct.
emulated:
runs-on: ubuntu-24.04
# Allow pushing base images to the GHCR container cache
permissions:
contents: read
packages: write
strategy:
# Let all the jobs run to completion even if one fails
fail-fast: false
matrix:
include:
- arch: 'ppc64le'
- arch: 's390x'
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
path: pgbackrest
- name: Install
run: |
sudo apt-get update
sudo DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive apt-get install -y sudo python3-yaml rsync zlib1g-dev libssl-dev libxml2-dev libpq-dev pkg-config make gcc ccache meson git liblz4-dev liblz4-tool zstd libzstd-dev bzip2 libbz2-dev
docker run --privileged --rm tonistiigi/binfmt --install all
- name: Login to GHCR
continue-on-error: true
run: echo "${{secrets.GITHUB_TOKEN}}" | docker login ghcr.io -u ${{github.actor}} --password-stdin
- name: Build VM
run: ${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm-build --vm=u22 --vm-arch=${{matrix.arch}}
# Compiling under emulation is slow enough that a warm ccache saves a lot of time
- name: Restore ccache
uses: ./pgbackrest/.github/action/ccache
with:
mode: restore
arch: ${{matrix.arch}}
path: test/ccache
- name: Run Test
run: |
${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm=u22 --vm-arch=${{matrix.arch}} --no-valgrind --no-coverage --module=common --test=type-pack --test=crypto --test=compress
${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm=u22 --vm-arch=${{matrix.arch}} --no-valgrind --no-coverage --module=postgres --test=interface
${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm=u22 --vm-arch=${{matrix.arch}} --no-valgrind --no-coverage --module=command --test=backup --test=restore --test=archive-get --test=archive-push --test=verify
# Run the smoke test against the arch build: a real PostgreSQL driven through a full backup/restore/verify cycle, which
# exercises checksums end-to-end on big-endian. It reuses the pgbackrest binary already built for the arch above and the
# single PostgreSQL version baked into the arch base image. A fresh container is started (test.py removes its own) with the
# SSH entrypoint overridden and run as root so smoke.py can drop to the postgres user, as the misc smoke job does.
#
# The binary is copied to /tmp first: test.py creates the test tree mode 0770 owned by the build user, so the unprivileged
# postgres user that smoke.py drops to cannot traverse it to execute the binary. /tmp is world-accessible -- it is where
# smoke.py puts its own work dirs -- so the copy there is reachable.
- name: Run Smoke Test
run: |
rm -rf /tmp/smoke && mkdir -p /tmp/smoke
cp ${GITHUB_WORKSPACE?}/test/build/u22/src/pgbackrest /tmp/smoke/pgbackrest
docker run --rm --platform linux/${{matrix.arch}} -u root --entrypoint python3 \
-v ${GITHUB_WORKSPACE?}/pgbackrest:${GITHUB_WORKSPACE?}/pgbackrest \
-v /tmp/smoke:/tmp/smoke \
ghcr.io/pgbackrest/test:u22-test-${{matrix.arch}} \
${GITHUB_WORKSPACE?}/pgbackrest/test/smoke.py --pgbackrest /tmp/smoke/pgbackrest
# Save on always() so the cache is still warmed even when tests fail
- name: Save ccache
if: always()
uses: ./pgbackrest/.github/action/ccache
with:
mode: save
arch: ${{matrix.arch}}
path: test/ccache