Repository navigation
Conversation
- Publish now calls the CI workflow (workflow_call) and only builds after tests, pre-commit and pip-audit pass on the commit being released. - Publish no longer runs on pull_request: official versions publish on push to main, pre-releases only via workflow_dispatch. - Split build / publish / release jobs; only publish gets id-token: write and only release gets contents: write. Publish uses trusted publishing through pypa/gh-action-pypi-publish, which uploads PEP 740 attestations. - Workflow-level permissions default to contents: read; checkouts use persist-credentials: false; all actions pinned to full commit SHAs. - Add a pip-audit CI job over the full uv export, with an allowlist file. - Dependabot: use the uv ecosystem so uv.lock is updated. - Refresh uv.lock (clears all known vulnerabilities in the locked set). - Add tests/test_workflows.py guarding the rules above.
Newer ruff (0.17) reformats Markdown code blocks and adds PLR0917; newer ty and redis 8 type stubs report new errors in src/. Adopting them is a separate change. Also raise the pyyaml floor to 6.0.3 (first release with Python 3.14 wheels).
pip-audit evaluates environment markers with its own interpreter and silently skips requirement lines that do not match, so pins limited to Python 3.10 (e.g. python_full_version < '3.11') were never audited. Audit the same export on 3.10-3.14 and fail if any version reports a vulnerability. tests/test_workflows.py checks that the version list matches the classifiers and the CI test matrix.
Morry98
marked this pull request as ready for review
November 9, 2026 06:03
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harden CI and release workflows
What changes
Publishing depends on CI (
publish.yml,ci.yml)ci.ymlis now also a reusable workflow (workflow_call).publish.ymlcalls it as its first job (ci), so tests (3.10–3.14), pre-commit and pip-audit must pass on the exact commit before anything is built or uploaded.ci.ymlno longer has its ownpush: maintrigger: on main, the same jobs run inside the Publish run (ci / test (3.x),ci / pre-commit,ci / pip-audit). Pull requests still runci.ymldirectly, with unchanged check names (pre-commit,test (3.x),coveralls-finished) plus the newpip-audit.No publishing from pull requests
publish.ymltriggers:pushtomainandworkflow_dispatchonly.pull_requestwas removed.x.y.z, optional.postN) publish only when the ref ismain(push or manual run).1.2.0rc1) publish only from a manualworkflow_dispatchrun (any branch). Pushes to main with a pre-release version are skipped, as before.concurrency: publishwithcancel-in-progress: falseso two releases never overlap.Least privilege
permissions: contents: readat the top level.check-version→build(read-only, uploadsdist/as an artifact) →publish(onlyid-token: write, environmentpypi) →release(onlycontents: write, creates the tag and GitHub Release withgh release create --target $GITHUB_SHA, no checkout and nogit push).actions/checkoutsteps usepersist-credentials: false.secrets: inheritis not used); Coveralls only needsGITHUB_TOKEN.Trusted publishing with attestations
uv publishis replaced bypypa/gh-action-pypi-publish(OIDC trusted publishing). It generates and uploads PEP 740 provenance attestations for every file by default.Actions pinned to commit SHAs
ci.yml,publish.ymlanddocs.ymlis pinned to a full 40-char SHA with a# vX.Y.Zcomment, staying on the major version already in use (checkout v6.1.0, setup-uv v7.6.0, action-pre-commit-uv v1.1.2, coveralls v2.3.8, upload-pages-artifact v4.0.0, deploy-pages v5.0.1). New: pypi-publish v1.14.3, upload-artifact v7.0.2, download-artifact v8.0.2.docs.ymlonly had itsuses:lines changed.dependabot.ymlalready coversgithub-actionsand bumps SHA + comment. The Python entry moves frompiptouvso Dependabot updatesuv.locktoo (thepipecosystem does not).Dependency audit (FTM-28)
pip-auditjob inci.ymlrunning.github/scripts/pip-audit.sh:uv export --frozen --all-groups(runtime, dev and docs) audited with a pinnedpip-audit==2.10.1. It fails on any known vulnerability.uvx --python 3.10…3.14, list inPYTHON_VERSIONS). pip-audit evaluates environment markers with its own interpreter and silently skips lines that do not match. A single run on 3.11+ would never check the pins limited to 3.10 (python_full_version < '3.11': 17 packages, includingstarlette==1.7.0,cronsim==2.7,pydantic-settings==2.15.0). The job fails if any single version reports a vulnerability..github/pip-audit-allowlist.txt, one vulnerability ID per line with a mandatory reason comment (currently empty).uv lock --upgrade: before, pip-audit reported 34 findings in 9 packages (starlette, anyio, idna, certifi, urllib3, pydantic-settings, setuptools, pymdown-extensions, mkdocs-material). After:No known vulnerabilities foundon every Python version from 3.10 to 3.14. The upgrade also adds two new transitive packages:opentelemetry-api(required by fastapi 0.162.0) andtzdata(required by python-dateutil 4.0.0, docs group).ruff 0.15.10,ty 0.0.29,redis 7.4.0. Their latest versions break the gate for reasons unrelated to this PR (ruff 0.17 reformats Markdown code blocks and adds PLR0917 intask_group.py; ty 0.0.97 and the redis 8.x type stubs report newbytes | strerrors insrc/). None of the three has a known vulnerability. Adopting them needs changes insrc/and belongs in its own PR.Workflow guard test
tests/test_workflows.py(addspyyaml>=6.0.3to the dev group) fails if:publish.ymlcan be triggered bypull_request,pull_request_targetorworkflow_run;id-token: writeorcontents: writeinpublish.ymldoes not depend, directly or transitively, on thecijob (which must call./.github/workflows/ci.yml);ci.ymlloses itsworkflow_calltrigger;permissions;uses:is not pinned to a full SHA with a# vX.Y.Zcomment;pip-auditjob no longer runs.github/scripts/pip-audit.sh;PYTHON_VERSIONSin the script differs from the union of the Python classifiers inpyproject.tomland the CI test matrix, or the loop stops iterating over the whole list or passing--pythontouvx.These rules apply to every file in
.github/workflows/, including ones added later.Not changed / decisions left open
fastapifloor not raised. Every starlette release before 1.3.1 is affected by at least one advisory (PYSEC-2026-249 affects>=0.4.1,<1.3.1), and every fastapi release from 0.115.13 to 0.162.0 still accepts starlette>=0.40/>=0.46. No fastapi floor can rule out vulnerable starlette. The only option is an explicitstarlette>=1.3.1dependency, which in practice also requiresfastapi>=0.133.0(earlier releases cap starlette below 1.0). That changes the supported range, so it is left to the maintainer. Applications choose their own starlette version anyway; the lock only covers CI and development.Unreleasedsection, and this PR does not change the published package.--resolution lowest-directCI job is not part of this PR.How to verify
Lowest direct versions (fastapi 0.115.13, starlette 0.46.2, redis 6.2.0, pydantic 2.11.7):
uv sync --resolution lowest-directon a scratch clone, thenpytest: 261 passed.Mutations tried (each applied alone;
tests/test_workflows.pywent red every time)pull_request:topublish.ymltriggersbuildneeds: [ci, check-version]→needs: [check-version]actions/checkout@<sha> # v6.1.0inci.yml→actions/checkout@v6permissions:fromci.ymlworkflow_call:fromci.ymlworkflow_dispatch:withworkflow_run:inpublish.yml| M7 |
PYTHON_VERSIONS=("3.10" …→ drop"3.10"| red || M8 | drop
"3.14"fromPYTHON_VERSIONS| red || M9 | loop over
"${PYTHON_VERSIONS[0]}"instead of"${PYTHON_VERSIONS[@]}"| red || M10 |
uvx --python "$python_version" pip-audit…→uvx pip-audit…| red |The pip-audit job was checked against the old lock (exit 1, 34 findings) and the new one (exit 0 on all five versions).
Marker check: in a copy of the script, right after
uv export, the 3.10-only pinstarlette==1.7.0 ; python_full_version < '3.11'was replaced withstarlette==1.3.0(vulnerable, PYSEC-2026-249). The previous single-interpreter script exits 0 on that export ("No known vulnerabilities found"). The new script exits 1 ("Found 2 known vulnerabilities in 1 package" on Python 3.10, clean on 3.11-3.14, then "pip-audit found vulnerabilities on Python: 3.10").Settings the maintainer must change on GitHub / PyPI
These cannot be set from the repository and the workflow depends on them:
pypi: Settings → Environments →pypimainif pre-releases should also come only frommain.PYPI_TOKEN/API-token secret is stored in the environment or the repo (trusted publishing does not need one).fastapi-task-manager→ Manage → Publishing. The GitHub publisher must be: ownerMorry98, repositoryfastapi-task-manager, workflowpublish.yml, environmentpypi. Add the environment name if it is empty, then delete any leftover project API tokens (Account settings → API tokens).main: Settings → Rules → Rulesets → New branch ruleset (or Settings → Branches → Add rule), targetmain:pre-commit,test (3.10),test (3.11),test (3.12),test (3.13),test (3.14),pip-audit. A check only shows in the picker after it has run once, so add them after this PR's first CI run.v*: restrict creation, update and deletion to maintainers, and allowgithub-actionsto create tags (thereleasejob creates them).actions,astral-sh,tox-dev,coverallsapp,pypa).Limitations
mainwith a new version, or a manualworkflow_dispatch.main, CI results now appear under the Publish run (ci / …) instead of a separate CI run. Coveralls still receives themaincoverage from that run (same branch and commit), but this is only confirmed after the first push tomain.permissionsand SHA-pinned actions.--no-deps --disable-pipon the fully pinned export (no hashes), so it prints a warning recommending hashes. This is expected and harmless.🤖 Generated with Claude Code
https://claude.ai/code/session_01HVysDwSu3eNK7jNjrPxgQy