Repository navigation
fix: restore RuntimeError on released objects, add missing version ma… #54
Workflow file for this run
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| # Release tags. Without this a `git push origin v0.1.0` triggers no | |
| # workflow at all, so the publish job below would never run. | |
| tags: ["v*"] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # The package itself has no dependencies; this is the dev extra | |
| # (pytest/ruff/mypy) plus the package in editable mode. | |
| - run: pip install -e '.[dev]' | |
| # Runtime-only and loaded lazily, so the suite passes without these -- | |
| # the integration tests skip themselves. Installing them is what makes | |
| # those tests actually run. | |
| # | |
| # Worth knowing: Ubuntu noble ships libei 1.2.1, not 1.6.x. That is a | |
| # feature here rather than a problem -- it exercises the 1.0.0 core | |
| # floor on a genuinely old build, and makes the 1.1/1.4/1.6 version | |
| # gates fire for real, which no developer machine running 1.6 can do. | |
| # Tests gated on a missing symbol skip; nothing should hang or fail. | |
| - name: Install libei | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libei1 libeis1 liboeffis1 | |
| - name: Report the native libraries actually found | |
| run: | | |
| python - <<'PY' | |
| from libei import ei, eis, oeffis | |
| for mod in (ei, eis, oeffis): | |
| print(f"{mod.__name__}: {mod.is_available()}") | |
| assert ei.is_available() and eis.is_available(), "native libei/libeis missing" | |
| PY | |
| - run: ruff check src tests | |
| # Checked, not applied. pyguitest and pyguitest-recorder both gate on | |
| # formatting; this repo's config had never asked for it, so an | |
| # unformatted file could land here and in neither of the others. | |
| - run: ruff format --check src tests | |
| - run: python -m mypy | |
| # -rs so the log names every skip: on an older libei the version-gated | |
| # tests skip, and which ones did is the interesting part of the run. | |
| - run: python -m pytest -q -rs | |
| # Importing must work with no native libraries present at all -- that is | |
| # the property the lazy loader exists to provide, and the one a consumer | |
| # depending on this package optionally relies on. | |
| import-without-libei: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - run: pip install . | |
| - name: Import and introspect with no libei installed | |
| run: | | |
| python - <<'PY' | |
| from libei import ei, eis, oeffis | |
| assert ei.EventType.POINTER_MOTION == 300 | |
| assert ei.DeviceCapability.TEXT == 1 << 6 | |
| for mod in (ei, eis, oeffis): | |
| assert mod.is_available() is False, f"{mod.__name__} unexpectedly available" | |
| print("import-safe with no native libraries") | |
| PY | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - run: pip install build twine | |
| - run: python -m build | |
| # A PyPI version number can never be reused, so a tag disagreeing with | |
| # the packaged version has to fail here rather than ship. Read back out | |
| # of the built artifact, not out of the source, so it checks what would | |
| # actually be uploaded. Skipped on branch pushes, where there is no tag. | |
| # | |
| # This repo needed it more than either sibling, which both had it | |
| # already: 0.5.2 came about because eleven commits had accumulated past | |
| # v0.5.1 -- including the InputCapture signal fix -- with nothing | |
| # anywhere able to notice the released number had stopped describing | |
| # the tree. Porting their step is what closes that. | |
| - name: Check the tag matches the packaged version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| set -eu | |
| tag="${GITHUB_REF_NAME#v}" | |
| built=$(ls dist/*.tar.gz | sed -E 's|.*/python_libei-(.+)\.tar\.gz|\1|') | |
| echo "tag=$tag packaged=$built" | |
| if [ "$tag" != "$built" ]; then | |
| echo "::error::tag $GITHUB_REF_NAME does not match the packaged" | |
| echo "::error::version $built -- fix the version in" | |
| echo "::error::pyproject.toml or retag." | |
| exit 1 | |
| fi | |
| # Strict, like its two siblings: catches a README that renders on GitHub | |
| # but not on PyPI, which is otherwise only discovered once the upload is | |
| # already permanent. Measured green on 0.5.2's artifacts before enabling. | |
| - run: python -m twine check --strict dist/* | |
| # Handed to the publish job below rather than rebuilt there, so what | |
| # reaches PyPI is byte-for-byte what twine just checked. | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| if-no-files-found: error | |
| # Publishes to PyPI on a v* tag via Trusted Publishing (OIDC): PyPI is | |
| # configured to trust this repo/workflow/environment, so there is no API | |
| # token in secrets to leak or rotate. `id-token: write` is what lets the | |
| # runner mint the short-lived credential; the action does the rest. | |
| # | |
| # Requires one-time setup on pypi.org first -- see "Releasing" in the | |
| # README. Until that exists, a tag push fails here rather than silently | |
| # publishing nothing. | |
| publish: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [test, import-without-libei, build] | |
| runs-on: ubuntu-latest | |
| # Must match the environment named in the PyPI publisher config. A | |
| # required reviewer on it makes each publish a deliberate approval | |
| # rather than a side effect of pushing a tag. | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/python-libei | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: pypa/gh-action-pypi-publish@release/v1 |