From 3b51e822cacab439ef548d00a6cce8d6a9290954 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 2 Aug 2026 21:08:42 +0800 Subject: [PATCH] Run the unit tests on FreeBSD The test-freebsd job has been commented out since it was written, and as written it could not have worked: it used two separate vmactions steps, one to install dependencies and one to run pytest, and each step boots its own VM -- so pytest ran in a VM where the dependencies were never installed. It also carried an actions/setup-python step and a python-version matrix, which only configure the Linux host. Fold it into a single step with prepare/run, drop the host-side Python setup, and cache the prepared VM image. Install only the runtime requirements: dev-requirements.txt pulls in matplotlib's build chain (contourpy, cffi) and FreeBSD ships no wheels for those, so pip builds them from source and the job runs past its timeout. pytest and psutil come from packages instead. --- .github/workflows/test.yml | 59 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80b629b3..ab20a02d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -135,37 +135,38 @@ jobs: run: | python -m pytest ./tests/test_core.py - # test-freebsd: + test-freebsd: - # needs: source-code-checks - # runs-on: ubuntu-latest - # strategy: - # matrix: - # # Only test the latest stable version - # python-version: ["3.14"] - # steps: + needs: source-code-checks + # FreeBSD is not offered by the GitHub-hosted runners, so the tests run in + # a FreeBSD VM booted under QEMU/KVM on a Linux runner. The whole job has + # to live in a single vmactions step: each step starts its own VM, so + # installing dependencies in one step and running pytest in another would + # run pytest in a VM that never saw the dependencies. + runs-on: ubuntu-latest + timeout-minutes: 30 - # - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + permissions: + contents: read - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 - # with: - # python-version: ${{ matrix.python-version }} - # cache: 'pip' + steps: - # - name: Install dependencies - # uses: vmactions/freebsd-vm@v1 - # with: - # usesh: true - # run: | - # pkg install -y python3 gcc devel/py-pip - # python3 --version - # if [ -f dev-requirements.txt ]; then python3 -m pip install -r dev-requirements.txt; fi - # if [ -f requirements.txt ]; then python3 -m pip install -r requirements.txt; fi + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - # - name: Unitary tests - # uses: vmactions/freebsd-vm@v1 - # with: - # usesh: true - # run: | - # python3 -m pytest ./tests/test_core.py + - name: Unitary tests + uses: vmactions/freebsd-vm@77ed28d336d03fe19a3f4f7266c1d2c4714dd79d # v1.5.2 + with: + usesh: true + cache-after-prepare: true + prepare: | + pkg install -y python3 gcc devel/py-pip devel/py-pytest sysutils/py-psutil + run: | + set -e + python3 --version + # Only the runtime requirements are installed here. + # dev-requirements.txt pulls in matplotlib's build chain (contourpy, + # cffi, ...), and FreeBSD has no wheels for those, so pip builds them + # from source and the job times out. tests/test_core.py does not need + # them. + python3 -m pip install --break-system-packages -r requirements.txt + python3 -m pytest ./tests/test_core.py