Skip to content

Add running tests in CI for each PR and commit on master#1168

Open
megahirt wants to merge 9 commits into
sillsdev:masterfrom
megahirt:feat/testCI
Open

Add running tests in CI for each PR and commit on master#1168
megahirt wants to merge 9 commits into
sillsdev:masterfrom
megahirt:feat/testCI

Conversation

@megahirt
Copy link
Copy Markdown
Contributor

@megahirt megahirt commented May 1, 2026

This pull request introduces a new GitHub Actions workflow to automate Python testing for the project. The workflow is designed to run both unit and integration tests on relevant code changes, ensuring code quality and reliability through continuous integration.

Continuous Integration Setup:

  • Adds a .github/workflows/python-tests.yml workflow that triggers on pushes and pull requests to the master branch, as well as manual dispatches. The workflow runs when changes are made to Python source, test files, or configuration files.

Testing Jobs:

  • Defines a "Unit Tests" job that sets up Python 3.11, installs dependencies, and runs pytest on test_usfmx.py, publishing the results to GitHub.
  • Defines an "Integration Tests" job that sets up Python 3.12, installs system dependencies (including XeTeX and required fonts), runs integration tests with pytest on test_projects.py using xvfb, and publishes test results. On failure, it uploads PDF diffs and log files as artifacts for debugging.

Permissions and Reporting:

  • Configures workflow permissions to allow publishing test results and posting PR comments, and uses the publish-unit-test-result-action to report test outcomes in GitHub checks.

megahirt and others added 9 commits April 30, 2026 21:48
- Bump actions/checkout and actions/setup-python to v6
- Bump actions/upload-artifact to v7
- Add --junit-xml output to both pytest invocations
- Add EnricoMi/publish-unit-test-result-action@v2 step to both jobs
- Add workflow-level permissions for checks and pull-requests writes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The test harness calls python/scripts/ptxprint as a subprocess which
uses the #!/usr/bin/python3 shebang. On the GHA runner this resolves
to system Python (missing regex, fonttools etc.) rather than the
setup-python venv. Redirect /usr/bin/python3 to the venv Python after
pip install so the shebang finds the correct interpreter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
parlocs.py unconditionally imports gi (PyGObject). Fix by:
- Adding libgirepository1.0-dev, libcairo2-dev, gir1.2-gtk-3.0,
  python3-gi, python3-gi-cairo, xvfb to apt dependencies
- Switching to pip install -e ".[gui]" to pull in pygobject/pycairo
- Running pytest under xvfb-run so GTK can open a virtual display

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pygobject 3.56.2 requires girepository-2.0 which conflicts with the
libgirepository1.0-dev apt package on Ubuntu 24.04. Avoid building
from source by installing python3-gi via apt and exposing it to the
venv Python through PYTHONPATH=/usr/lib/python3/dist-packages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The python3-gi apt package on Ubuntu 24.04 ships _gi compiled for
Python 3.12. Running with Python 3.11 causes an ABI mismatch:
  ImportError: cannot import name '_gi' from partially initialized module 'gi'
Switching setup-python to 3.12 makes the C extension importable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
XeTeX now runs successfully but done_job uses Poppler via GObject
introspection to diff the output PDF against the baseline. Add the
Poppler GIR typelib so gi.require_version('Poppler', ...) succeeds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: trigger GHA workflow to verify PR test reporting

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: create test/tmp directory for archive verification step

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@megahirt megahirt added the enhancement New feature or request label May 1, 2026
@megahirt
Copy link
Copy Markdown
Contributor Author

@mhosken consider merging this one first so that all subsequent PRs get a "green check" for running tests on the PR branch... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant