Updated pdm, dev dependencies, and pre-commit pinned versions (#376) #985
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
workflow_dispatch: | |
inputs: | |
verbose: | |
description: 'Increase level of test verbosity' | |
required: false | |
default: false | |
type: boolean | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- converted_to_draft | |
- ready_for_review | |
branches: | |
- main | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
- '!**.pyi' | |
- 'tox.ini' | |
- 'pyproject.toml' | |
- 'pdm.lock' | |
- '.github/codecov.yml' | |
- '.github/actions/setup-tox/**' | |
- '.github/workflows/test.yml' | |
push: | |
branches: | |
- main | |
tags-ignore: | |
- '*' | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
- '!**.pyi' | |
- 'tox.ini' | |
- 'pyproject.toml' | |
- 'pdm.lock' | |
- '.github/codecov.yml' | |
- '.github/actions/setup-tox/**' | |
- '.github/workflows/test.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
env: | |
PYTEST_VERBOSE_FLAG: ${{ inputs.verbose && '-v' || '' }} | |
PDM_VERSION: '2.20.1' # Used by FreeBSD VM | |
jobs: | |
tests: | |
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: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-24.04, windows-2022, macos-14] | |
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 (${{ matrix.os }}, ${{ matrix.python_version }}) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup tox (python ${{ matrix.python_version }}) | |
uses: ./.github/actions/setup-tox | |
with: | |
python-version: ${{ matrix.python_version }} | |
- name: Launch tests | |
timeout-minutes: 20 | |
run: tox run -f ${{ matrix.tox_py }} -- ${{ env.PYTEST_VERBOSE_FLAG }} | |
- name: Generate coverage report | |
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 | |
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-${{ 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'))) | |
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 | |
include: | |
# py3XX-sqlite3 is needed for coverage.py | |
- python_version: '3.11' | |
freebsd_ports: >- | |
python311 | |
py311-sqlite3 | |
tox_py: py311 | |
name: test (freebsd-14, ${{ 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: vmactions/freebsd-vm@v1 | |
with: | |
release: '14.1' | |
usesh: true | |
prepare: | | |
set -e | |
pkg install -y curl git ${{ matrix.freebsd_ports }} | |
curl -sSL https://pdm-project.org/install-pdm.py | python${{ matrix.python_version }} - --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 | |
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 }} |