Skip to content

Commit

Permalink
[WIP] CI: Added tests on OpenBSD & NetBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia committed Nov 11, 2024
1 parent 7087e4a commit d16c081
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 36 deletions.
50 changes: 50 additions & 0 deletions .github/actions/netbsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions .github/actions/netbsd-vm/python/3.11.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Install python and all optional dependencies
NETBSD_PORTS_FOR_PYTHON="python311-*"
NETBSD_PYTHON_BIN=python3.11
48 changes: 48 additions & 0 deletions .github/actions/openbsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .github/actions/openbsd-vm/python/3.11.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OPENBSD_PORTS_FOR_PYTHON=python-3.11.10p1
OPENBSD_PYTHON_BIN=python3.11
84 changes: 48 additions & 36 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -110,60 +107,75 @@ 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:
fetch-depth: 0
- 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 }}
tox --workdir /tmp/.tox run -f coverage
- 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 }}

0 comments on commit d16c081

Please sign in to comment.