From b12affc1a023cffa50db6e44eabba9324848c0e4 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 6 Aug 2026 08:46:14 +0000 Subject: [PATCH] ci: run the unit tests, which nothing was running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main_test.py has 99 tests and CI never executed a single one. The repo's workflows are commit-check (self test), pre-commit (black, mypy, codespell, yaml/toml), release and used-by — none of them invoke pytest. Every release so far shipped with the suite unrun outside contributors' machines. Matrix is the floor and the newest across the three OSes the action supports. 3.10 is the real floor: main.py annotates with `str | None` without `from __future__ import annotations`, so the annotation is evaluated at def time, and main_test.py uses parenthesized context managers — both 3.10+. Installs requirements.txt rather than the bare deps, so the commit-check version under test is the one the action ships, which is also the version the golden tests read back out of importlib.metadata. Verified from a clean venv: the exact install and pytest invocation this workflow runs gives 99 passed, 2 subtests passed. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01U9zFxq8V4qxG4aMzJhGBFn --- .github/workflows/test.yml | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f328dcd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test + +permissions: + contents: read + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + strategy: + fail-fast: false + matrix: + # The floor and the newest. 3.10 is the real floor: main.py annotates + # with `str | None` and has no `from __future__ import annotations`, so + # the annotation is evaluated at def time, and main_test.py uses + # parenthesized context managers. Both are 3.10+. + # + # The action itself runs on whatever python3 the runner ships, so the + # in-between versions add little here — unlike commit-check, which is a + # published package and tests every one. + py: ['3.10', '3.14'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ matrix.py }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + # requirements.txt rather than a bare install: it pins the same + # commit-check the action ships, which is the version the golden + # tests expect to read back out of importlib.metadata. + python -m pip install -r requirements.txt pytest + + - name: Run unit tests + run: python -m pytest main_test.py -v