From d16c081d558ddd5ead9395daf0994d9a239badf2 Mon Sep 17 00:00:00 2001 From: Francis CLAIRICIA-ROSE-CLAIRE-JOSEPHINE Date: Mon, 11 Nov 2024 14:08:44 +0100 Subject: [PATCH] [WIP] CI: Added tests on OpenBSD & NetBSD --- .github/actions/netbsd-vm/action.yml | 50 ++++++++++++ .github/actions/netbsd-vm/python/3.11.conf | 3 + .github/actions/openbsd-vm/action.yml | 48 ++++++++++++ .github/actions/openbsd-vm/python/3.11.conf | 2 + .github/workflows/test.yml | 84 ++++++++++++--------- 5 files changed, 151 insertions(+), 36 deletions(-) create mode 100644 .github/actions/netbsd-vm/action.yml create mode 100644 .github/actions/netbsd-vm/python/3.11.conf create mode 100644 .github/actions/openbsd-vm/action.yml create mode 100644 .github/actions/openbsd-vm/python/3.11.conf diff --git a/.github/actions/netbsd-vm/action.yml b/.github/actions/netbsd-vm/action.yml new file mode 100644 index 00000000..cb891424 --- /dev/null +++ b/.github/actions/netbsd-vm/action.yml @@ -0,0 +1,50 @@ +name: 'NetBSD VM' +description: 'Install NetBSD VM with python3, PDM and tox pre-installed' +inputs: + python-version: + description: "Version range or exact version of Python to use, using SemVer's version range syntax." + required: true + run: + description: 'The CI command to run' + required: true + release: + description: 'The release version of NetBSD vm' + required: false + envs: + description: 'The envs to pass into NetBSD vm' + required: false + sync: + description: 'How to synchronize the source code to/from the VM, Values can be: rsync(default), and sshfs' + required: false + +runs: + using: 'composite' + steps: + - name: Load PDM configuration from pdm.conf + uses: cardinalby/export-env-action@v2 + with: + envFile: .github/actions/pdm.conf + - name: Load Python configuration + uses: cardinalby/export-env-action@v2 + with: + envFile: ${{ github.action_path }}/python/${{ inputs.python-version }}.conf + - name: Run on VM + uses: vmactions/netbsd-vm@v1 + with: + release: ${{ inputs.release }} + usesh: true + envs: ${{ inputs.envs }} + sync: ${{ inputs.sync }} + prepare: | + set -e + /usr/sbin/pkg_add -v pkgin + pkgin update + pkgin -y install curl git ${{ env.NETBSD_PORTS_FOR_PYTHON }} + curl -sSL https://pdm-project.org/install-pdm.py | ${{ env.NETBSD_PYTHON_BIN }} - --version=${{ env.PDM_VERSION }} --path=/usr/local + pdm config check_update false + pdm config install.cache true + run: | + set -e + pdm install --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox + tox --version + ${{ inputs.run }} diff --git a/.github/actions/netbsd-vm/python/3.11.conf b/.github/actions/netbsd-vm/python/3.11.conf new file mode 100644 index 00000000..22446db7 --- /dev/null +++ b/.github/actions/netbsd-vm/python/3.11.conf @@ -0,0 +1,3 @@ +# Install python and all optional dependencies +NETBSD_PORTS_FOR_PYTHON="python311-*" +NETBSD_PYTHON_BIN=python3.11 diff --git a/.github/actions/openbsd-vm/action.yml b/.github/actions/openbsd-vm/action.yml new file mode 100644 index 00000000..fb5f25d6 --- /dev/null +++ b/.github/actions/openbsd-vm/action.yml @@ -0,0 +1,48 @@ +name: 'OpenBSD VM' +description: 'Install OpenBSD VM with python3, PDM and tox pre-installed' +inputs: + python-version: + description: "Version range or exact version of Python to use, using SemVer's version range syntax." + required: true + run: + description: 'The CI command to run' + required: true + release: + description: 'The release version of OpenBSD vm' + required: false + envs: + description: 'The envs to pass into OpenBSD vm' + required: false + sync: + description: 'How to synchronize the source code to/from the VM, Values can be: rsync(default), and sshfs' + required: false + +runs: + using: 'composite' + steps: + - name: Load PDM configuration from pdm.conf + uses: cardinalby/export-env-action@v2 + with: + envFile: .github/actions/pdm.conf + - name: Load Python configuration + uses: cardinalby/export-env-action@v2 + with: + envFile: ${{ github.action_path }}/python/${{ inputs.python-version }}.conf + - name: Run on VM + uses: vmactions/openbsd-vm@v1 + with: + release: ${{ inputs.release }} + usesh: true + envs: ${{ inputs.envs }} + sync: ${{ inputs.sync }} + prepare: | + set -e + pkg_add -v -r curl git ${{ env.OPENBSD_PORTS_FOR_PYTHON }} + curl -sSL https://pdm-project.org/install-pdm.py | ${{ env.OPENBSD_PYTHON_BIN }} - --version=${{ env.PDM_VERSION }} --path=/usr/local + pdm config check_update false + pdm config install.cache true + run: | + set -e + pdm install --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox + tox --version + ${{ inputs.run }} diff --git a/.github/actions/openbsd-vm/python/3.11.conf b/.github/actions/openbsd-vm/python/3.11.conf new file mode 100644 index 00000000..16d0ac87 --- /dev/null +++ b/.github/actions/openbsd-vm/python/3.11.conf @@ -0,0 +1,2 @@ +OPENBSD_PORTS_FOR_PYTHON=python-3.11.10p1 +OPENBSD_PYTHON_BIN=python3.11 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57a4f7e6..5c294a92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,9 +84,6 @@ jobs: if: hashFiles('.coverage.*') != '' # Rudimentary `file.exists()` continue-on-error: true run: tox run -f coverage - # Currently, it is not possible to send several files with per-file tags. - # This is why the step is copy-paste twice. - # Issue: https://github.com/codecov/codecov-action/issues/1522 - name: Upload (unit tests) coverage to codecov if: hashFiles('coverage.unit.xml') != '' # Rudimentary `file.exists()` uses: codecov/codecov-action@v4 @@ -110,21 +107,39 @@ jobs: OS-${{ runner.os }}, Py-${{ matrix.python_version }} - test-freebsd: - if: | - (github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'Bump version:')) - && (github.event_name != 'pull_request' || (github.event.pull_request.draft != true && !contains(github.event.pull_request.labels.*.name, 'pr-skip-test'))) + test-bsd: + # TODO: Add this when the workflow is stable. + # if: | + # (github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'Bump version:')) + # && (github.event_name != 'pull_request' || (github.event.pull_request.draft != true && !contains(github.event.pull_request.labels.*.name, 'pr-skip-test'))) runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: # TODO: Add test with other python version - # c.f. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271673 + # FreeBSD issue: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271673 + bsd: [freebsd, openbsd, netbsd] + python_version: ['3.11'] + include: + ###### Specify releases and OS display name for each VM ###### + - bsd: freebsd + vm: ./.github/actions/freebsd-vm + os: FreeBSD + release: '14.1' + - bsd: openbsd + vm: ./.github/actions/openbsd-vm + os: OpenBSD + release: '7.6' + - bsd: netbsd + vm: ./.github/actions/netbsd-vm + os: NetBSD + release: '10.0' + ###### Python version ###### - python_version: '3.11' tox_py: py311 - name: test (freebsd-14, ${{ matrix.python_version }}) + name: test (${{ matrix.bsd }}-${{ matrix.release }}, ${{ matrix.python_version }}) steps: - uses: actions/checkout@v4 with: @@ -132,9 +147,9 @@ jobs: - name: Launch tests # Add 5 minutes to let the VM boot and install dependencies timeout-minutes: 25 - uses: ./.github/actions/freebsd-vm + uses: ${{ matrix.vm }} with: - release: '14.1' + release: ${{ matrix.release }} python-version: ${{ matrix.python_version }} run: | tox --workdir /tmp/.tox run -f ${{ matrix.tox_py }} -- ${{ env.PYTEST_VERBOSE_FLAG }} @@ -142,28 +157,25 @@ jobs: - name: Check files in workspace if: always() run: ls -lA - # Currently, it is not possible to send several files with per-file tags. - # This is why the step is copy-paste twice. - # Issue: https://github.com/codecov/codecov-action/issues/1522 - - name: Upload (unit tests) coverage to codecov - if: hashFiles('coverage.unit.xml') != '' # Rudimentary `file.exists()` - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - disable_search: true - files: >- - coverage.unit.xml - flags: >- - test-unit - - name: Upload (functional tests) coverage to codecov - if: hashFiles('coverage.functional.xml') != '' # Rudimentary `file.exists()` - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - disable_search: true - files: >- - coverage.functional.xml - flags: >- - test-functional, - OS-FreeBSD, - Py-${{ matrix.python_version }} + # - name: Upload (unit tests) coverage to codecov + # if: hashFiles('coverage.unit.xml') != '' # Rudimentary `file.exists()` + # uses: codecov/codecov-action@v4 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # disable_search: true + # files: >- + # coverage.unit.xml + # flags: >- + # test-unit + # - name: Upload (functional tests) coverage to codecov + # if: hashFiles('coverage.functional.xml') != '' # Rudimentary `file.exists()` + # uses: codecov/codecov-action@v4 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # disable_search: true + # files: >- + # coverage.functional.xml + # flags: >- + # test-functional, + # OS-${{ matrix.os }}, + # Py-${{ matrix.python_version }}