# Compile and run the unit tests on the runner itself rather than in a container, once per toolchain. The container jobs cover # what pgBackRest is normally built with, so what is tested here is whether it builds and runs somewhere else: gcc is the # baseline, clang is a second opinion from a different compiler, and Fil-C is a memory-safe implementation of C where every # pointer carries an invisible capability that is checked on every access, so an out-of-bounds access, a use-after-free, or a # type confusion panics instead of doing damage. # # Only the unit tests that run without a container are run. The integration tests need containers by definition. name: compile on: workflow_call # Limit permissions on the repository permissions: contents: read jobs: # gcc and clang, each with the optional libraries present and absent. The runs are fast enough that the second variation is # nearly free, and it is what catches code that only compiles when a feature is enabled. toolchain: runs-on: ubuntu-24.04 strategy: # Let all the jobs run to completion even if one fails fail-fast: false matrix: include: - cc: gcc lib: full - cc: gcc lib: minimal - cc: clang lib: full - cc: clang lib: minimal steps: - name: Checkout Code uses: actions/checkout@v6 with: path: pgbackrest - name: Update Apt uses: ./pgbackrest/.github/action/apt # The required libraries, the compression tools some tests shell out to, and what the harness needs. The optional libraries # are added for the full variation and removed for the minimal one rather than just left out, since the runner image is not # a fixed set of packages and one of them may already be there or arrive as a dependency of something installed here. - name: Install run: | package="git pkg-config meson ninja-build python3-yaml python3-coverage zlib1g-dev libssl-dev libxml2-dev libpq-dev" package="${package} libbz2-dev liblz4-dev liblz4-tool bzip2 libzstd-dev zstd ${{matrix.cc}}" optional="libssh2-1-dev libsystemd-dev" if test "${{matrix.lib}}" = full; then package="${package} ${optional}" fi DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ${package} if test "${{matrix.lib}}" = minimal; then DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive sudo apt-get remove -y ${optional} fi # Removing a package is not proof that meson will not find the library, so check what it will actually see. Without this a # library that reappears on a future runner image would turn the minimal variation into a second full one and nothing # would say so. - name: Check Libraries run: | for lib in libssh2 libsystemd; do pkg-config --exists ${lib} && found=full || found=minimal if test "${found}" != "${{matrix.lib}}"; then echo "${lib} is ${found} but the variation is ${{matrix.lib}}" exit 1 fi done # Coverage and valgrind are both off since neither is what this job is for and both cost time. The tests must not run as # root: several of them expect an operation to be refused, and as root it succeeds and leaves the path behind, which # breaks the run and every run after it on the same machine. - name: Run Test env: CC: ${{matrix.cc}} run: | cd ${HOME?} && ${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm-max=2 --no-coverage --no-valgrind # Fil-C. Everything the tests link has to be built with Fil-C as well -- linking to code that was not is what Fil-C calls # unsafe and it is severely restricted -- so the /opt/fil distribution is used, which ships memory-safe builds of every # library the tests need. fil-c: runs-on: ubuntu-24.04 # Fail rather than hang, since a test that deadlocks under Fil-C blocks the runner until the workflow timeout otherwise timeout-minutes: 45 # Fil-C releases are at https://github.com/pizlonator/fil-c/releases. env: FILC_VERSION: '0.684' # Build with the Fil-C compiler and find only the libraries built for it. --gcc-toolchain points clang at the Fil-C # prefix so the host gcc's library directory stays out of the search path, which keeps a library that was not built with # Fil-C from being picked up, and PKG_CONFIG_LIBDIR does the same for pkg-config. It also keeps meson from finding the # libbacktrace that ships with gcc, which matters because libbacktrace cannot work here -- the Fil-C runtime does not # implement _Unwind_Backtrace, so every attempt to build a stack trace panics. CC: /opt/fil/bin/filcc --gcc-toolchain=/opt/fil PKG_CONFIG_PATH: /opt/fil/lib/pkgconfig PKG_CONFIG_LIBDIR: /opt/fil/lib/pkgconfig # The glibc in /opt/fil looks for the timezone database under its own prefix, where there is none, and silently falls back # to UTC. That makes every test that sets a timezone read as if it had not, so point it at the one the system has. TZDIR: /usr/share/zoneinfo steps: - name: Checkout Code uses: actions/checkout@v6 with: path: pgbackrest - name: Update Apt uses: ./pgbackrest/.github/action/apt # No -dev packages are installed since nothing built by the host toolchain can be linked into a Fil-C binary. - name: Install run: | DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive sudo apt-get install -y meson ninja-build \ python3-yaml python3-coverage pkg-config liblz4-tool bzip2 zstd # The /opt/fil distribution is used rather than the standalone tarball because it is glibc-based and ships memory-safe # builds of every library the tests link, openssl, zlib, lz4, zstd, bz2, libxml2, and libpq. It is x86_64 only, which # is why this job does not also run on the ARM runner. - name: Install Fil-C run: | cd ${HOME?} filc=optfil-${FILC_VERSION?}-linux-x86_64 curl -fsSL -O https://github.com/pizlonator/fil-c/releases/download/v${FILC_VERSION?}/${filc}.tar.xz tar -xJf ${filc}.tar.xz cd ${filc} && sudo ./setup.sh --unattended sudo chown -R $(id -u):$(id -g) /opt/fil - name: Run Test run: | cd ${HOME?} && ${GITHUB_WORKSPACE?}/pgbackrest/test/test.py --vm-max=2 --no-coverage --no-valgrind