Repository navigation
ci: modernize workflows and add releases - #266
Conversation
Replace setup.py and the requirements*.txt files with PEP 621 metadata in pyproject.toml (setuptools backend). Distribution name, import package and the `dev` and `docs` extras are unchanged. - declare `requires-python = ">=3.10"` (3.9 is end of life) - ship `py.typed` inside the package so the "Typed" classifier holds - package only `foca*`, so `tests` is no longer installed into site-packages; configure pytest `pythonpath` so tests still import - declare `typing_extensions` as a runtime dependency (it is imported by `foca.models.config`) - drop the obsolete `typing` backport and the unused `toml`, `mypy-extensions`, `types-urllib3`, `types-setuptools`, `pylint`, `python-semantic-release` and `readthedocs-sphinx-ext` - drop `setup_requires` and the setuptools-git based MANIFEST.in - remove the stale semantic-release config from setup.cfg; move the mypy config to pyproject.toml (flake8 config stays in setup.cfg until ruff replaces it) - install FOCA directly from the source tree in the Docker image Closes #232 Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA now requires Python >= 3.10. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Update runtime, dev and docs dependencies while staying on Connexion 2. Ranges now allow minor/patch updates within the current major version. - connexion >=2.15.1,<3: makes explicit what was already resolved (2.15 is the only 2.x line compatible with Werkzeug 3) - Flask >=3.1.3,<4 (fixes CVE-2026-27205); Flask-PyMongo 3.x - cryptography >=50 (fixes six advisories in 44.x) - flask-authz <2.8 (2.8+ hard-pins a vulnerable Flask) - swagger-ui-bundle >=1.1 (Swagger UI 4; required by connexion 2.15) - raise floors of celery, Flask-Cors, PyJWT, requests and dev/docs tools (Sphinx >=8, sphinx-rtd-theme >=3) pip-audit reports no known vulnerabilities for the updated set. BREAKING CHANGE: FOCA now requires Flask 3. Apps using APIs removed in Flask 3 (e.g. `flask.Markup`, `_app_ctx_stack`, custom JSON encoders) need to be updated. Closes #216 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Docker: default to python:3.13-slim-trixie (Debian 13), use trixie-based images in CI, fix Dockerfile lint (`AS`, `ENV K=V`) - examples: MongoDB 8.0, Python 3.13 images, drop obsolete compose `version` key - Read the Docs: Ubuntu 24.04 and Python 3.13; install only the `docs` extra Co-Authored-By: Claude Opus 5.5 <[email protected]>
- update actions (Node 24 versions) and pin them by commit SHA - split into lint/build, unit test, integration test and image jobs - test Python 3.10-3.14 against MongoDB 8.0 (plus 3.13 on 7.0) instead of 16 jobs with EOL MongoDB versions; upload coverage and run the petstore integration tests once - check that sdist and wheel build and pass `twine check` - wait for the petstore app instead of sleeping; show logs on failure - push Docker images only for pushes to `dev`, add Python 3.13/3.14 images and move `latest` to 3.13; skip image builds on PRs (the integration job already builds one) - restrict token permissions, cancel superseded PR runs, set job timeouts, cache pip downloads - replace the blanket `-W ignore::DeprecationWarning` with targeted pytest filters for connexion's use of deprecated jsonschema APIs - add Python 3.13 and 3.14 classifiers Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build sdist and wheel when a GitHub release is published, check that the release tag matches the package version, and upload to PyPI via trusted publishing from the `pypi` environment (no API token). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Weekly grouped updates for Python dependencies, GitHub Actions and the Docker base image, targeting `dev`. Connexion major updates are ignored until the Connexion 3 migration (#188). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR restructures CI around focused, SHA-pinned validation jobs with broader current-runtime coverage, reliable petstore readiness diagnostics, and Docker publishing only on branch pushes. It also adds a tag-validated, artifact-based PyPI release workflow using trusted publishing, weekly Dependabot maintenance, and updates runtime, dependency, documentation, Docker, and MongoDB baselines for the v0.14.0 maintenance line. Sequence diagram for the validated PyPI release workflowsequenceDiagram
actor Maintainer
participant GitHub as GitHub Release
participant Build as Build job
participant Artifact as Release artifact
participant Publish as Publish job
participant PyPI
Maintainer->>GitHub: Publish release
GitHub->>Build: Trigger release workflow
Build->>Build: Check release tag against __version__
Build->>Build: python -m build
Build->>Build: twine check --strict
Build->>Artifact: Upload dist/
Artifact->>Publish: Download distributions
Publish->>PyPI: Publish via trusted publishing
Flow diagram for controlled Docker image publishingflowchart TD
Event[Push event] --> Checks[Lint unit and integration checks]
Checks -->|all pass| Matrix[Build Python 3.10 to 3.14 images]
Matrix --> Push[Push YYYYMMDD-pyX.Y tags to Docker Hub]
Push --> Latest[Python 3.13 image also receives latest]
PR[Pull request] --> Skip[Docker publishing skipped]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #266 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 1113 1113
=========================================
Hits 1113 1113
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
CI is pending, and the unexercised PyPI and Docker publishing paths require human validation.
No open issues 🎉
What changed in this PR
Modernizes FOCA’s packaging and CI, building on the maintenance series with automated PyPI releases and dependency updates.
Changes:
- Centralizes packaging and dependencies in
pyproject.toml. - Splits CI jobs, updates supported environments, and limits Docker publishing to
devpushes. - Adds trusted PyPI publishing and weekly Dependabot updates.
| File | Description |
|---|---|
| setup.py | Removes legacy packaging script. |
| setup.cfg | Retains only flake8 configuration. |
| requirements.txt | Moves runtime dependencies to project metadata. |
| requirements_docs.txt | Moves documentation dependencies to an extra. |
| requirements_dev.txt | Moves development dependencies to an extra. |
| pyproject.toml | Centralizes packaging, dependencies, and tool settings. |
| MANIFEST.in | Defines source-distribution inclusions. |
| foca/py.typed | Places the typing marker inside the package. |
| examples/petstore/docker-compose.yaml | Updates Python and MongoDB defaults. |
| examples/petstore-access-control/docker-compose.yaml | Updates Python and MongoDB defaults. |
| docker/Dockerfile | Updates the base image and package installation. |
| .readthedocs.yaml | Updates the documentation build environment. |
| .github/workflows/release.yml | Adds version-checked, trusted PyPI publishing. |
| .github/workflows/checks.yml | Separates validation jobs and restricts image publishing. |
| .github/dependabot.yml | Adds scheduled dependency updates. |
Review effort: Balanced
# Conflicts: # .github/workflows/checks.yml # pyproject.toml
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/release.yml" line_range="21" />
<code_context>
- - name: Set up Python ${{ matrix.py-version-img[0] }}
- uses: actions/setup-python@v5
+ - name: Checkout repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- python-version: ${{ matrix.py-version-img[0] }}
</code_context>
<issue_to_address>
**Unmerged tags can publish packages**
When a contributor who can create and publish GitHub releases but cannot merge to the protected branch creates a release tag pointing to an unmerged commit whose package version matches the tag, `actions/checkout` checks out the release tag, and the version check only compares that tag with `foca/version.py` from the same checkout. The build uploads those distributions for the trusted-publishing job, which publishes them to PyPI.
Before building, verify that the tagged commit is reachable from the protected release branch, or enforce equivalent protected and reviewed release-tag controls.
</issue_to_address>
### Comment 2
<location path=".github/workflows/release.yml" line_range="35" />
<code_context>
+ TAG: ${{ github.event.release.tag_name }}
+ run: |
+ VERSION=$(python -c 'exec(open("foca/version.py").read()); print(__version__)')
+ if [[ "${TAG#v}" != "${VERSION}" ]]; then
+ echo "Release tag '${TAG}' does not match package version '${VERSION}'" >&2
+ exit 1
</code_context>
<issue_to_address>
**Valid release fails version check**
When the first v0.14.0 release is published before `foca/version.py` is bumped, the release tag check compares the tag with the `0.13.0` version in `foca/version.py`, so the build job exits and nothing is uploaded to PyPI.
Update the version used by the check before publishing the release.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release.yml" line_range="67" />
<code_context>
+ name: dist
+ path: dist/
+ - name: Publish to PyPI
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
</code_context>
<issue_to_address>
**Retry leaves release incomplete**
When pyPI accepts one distribution but a later upload fails, the publish action encounters the already-published file on retry and fails instead of uploading the missing distribution, leaving the release incomplete until someone intervenes.
Configure publishing so a retry skips distributions already present on PyPI.
</issue_to_address>
### Comment 4
<location path=".github/workflows/checks.yml" line_range="118" />
<code_context>
+ - name: Wait for petstore app
+ run: |
+ for _ in $(seq 1 30); do
+ curl -s -o /dev/null http://localhost:8080/ && exit 0
+ sleep 2
+ done
</code_context>
<issue_to_address>
**Integration tests race MongoDB startup**
When the app responds before MongoDB is ready to accept connections, the readiness loop exits on any HTTP response, so the integration tests start database operations before MongoDB is ready and fail.
Wait for MongoDB to be ready for operations before starting the integration tests.
</issue_to_address>
### Comment 5
<location path=".github/workflows/checks.yml" line_range="162" />
<code_context>
- export TAG="${TAG}-py${PY_VERSION}"
- echo "TAG: ${TAG}"
+ IMAGE="${DOCKERHUB_ORG}/${REPO_NAME}"
+ TAG="$(date '+%Y%m%d')-py${PY_VERSION}"
docker build \
- -t ${DOCKERHUB_ORG}/${REPO_NAME}:${TAG} \
</code_context>
<issue_to_address>
**Python image tags split across dates**
When docker matrix jobs for one push run on opposite sides of UTC midnight, each Docker matrix job evaluates `date` independently, so jobs that run on opposite sides of UTC midnight push the same commit’s Python images under different date prefixes, leaving an incomplete tag set for either date.
Compute the date once for the workflow run and pass that value to every Docker matrix job.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, and a published release can upload a distribution to PyPI, and the Docker workflow can push public image tags; reverting the workflow stops future publishes but does not retract artifacts already published or undo pulls of an overwritten tag. The PyPI job also uses an OIDC publishing identity, so an incorrectly configured release path could use that publishing authority.
Blocking findings: .github/workflows/release.yml:21, .github/workflows/release.yml:35, .github/workflows/release.yml:67, .github/workflows/checks.yml:118, .github/workflows/checks.yml:162
- Fail the release if the tagged commit is not on the default branch, guarding against accidental releases from unmerged commits. Publishing itself is controlled by the `pypi` environment's protection rules (required reviewer, `v*` tags only). - Skip distributions already on PyPI, so that re-running a partially failed upload completes the release instead of failing. Addresses Sourcery review comments on #266. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Derive the date in Docker image tags from the pushed commit's timestamp instead of each job's clock, so that all images of one push share the same tag date, even if matrix jobs run on both sides of UTC midnight. Addresses a Sourcery review comment on #266. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflict in the CI workflow in favour of this branch, which rewrites it and already includes the changes from #265. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Resolve conflicts with the squash-merged #264, #265 and #266: - CI workflow: keep linting and format checks with ruff from this branch, take the commit-timestamp Docker tags from dev. - Release workflow: take the release commit check and skip-existing uploads from dev. - pyproject.toml: keep ruff and pre-commit instead of flake8 in the dev extra. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Third PR of the v0.14.0 maintenance series. Builds on #265 (and #264); only the last three commits are new here.
CI workflow (
checks.yml)python -m build,twine check --strict), unit tests, integration tests, Docker imagessleep 10and prints container logs on failuredev(previously PR branches were pushed to Docker Hub too, and fork PRs failed for lack of secrets); images for Python 3.10–3.14,latestmoves to 3.13; tag schemeYYYYMMDD-pyX.Yunchangedpermissions: contents: read, concurrency group cancelling superseded PR runs, job timeouts, pip cache-W ignore::DeprecationWarningreplaced by targeted pytestfilterwarningsfor connexion 2's use of deprecated jsonschema APIsRelease workflow (
release.yml)vX.Y.ZorX.Y.Z) matchesfoca/version.py, builds sdist + wheel (0.13.0 was published as wheel only), runstwine checkpypienvironment (configured on PyPI and GitHub), no API tokenDependabot (
dependabot.yml)devVerification
Locally:
actionlinton both workflows: cleanpython -m build+twine check --strict: both distributions passpytest(unit tests without MongoDB) with the new warning filters and without-W: 246 passed, 0 warningspython:3.14-slim-trixieexists on Docker HubThe release workflow can only be exercised by publishing a release; its first real run will be v0.14.0. The Docker job only runs on pushes to
dev, so it will first run after merge.CI: all checks pass with the new workflow (run): lint/type-check/build, unit tests on Python 3.10–3.14 × MongoDB 8.0 and 3.13 × MongoDB 7.0, petstore integration tests, Read the Docs; image publishing correctly skipped on the PR.
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Modernize project automation with broader CI coverage, controlled Docker publishing, automated PyPI releases, and dependency update management.
New Features:
Bug Fixes:
Enhancements:
CI:
Deployment:
Tests: