Skip to content

fix: avoid the "Source ID N was not found" GLib critical when an Inpu… #65

fix: avoid the "Source ID N was not found" GLib critical when an Inpu…

fix: avoid the "Source ID N was not found" GLib critical when an Inpu… #65

Workflow file for this run

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:
schedule:
# Weekly, for the libei-floor job below: the declared 1.0.0 floor is
# otherwise a claim nothing executes, since no distro CI runs ships a
# libei that old. Monday morning, so a break is found at the start of a
# week rather than during a release.
- cron: "0 5 * * 1"
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
# The README declares "libei 1.0.0 or newer"; development tracks 1.6.x and
# the `test` job above runs Ubuntu's 1.2.1 -- which leaves 1.0.x and 1.1.x
# as a floor nothing has executed since it was declared. This builds those
# exact releases from source and runs the suite against them: the
# version-gated tests must *skip* (that is their whole mechanism firing for
# real), and everything else must pass. Weekly and on dispatch, not per
# push -- a from-source meson build is minutes of work and the floor only
# moves when a release changes it. Deliberately NOT in `publish`'s needs:
# a job that does not run on tag pushes would leave publish waiting on a
# skip.
libei-floor:
name: declared floor (libei ${{ matrix.libei }})
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
libei: ["1.0.0", "1.1.0"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# What libei's own meson build needs: jinja2/attrs generate the
# protocol code, libevdev and libsystemd (sd-bus, for liboeffis) are
# its two library dependencies. Documentation is switched off rather
# than left on auto so a runner image that happens to carry doxygen
# does not turn this into a docs build.
#
# jinja2/attrs go in through BOTH apt and pip on purpose. `meson setup`
# resolves `python3` from PATH, where actions/setup-python has placed
# its own 3.12 ahead of the system one, so it is that interpreter --
# not the system python3 the apt packages land in -- that must carry
# the modules, or the proto generation fails with "python3 is missing
# modules: attr, jinja2". The pip line installs into the setup-python;
# the apt line stays as the belt-and-braces for a meson that finds the
# system interpreter instead.
- name: Install the libei build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
meson ninja-build pkg-config gcc libevdev-dev libsystemd-dev \
python3-jinja2 python3-attr
python -m pip install attrs jinja2
- name: Build and install libei ${{ matrix.libei }} from source
run: |
set -eu
git clone --depth 1 --branch "${{ matrix.libei }}" \
https://gitlab.freedesktop.org/libinput/libei.git /tmp/libei
cd /tmp/libei
# Options verified against 1.0.0's own meson_options.txt:
# documentation is an array (default []), tests a feature whose
# auto would pull the munit subproject this job has no use for.
meson setup build --prefix=/usr/local -Ddocumentation=[] -Dtests=disabled
ninja -C build
sudo ninja -C build install
sudo ldconfig
- run: pip install -e '.[dev]'
- name: The loader must find exactly the version just built
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(), "the built libei was not found"
PY
# -rs for the same reason as the `test` job: on a floor build the
# version-gated tests skipping is the finding, and the log should name
# every one of them.
- run: python -m pytest -q -rs
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