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 4e3fb8e commit 61d859c
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 54 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
45 changes: 45 additions & 0 deletions .github/actions/openbsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 }}
# 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
17 changes: 17 additions & 0 deletions .github/requirements-mypy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is @generated by PDM.
# Please do not edit it manually.

attrs==24.2.0
cbor2==5.6.5
cffi==1.17.1
idna==3.10
msgpack==1.1.0
msgpack-types==0.5.0
mypy==1.13.0
mypy-extensions==1.0.0
outcome==1.3.0.post0
pycparser==2.22
sniffio==1.3.1
sortedcontainers==2.4.0
trio==0.27.0
typing-extensions==4.12.2
27 changes: 27 additions & 0 deletions .github/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is @generated by PDM.
# Please do not edit it manually.

attrs==24.2.0
cbor2==5.6.5
cffi==1.17.1
colorama==0.4.6
coverage[toml]==7.6.4
execnet==2.1.1
idna==3.10
iniconfig==2.0.0
msgpack==1.1.0
outcome==1.3.0.post0
packaging==24.2
pluggy==1.5.0
pycparser==2.22
pytest==8.3.3
pytest-asyncio==0.24.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-retry @ git+https://github.com/str0zzapreti/pytest-retry.git@bb465fff6f01f3f90a77229468f7e08a3bdbce20
pytest-trio==0.8.0
pytest-xdist==3.6.1
sniffio==1.3.1
sortedcontainers==2.4.0
trio==0.27.0
trove-classifiers==2024.10.21.16
54 changes: 53 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,67 @@ jobs:
&& (github.event_name != 'pull_request' || github.event.pull_request.draft != true)
runs-on: ubuntu-24.04

name: type-hinting (freebsd-14)
name: type-hinting (freebsd-14.1)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Launch checks
uses: ./.github/actions/freebsd-vm
with:
timeout-minutes: 10
release: '14.1'
python-version: '3.11'
run: |
tox --workdir /tmp/.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
uses: ./.github/actions/openbsd-vm
with:
timeout-minutes: 10
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
uses: ./.github/actions/netbsd-vm
with:
timeout-minutes: 10
release: '10.0'
python-version: '3.11'
run: |
tox --workdir /tmp/.tox run -e mypy-full
100 changes: 93 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,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 Down Expand Up @@ -122,8 +119,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# TODO: Add test with other python version
# 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 @@ -146,9 +144,6 @@ 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
Expand All @@ -171,3 +166,94 @@ 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: |
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
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ repos:
'--without-hashes',
'--output=benchmark_server/servers/requirements.txt'
]
- id: pdm-export
name: pdm-export mypy
args: [
'--no-default',
'--group=mypy',
'--group=cbor',
'--group=msgpack',
'--group=types-msgpack',
'--group=trio',
'--format=requirements',
'--without-hashes',
'--output=.github/requirements-mypy.txt'
]
- id: pdm-export
name: pdm-export test
args: [
'--no-default',
'--group=test',
'--group=coverage',
'--group=cbor',
'--group=msgpack',
'--group=trio',
'--group=test-trio',
'--format=requirements',
'--without-hashes',
'--output=.github/requirements-test.txt'
]
- repo: https://github.com/doublify/pre-commit-rust
rev: 'v1.0'
hooks:
Expand Down
3 changes: 2 additions & 1 deletion src/easynetwork/clients/async_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ def __init__(
assert isinstance(ssl, _ssl_module.SSLContext) # nosec assert_used
if server_hostname is not None and not server_hostname:
ssl.check_hostname = False
ssl.options &= ~_ssl_module.OP_IGNORE_UNEXPECTED_EOF
with contextlib.suppress(AttributeError):
ssl.options &= ~_ssl_module.OP_IGNORE_UNEXPECTED_EOF
else:
if server_hostname is not None:
raise ValueError("server_hostname is only meaningful with ssl")
Expand Down
Loading

0 comments on commit 61d859c

Please sign in to comment.