Skip to content

ci: modernize workflows and add releases - #266

Merged
uniqueg merged 12 commits into
devfrom
ci/modernize
Oct 17, 2026
Merged

uniqueg merged 12 commits into
devfrom
ci/modernize

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

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)

  • actions updated to current (Node 24) versions and pinned by commit SHA
  • jobs split: lint/build (flake8, mypy, python -m build, twine check --strict), unit tests, integration tests, Docker images
  • unit test matrix: Python 3.10–3.14 × MongoDB 8.0, plus Python 3.13 × MongoDB 7.0 (6 jobs instead of 16, no EOL MongoDB versions); coverage uploaded once
  • petstore integration tests run once; the job waits for the app instead of sleep 10 and prints container logs on failure
  • Docker images are pushed only on pushes to dev (previously PR branches were pushed to Docker Hub too, and fork PRs failed for lack of secrets); images for Python 3.10–3.14, latest moves to 3.13; tag scheme YYYYMMDD-pyX.Y unchanged
  • permissions: contents: read, concurrency group cancelling superseded PR runs, job timeouts, pip cache
  • blanket -W ignore::DeprecationWarning replaced by targeted pytest filterwarnings for connexion 2's use of deprecated jsonschema APIs
  • Python 3.13/3.14 classifiers added

Release workflow (release.yml)

  • triggered when a GitHub release is published
  • checks that the release tag (vX.Y.Z or X.Y.Z) matches foca/version.py, builds sdist + wheel (0.13.0 was published as wheel only), runs twine check
  • publishes to PyPI via trusted publishing from the pypi environment (configured on PyPI and GitHub), no API token

Dependabot (dependabot.yml)

  • weekly grouped version updates for pip, GitHub Actions and the Docker base image, targeting dev
  • Connexion major updates ignored until the Connexion 3 migration (build: add support for Connexion 3+ #188)

Verification

Locally:

  • actionlint on both workflows: clean
  • python -m build + twine check --strict: both distributions pass
  • pytest (unit tests without MongoDB) with the new warning filters and without -W: 246 passed, 0 warnings
  • python:3.14-slim-trixie exists on Docker Hub

The 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:

  • Add an automated release workflow that validates package versions and publishes source and wheel distributions to PyPI using trusted publishing.
  • Add Dependabot automation for weekly dependency, GitHub Actions, and Docker base-image updates.

Bug Fixes:

  • Prevent Docker image publishing from pull request workflows and ensure release artifacts are published only from valid release commits and matching tags.

Enhancements:

  • Modernize CI with separate lint/build, unit-test, integration-test, and Docker publishing jobs covering supported Python and MongoDB versions.
  • Improve integration test readiness checks, failure diagnostics, permissions, concurrency, caching, and workflow time limits.
  • Replace broad deprecation-warning suppression with targeted pytest filters and add Python 3.13 and 3.14 package classifiers.

CI:

  • Pin GitHub Actions to commit SHAs and update the CI workflow to current action versions.

Deployment:

  • Publish Docker images for Python 3.10 through 3.14 on pushes to the development branch, with Python 3.13 as the latest image.

Tests:

  • Expand automated unit-test coverage across Python 3.10–3.14 and MongoDB 7.0/8.0, and isolate petstore integration testing into its own job.

uniqueg and others added 7 commits October 17, 2026 18:05
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]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 16:21
@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This 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 workflow

sequenceDiagram
    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
Loading

Flow diagram for controlled Docker image publishing

flowchart 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]
Loading

File-Level Changes

Change Details Files
Modernize CI into isolated validation, testing, integration, and conditional Docker publishing jobs with pinned actions and stronger execution controls.
  • Split lint/type-check/package validation from unit, petstore integration, and Docker jobs.
  • Expand unit coverage to Python 3.10–3.14 with MongoDB 8.0 plus Python 3.13/MongoDB 7.0, uploading coverage once.
  • Replace fixed integration-test sleep with readiness polling and failure log collection.
  • Restrict Docker publishing to push events, publish Python 3.10–3.14 images, and move latest to Python 3.13.
  • Add SHA-pinned actions, read-only permissions, PR concurrency cancellation, timeouts, and pip caching.
  • Replace blanket deprecation suppression with targeted pytest warning filters.
.github/workflows/checks.yml
pyproject.toml
Add a release pipeline that validates versioning, builds both distribution formats, and publishes through PyPI trusted publishing.
  • Trigger on published GitHub releases and accept either vX.Y.Z or X.Y.Z tag forms.
  • Verify the release tag matches foca/version.py before building.
  • Run strict distribution checks and transfer artifacts between isolated build and publish jobs.
  • Publish through the pypi environment using an OIDC id-token instead of an API token.
.github/workflows/release.yml
Automate dependency maintenance while preserving the planned Connexion migration boundary.
  • Schedule weekly grouped updates for pip and GitHub Actions, targeting dev.
  • Track the Docker base image through Dependabot.
  • Ignore Connexion major updates pending the Connexion 3 migration.
.github/dependabot.yml
Update supported runtime and documentation/container baselines for current Python and platform releases.
  • Add Python 3.13 and 3.14 package classifiers and broaden dependency minimums.
  • Move Read the Docs to Ubuntu 24.04/Python 3.13 and simplify documentation extras.
  • Update Docker and petstore compose defaults to Python 3.13 slim Trixie and MongoDB 8.0.
  • Modernize Dockerfile syntax and environment declarations.
pyproject.toml
.readthedocs.yaml
docker/Dockerfile
examples/petstore/docker-compose.yaml
examples/petstore-access-control/docker-compose.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7969cc6) to head (8ecdd57).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #266   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1113      1113           
=========================================
  Hits          1113      1113           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 dev pushes.
  • 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

@uniqueg
uniqueg marked this pull request as ready for review October 17, 2026 16:37
Copilot AI balanced review requested due to automatic review settings October 17, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new PyPI and revised Docker publishing paths remain unexercised and warrant human validation.

No open issues 🎉

Review effort: Balanced

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/checks.yml Resolved
Comment thread .github/workflows/checks.yml Resolved
uniqueg and others added 2 commits October 18, 2026 01:19
- 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]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 23:19
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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The unexercised publishing paths require human confirmation of external publishing configuration and protections.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 17, 2026 23:21
Copilot stopped reviewing on behalf of uniqueg due to an error October 17, 2026 23:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@uniqueg
uniqueg merged commit 9367dab into dev Oct 17, 2026
13 of 14 checks passed
@uniqueg
uniqueg deleted the ci/modernize branch October 17, 2026 23:24
uniqueg added a commit that referenced this pull request Oct 17, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants