diff --git a/.github/actions/netbsd-vm/action.yml b/.github/actions/netbsd-vm/action.yml new file mode 100644 index 00000000..aedd80a7 --- /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 --verbose --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..fac3461e --- /dev/null +++ b/.github/actions/netbsd-vm/python/3.11.conf @@ -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 diff --git a/.github/actions/netbsd-vm/python/3.12.conf b/.github/actions/netbsd-vm/python/3.12.conf new file mode 100644 index 00000000..5ed571a9 --- /dev/null +++ b/.github/actions/netbsd-vm/python/3.12.conf @@ -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 diff --git a/.github/actions/netbsd-vm/python/3.13.conf b/.github/actions/netbsd-vm/python/3.13.conf new file mode 100644 index 00000000..db63c894 --- /dev/null +++ b/.github/actions/netbsd-vm/python/3.13.conf @@ -0,0 +1,4 @@ +# Use "*" because the name of the python package is something like: +# python313-3.13.?(nb?) +NETBSD_PORTS_FOR_PYTHON="python313-*" +NETBSD_PYTHON_BIN=python3.13 diff --git a/.github/actions/openbsd-vm/action.yml b/.github/actions/openbsd-vm/action.yml new file mode 100644 index 00000000..a76aecc3 --- /dev/null +++ b/.github/actions/openbsd-vm/action.yml @@ -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 }} 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..2bfcdc29 --- /dev/null +++ b/.github/actions/openbsd-vm/python/3.11.conf @@ -0,0 +1,2 @@ +OPENBSD_PORTS_FOR_PYTHON=python +OPENBSD_PYTHON_BIN=python3.11 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1cc9244a..59fed9c0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1933b998..4f1ffd9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -166,3 +167,96 @@ 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 --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 + + 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: + python_version: ['3.11', '3.12', '3.13'] + include: + - python_version: '3.11' + tox_py: py311 + - python_version: '3.12' + tox_py: py312 + - python_version: '3.13' + tox_py: py313 + + 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 diff --git a/.gitignore b/.gitignore index 20776814..05d0570a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ benchmark*.svg # Github Actions .github/.*.key +.github/requirements*.txt # Byte-compiled / optimized / DLL files __pycache__/