Skip to content

Commit

Permalink
CI: Added tests on OpenBSD & NetBSD (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia authored Nov 26, 2024
1 parent 253b487 commit 2a5f581
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 11 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
74 changes: 74 additions & 0 deletions .github/actions/openbsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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
env:
PDM_USE_VENV: False
- 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
10 changes: 5 additions & 5 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ comment:
require_changes: false # Always show messages if codecov is triggered
layout: "flags" # Only show coverage by flags
# unit and functional tests run:
# Python 3.11: Linux(==1), Windows(==1), MacOS(==1), FreeBSD(==1).
# Python 3.12: Linux(==1), Windows(==1), MacOS(==1).
# Python 3.13: Linux(==1), Windows(==1), MacOS(==1).
# Python 3.11: Linux, Windows, MacOS, FreeBSD, OpenBSD, NetBSD.
# Python 3.12: Linux, Windows, MacOS.
# Python 3.13: Linux, Windows, MacOS.
# Final calculation:
# (nb_builds_per_python_version(==4 + 3 + 3) * (nb_test_runs (unit + functional) (==2))
after_n_builds: 20
# (nb_builds_per_python_version(==6 + 3 + 3) * (nb_test_runs (unit + functional) (==2))
after_n_builds: 24
coverage:
status:
project:
Expand Down
53 changes: 52 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,55 @@ 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:
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:
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
136 changes: 131 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ jobs:
strategy:
fail-fast: false
matrix:
# TODO: Add test with other python versions
# c.f. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271673
python_version: ['3.11']
include:
- python_version: '3.11'
tox_py: py311
Expand All @@ -139,8 +136,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 +164,131 @@ jobs:
test-functional,
OS-FreeBSD,
Py-${{ matrix.python_version }}
test-openbsd:
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:
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 --cov --cov-report=term-missing ${{ env.PYTEST_VERBOSE_FLAG }} tests/unit_test
coverage xml -o coverage.unit.xml
# Launch functional tests
export COVERAGE_FILE=.coverage.functional
pytest -n auto --cov --cov-report=term-missing ${{ env.PYTEST_VERBOSE_FLAG }} tests/functional_test
coverage xml -o coverage.functional.xml
- name: Check files in workspace
if: always()
run: ls -lA
- name: Upload (unit tests) coverage to codecov
if: hashFiles('coverage.unit.xml') != '' # Rudimentary `file.exists()`
uses: codecov/codecov-action@v5
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@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
files: >-
coverage.functional.xml
flags: >-
test-functional,
OS-OpenBSD,
Py-${{ matrix.python_version }}
test-netbsd:
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:
include:
- python_version: '3.11'
tox_py: py311

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
- name: Upload (unit tests) coverage to codecov
if: hashFiles('coverage.unit.xml') != '' # Rudimentary `file.exists()`
uses: codecov/codecov-action@v5
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@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
files: >-
coverage.functional.xml
flags: >-
test-functional,
OS-NetBSD,
Py-${{ matrix.python_version }}
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 2a5f581

Please sign in to comment.