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 24, 2024
1 parent 253b487 commit d677526
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 3 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 --verbose --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox
tox --version
${{ inputs.run }}
4 changes: 4 additions & 0 deletions .github/actions/netbsd-vm/python/3.11.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use "*" because the name of the python package is something like:
# python311-3.11.?(nb?)
NETBSD_PORTS_FOR_PYTHON="python311-*"
NETBSD_PYTHON_BIN=python3.11
4 changes: 4 additions & 0 deletions .github/actions/netbsd-vm/python/3.12.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use "*" because the name of the python package is something like:
# python312-3.12.?(nb?)
NETBSD_PORTS_FOR_PYTHON="python312-*"
NETBSD_PYTHON_BIN=python3.12
72 changes: 72 additions & 0 deletions .github/actions/openbsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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: Install PDM
uses: pdm-project/setup-pdm@2f3a9be7ac56a6e5c1ea605f8e9d0f0500363705 # v4
id: pdm
with:
version: ${{ env.PDM_VERSION }}
python-version: '3.11'
- name: Create requirements.txt files in .github
shell: bash
run: |
set -x
pdm export --no-default --format=requirements --without-hashes --output=.github/requirements-mypy.txt \
--group=mypy \
--group=cbor \
--group=msgpack \
--group=types-msgpack \
--group=trio
pdm export --no-default --format=requirements --without-hashes --output=.github/requirements-test.txt \
--group=test \
--group=coverage \
--group=cbor \
--group=msgpack \
--group=trio \
--group=test-trio
cat .github/requirements-mypy.txt
cat .github/requirements-test.txt
- name: Run on VM
uses: vmactions/openbsd-vm@v1
with:
release: ${{ inputs.release }}
usesh: true
envs: ${{ inputs.envs }}
sync: ${{ inputs.sync }}
# FIXME: Cannot install tox on OpenBSD: PDM crashes when installing packages
# c.f. https://github.com/pdm-project/dep-logic/issues/7
prepare: |
set -e
pkg_add -v -r curl git ${{ env.OPENBSD_PORTS_FOR_PYTHON }}
run: |
set -e
${{ 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
OPENBSD_PYTHON_BIN=python3.11
55 changes: 54 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,57 @@ jobs:
release: '14.1'
python-version: '3.11'
run: |
tox --workdir /tmp/.tox run -e mypy-full
export TOX_WORK_DIR=/tmp/.tox
tox run -e mypy-full
type-hinting-openbsd:
# 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)
runs-on: ubuntu-24.04

name: type-hinting (openbsd-7.6)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Launch checks
timeout-minutes: 10
uses: ./.github/actions/openbsd-vm
with:
release: '7.6'
python-version: '3.11'
# FIXME: Cannot run tox (which uses tox-pdm) on OpenBSD: PDM crashes when installing packages
# c.f. https://github.com/pdm-project/dep-logic/issues/7
run: |
export PYTHONUNBUFFERED=1
export MYPY_CACHE_DIR=/tmp/.mypy_cache
python3.11 -m venv /tmp/.venv
. /tmp/.venv/bin/activate
pip install -r .github/requirements-mypy.txt -e .
mypy --config-file=pyproject.toml -p easynetwork
type-hinting-netbsd:
# 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)
runs-on: ubuntu-24.04

name: type-hinting (netbsd-10.0)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Launch checks
timeout-minutes: 10
uses: ./.github/actions/netbsd-vm
with:
release: '10.0'
python-version: '3.11'
run: |
export TOX_WORK_DIR=/tmp/.tox
tox run -e mypy-full
97 changes: 95 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ jobs:
release: '14.1'
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
export TOX_WORK_DIR=/tmp/.tox
tox run -f ${{ matrix.tox_py }} -- ${{ env.PYTEST_VERBOSE_FLAG }}
tox run -f coverage
- name: Check files in workspace
if: always()
run: ls -lA
Expand All @@ -166,3 +167,95 @@ jobs:
test-functional,
OS-FreeBSD,
Py-${{ matrix.python_version }}
test-openbsd:
# 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:
# OpenBSD always has a unique Python3 version.
python_version: ['3.11']
include:
- python_version: '3.11'
tox_py: py311

name: test (openbsd-7.6, ${{ 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/openbsd-vm
with:
release: '7.6'
python-version: ${{ matrix.python_version }}
# FIXME: Cannot run tox (which uses tox-pdm) on OpenBSD: PDM crashes when installing packages
# c.f. https://github.com/pdm-project/dep-logic/issues/7
run: |
export PYTHON=python${{ matrix.python_version }}
export PYTHONUNBUFFERED=1
export PYTHONHASHSEED=100
export PYTEST_ADDOPTS="-p "no:cacheprovider""
$PYTHON -m venv /tmp/.venv
. /tmp/.venv/bin/activate
pip install -r .github/requirements-test.txt -e .
# Launch common checks
pytest -m "not unit and not functional" --no-cov ${{ env.PYTEST_VERBOSE_FLAG }}
# Launch unit tests
export COVERAGE_FILE=.coverage.unit
pytest -n auto tests/unit_test --cov --cov-report=term-missing ${{ env.PYTEST_VERBOSE_FLAG }}
coverage xml -o coverage.unit.xml
# Launch functional tests
export COVERAGE_FILE=.coverage.functional
pytest -n auto tests/functional_test --cov --cov-report=term-missing ${{ env.PYTEST_VERBOSE_FLAG }}
coverage xml -o coverage.functional.xml
- name: Check files in workspace
if: always()
run: ls -lA

test-netbsd:
# 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:
# NOTE: Python 3.13 is not available yet.
python_version: ['3.11', '3.12']
include:
- python_version: '3.11'
tox_py: py311
- python_version: '3.12'
tox_py: py312

name: test (netbsd-10.0, ${{ 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/netbsd-vm
with:
release: '10.0'
python-version: ${{ matrix.python_version }}
run: |
export TOX_WORK_DIR=/tmp/.tox
tox run -f ${{ matrix.tox_py }} -- ${{ env.PYTEST_VERBOSE_FLAG }}
tox run -f coverage
- name: Check files in workspace
if: always()
run: ls -lA
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ benchmark*.svg

# Github Actions
.github/.*.key
.github/requirements*.txt

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down

0 comments on commit d677526

Please sign in to comment.