Repository navigation
Workflow python ci
What it does. The CI for a Python project: lint, an optional type check, workflow lint, the
test suite across a matrix of Python versions and runners, an optional run of the tests inside other
distributions' container images, a coverage upload, an optional CLI smoke test, a single-architecture
container build that is run before it is trusted, and two optional pull-request checks. The last job,
CI green, needs every other job and fails if any failed, so branch protection requires one name.
Why it exists. Nine projects each kept their own copy, and every copy had been fixed on its own. The rules that shaped it: the job that runs your tests must not be able to mint a token; coverage must not run beside proposed code; and "passes on my machine" is not a result, so the matrix and the distribution images exist. See Why GYST exists.
| Job | Holds | Notes |
|---|---|---|
lint |
contents: read |
Runs your lint-command
|
typecheck |
contents: read |
Only when typecheck-command is set; part of the gate |
workflow-lint |
contents: read |
actionlint and zizmor over your .github/workflows; turn off on one job when another already runs it |
test |
contents: read, no OIDC token
|
Runs your tests and everything they import. It never holds a token, because that code could mint one |
distro |
contents: read |
Only when distros is non-empty. Runs your install and test commands as root in a throwaway container of a distribution's official image, under its own egress list. The container shares the job's network namespace, so the egress block still applies |
coverage |
contents: read, id-token: write
|
Downloads the report artifact and uploads to Codecov over OIDC. Never runs on a pull request, so nothing your tests execute ever runs beside a token. Coverage therefore appears per push to the default branch, not per pull request |
smoke |
contents: read |
Installs the project and runs smoke-command
|
docker |
contents: read |
Builds the image for one platform, never pushes, runs docker-test-command against it |
fragment-check, commit-claims
|
contents: read |
Pull requests only; see below |
ci-green |
none |
if: always(); fails if any needed job failed or was cancelled, passes on success or a deliberate skip |
jobs:
ci:
uses: ChiefGyk3D/git-your-ship-together/.github/workflows/python-ci.yml@<sha> # vX.Y.Z
permissions:
contents: read
id-token: write # the coverage job declares it; without this the run is a startup_failure with no check
with:
python-versions: '["3.12", "3.13"]' # omit it to test every supported CPython (see below)
test-command: pytest --cov=src --cov-report=xml
egress-policy: blockWhich Pythons the default tests. The default python-versions is every CPython still in security support: 3.11 to 3.15
as of 2026-10-30, each with its end date in .github/python-support.json (3.11 to 2027-10-31, 3.12 to 2028-10-31, 3.13 to
2029-10-31, 3.14 to 2030-10-31, 3.15 to 2031-10-31, from the devguide). Each
version is one Test job per runner, so the default is five jobs on one runner and ten on two. A caller that must keep
supporting an older Python lists it in python-versions; nothing here stops it. tests/test_python_support.py fails when a
listed version is past its end date, so the default shrinks on schedule, and it holds every workflow default and the README
equal to the file. The tool locks behind security.yml and agent-scan.yml stop at 3.14: some locked packages publish
no 3.15 wheel yet.
A smaller matrix on pull requests. Set pr-python-versions: '["3.11", "3.15"]' (the oldest and newest) and a pull request
runs only those Test legs, while push, schedule and dispatch keep running the full python-versions. Add on: schedule to the
caller for a weekly full run. The default is empty, which changes nothing. Each entry must be in python-versions, and with
coverage-threshold set coverage-python-version must be an entry too; the job fails with an error otherwise. CI green still
needs test, so a failed leg still blocks the merge. Require ci / CI green, not individual Test (Python ...) checks, since the
legs a pull request creates differ from the ones main creates.
Point branch protection at ci / CI green. A repository with more than one language calls one CI workflow per language
from one job each and requires each gate (ci / CI green and shell / CI green, say).
The grant that fails silently. GitHub validates a called workflow's declared permissions at startup, before any if. A
caller that pins permissions: contents: read makes the coverage job's id-token: write impossible, and the run ends
startup_failure with no check run at all. Nothing is red; the required check never appears. Measured on two callers
on 2026-10-03, which then merged without a gate (issue #74, closed: the Troubleshooting page now has the
row, and a test checks that the example grants every permission the workflow declares).
-
Kali and Parrot are pinned.
kalilinux/kali-rollingandparrotsec/coreuse redirectors that answer each request with a different mirror, which a block list cannot follow. The defaultdistro-setup-commandrewrites Kali's sources tokali.downloadand Parrot's todeb.parrot.sh/direct/parrot, each one name. -
Fedora is not on the list.
dnftakes its mirror from a metalink answer that varies per run, so a caller testingfedora:*setsdistro-egress-policy: auditor adds the mirrors it observed. Thedistrolists were measured in block mode on Debian 12 and 13, Ubuntu 24.04, Kali and Parrot, both runners. -
Distribution coverage: Ubuntu, Xubuntu, Kubuntu and Pop!_OS are covered by
ubuntu:24.04(same userland); Raspberry Pi OS bydebian:12ordebian:13withubuntu-24.04-arm(same userland, same architecture, not a Pi); Qubes has no userland of its own, sodebian:13andfedora:42cover its templates. -
Pull-request checks.
fragment-check-commandandcommit-claims-commandrun your own scripts on pull requests, with full history and the base branch and head commit as environment variables. They exist for repositories whose changelog is one file per change and whose commit messages make claims a diff can check ("adds a test"). Neither is worth turning on without a script of your own. -
Workflow lint under
blockneedsregistry.npmjs.orgfor actionlint, so the default list carries it; before that it was an entry every caller added by hand (issue #65).
Inputs (42), read from python-ci.yml:
| Input | Type | Default | Meaning |
|---|---|---|---|
python-versions |
string | ["3.11", "3.12", "3.13", "3.14", "3.15"] |
JSON array of Python versions for the test matrix. The default is the CPython versions still in security support (.github/python-support.json in this repository). |
pr-python-versions |
string | empty | JSON array of Python versions the test matrix runs on a pull request (for example ["3.11", "3.15"], the oldest and the newest). Empty, the default, runs python-versions on every event. Push, schedule and dispatch always run the full python-versions, so a caller wanting the full matrix weekly adds a schedule trigger. Every entry must be in python-versions; with coverage-threshold set, coverage-python-version must be an entry too. |
coverage-python-version |
string | 3.13 |
The matrix leg that uploads the coverage report. |
install-command |
string | python -m pip install --upgrade pip pip install -r requirements.txt |
Shell run before tests on every matrix leg. |
test-command |
string | pytest |
Shell that runs the test suite. |
xdist |
boolean | false |
Run the test job's pytest in parallel with pytest-xdist. Installs pytest-xdist (the one version locked with hashes in this workflow, with execnet; no input changes it) after install-command and sets PYTEST_ADDOPTS=-n <xdist-workers> for the test-command step, so it reaches every pytest in the command and nothing else, whatever else the command chains (scripts, checks) and however pytest is spelled (pytest, python -m pytest, python -I -m pytest). Only the test job; the distro job runs the command as written. Off by default, so a caller that sets nothing is unchanged. Tests must not share state (a fixed port, one file path) to run under it. |
xdist-workers |
string | auto |
Worker count with xdist - auto (one per CPU), logical (one per logical CPU) or a whole number. Anything else fails the job. |
coverage-file |
string | coverage.xml |
Coverage report path uploaded as an artifact when present. |
coverage-threshold |
string | empty | Minimum total line coverage, a percentage such as 85; the test job fails below it. Read from coverage-file (Cobertura XML, which coverage.py and pytest-cov write) on the leg that uploads it, so the test command must produce that file. Empty skips the check. |
codecov |
boolean | false |
Upload the coverage report to Codecov over GitHub OIDC; no Codecov token is stored anywhere. The repository must be enabled in the Codecov GitHub App. |
lint-python-version |
string | 3.13 |
Python used for the lint job. |
lint-install-command |
string | pip install "ruff==0.17.3" |
Shell that installs the linters. The default pins ruff: an unpinned install turned every caller's lint red on the day ruff 0.17.0 changed its default target version (2026-10-09). Move the pin here, deliberately, with a release. |
lint-command |
string | ruff check . |
Shell that lints. A non-zero exit fails the job unless lint-continue-on-error is set. |
lint-continue-on-error |
boolean | false |
Report lint failures without failing CI. A migration aid, not a resting state. |
typecheck-install-command |
string | empty | Shell that installs the type checker and whatever it needs to resolve imports, e.g. pip install mypy==2.4.1; empty installs nothing. Runs on lint-python-version. |
typecheck-command |
string | empty | Shell that type-checks, e.g. mypy src; empty skips the Type check job. |
fragment-check-command |
string | empty | Shell run on pull requests only, with the full history checked out and BASE set to the pull request's base branch name (so origin/$BASE resolves); empty skips the Changelog fragment job. For a repository that keeps one changelog fragment per change under changelog.d/, e.g. python3 scripts/changelog.py check-pr --base "origin/$BASE". Part of the gate when set. |
commit-claims-command |
string | empty | Shell run on pull requests only, with the full history checked out, BASE set to the base branch name and HEAD to the pull request's head commit; empty skips the Commit claims job. For a repository that checks what each commit message claims against its diff, e.g. python3 scripts/check_commit_claims.py --range "origin/$BASE..HEAD". Part of the gate when set. |
smoke-command |
string | empty | Shell run after smoke-install-command on coverage-python-version; empty skips the job. |
smoke-install-command |
string | pip install . |
Shell that installs the project for the smoke test. |
docker-build |
boolean | true |
Build the container image (single platform, never pushed). |
dockerfile |
string | Dockerfile |
Path to the Dockerfile. |
docker-context |
string | . |
Build context. |
docker-test-command |
string | empty | Shell run against the built image; $IMAGE names it. Empty skips the check. |
workflow-lint |
boolean | true |
Run actionlint and zizmor over the caller's own .github/workflows. |
zizmor-persona |
string | regular |
zizmor strictness - regular, pedantic or auditor. |
runners |
string | ["ubuntu-24.04"] |
JSON array of runner labels for the test matrix, e.g. ["ubuntu-24.04", "ubuntu-24.04-arm", "macos-15", "windows-2025"]. The first entry also uploads the coverage report. A Windows runner runs the commands under bash. |
distros |
string | [] |
JSON array of container images to run the tests in as well, e.g. ["debian:13", "kalilinux/kali-rolling"]. GitHub-hosted runners are Ubuntu, macOS and Windows only; another distribution is tested inside its official image on a runner. [] skips the job. |
distro-runners |
string | ["ubuntu-24.04"] |
JSON array of runner labels the distros run on. Add ubuntu-24.04-arm to run the images natively on arm64. |
distro-setup-command |
string | export DEBIAN_FRONTEND=noninteractive if command -v apt-get >/dev/null 2>&1; then # Kali's redirector hands out a different mirror per request, which # no egress list can follow; the CDN host it fronts is one name. if grep -qx 'ID=kali' /etc/os-release; then sed -i 's|http://http.kali.org|http://kali.download|g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true fi # Parrot's package redirector (director.parrot.sh) does the same; # its /direct path serves the pool from deb.parrot.sh itself. if grep -qx 'ID=parrot' /etc/os-release; then sed -i 's|https://deb.parrot.sh/parrot|https://deb.parrot.sh/direct/parrot|g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true fi # A mirror that answers 502, or is caught mid-sync (Kali's "File has # unexpected size", #228), is not retried by apt itself, so the whole # step is tried six times with a growing pause (20 s up to 60 s). The # package lists are cleared between tries so a partial index is never # reused; the last failure exits non-zero with apt's own error shown. for attempt in 1 2 3 4 5 6; do apt-get -o Acquire::Retries=3 update -qq && apt-get -o Acquire::Retries=3 install -y -qq --no-install-recommends python3 python3-venv python3-pip git ca-certificates && break if [ "$attempt" = 6 ]; then echo "apt-get still failing after 6 attempts" >&2 exit 1 fi rm -rf /var/lib/apt/lists/* sleep $((attempt * 20 > 60 ? 60 : attempt * 20)) done elif command -v dnf >/dev/null 2>&1; then dnf install -y -q python3 python3-pip git ca-certificates fi |
Shell run as root inside each image before the install command. The default installs python3, python3-venv, python3-pip, git and ca-certificates with apt-get where it exists, else with dnf; non-interactive and quiet. The install and test commands then run in a fresh virtual environment. |
distro-egress-policy |
string | block |
harden-runner egress policy for the distro job - audit logs outbound connections, block allows only distro-allowed-endpoints and extra-allowed-endpoints. |
distro-allowed-endpoints |
string | archive.ubuntu.com:80 auth.docker.io:443 deb.debian.org:80 deb.parrot.sh:443 docker-images-prod.s3.dualstack.us-east-1.amazonaws.com:443 files.pythonhosted.org:443 kali.download:80 ports.ubuntu.com:80 production.cloudfront.docker.com:443 pypi.org:443 registry-1.docker.io:443 security.ubuntu.com:80 |
harden-runner allow-list for the distro job in block, space-separated host:port entries. The default is Docker Hub's image pull (registry, auth, CDN and the S3 host layer blobs redirect to), the package mirrors of the Debian, Ubuntu, Kali and Parrot images, and the PyPI hosts the install command reaches. A distribution not named here (Fedora, whose metalink mirrors vary by run) needs its hosts in extra-allowed-endpoints, or distro-egress-policy set to audit. Wildcards are not supported and a newline-separated list matches nothing. |
distro-continue-on-error |
boolean | false |
Let a failing distro run leave the gate green. For a suite that assumes a non-root user or a newer Python than the distribution ships; the result stays visible on the job. |
egress-policy |
string | audit |
harden-runner egress policy for every job except distro - audit logs outbound connections, block allows only allowed-endpoints. Jobs that hold no secret follow egress-policy-secretless instead (EX-0001). |
egress-policy-secretless |
string | block |
harden-runner egress policy for the jobs that hold no stored secret, no OIDC token and no write-scoped or publish-capable token (read-only contents, a SARIF upload at most), and whose output no privileged job consumes - exactly audit or block. Defaults to block since security exception EX-0001 (GitHub-hosted runners in westus2 broke harden-runner block) was closed on 2026-11-02 after harden-runner v2.22.3 passed on westus2; see docs/security/exceptions/. Every job still has the default read-only job token. Set audit to opt out if the defect recurs. Any other job follows egress-policy. Any other value fails the job. |
allowed-endpoints |
string | api.doppler.com:443 api.github.com:443 auth.docker.io:443 cli.codecov.io:443 deb.debian.org:80 files.pythonhosted.org:443 ghcr.io:443 github.com:443 ingest.codecov.io:443 keybase.io:443 pkg-containers.githubusercontent.com:443 production.cloudfront.docker.com:443 pypi.org:443 raw.githubusercontent.com:443 registry-1.docker.io:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 storage.googleapis.com:443 |
harden-runner allow-list for block, space-separated host:port entries. The default is every endpoint this workflow's jobs reached in audit mode across the calling repositories; the runner's own infrastructure needs no entry. Wildcards are not supported and a newline-separated list matches nothing. |
extra-allowed-endpoints |
string | empty | Appended to allowed-endpoints, for hosts only this repository reaches, such as an apt repository its Dockerfile adds. Same format. |
doppler-project |
string | empty | Doppler project slug. |
doppler-config |
string | empty | Doppler config slug holding CI secrets. |
doppler-identity-id |
string | empty | Doppler Service Account Identity UUID for OIDC. |
doppler-trusted-refs-only |
boolean | true |
Fetch CI secrets only on the default branch, a version tag (vN.N.N) or a schedule; never on a pull request or another branch. false restores fetching on every same-repository run. |
timeout-minutes |
number | 15 |
Per-job timeout. |
Secrets a caller may pass, by name:
| Secret | Required | Meaning |
|---|---|---|
DOPPLER_TOKEN |
no | Doppler Service Token fallback when OIDC is not configured. |
It never gives the test job a token, never uploads coverage from a pull request, never pushes the image it builds, and never
lets a failed job leave CI green passing.
Generated from docs/wiki/ at commit f3af2fa0bae3. Do not edit this wiki: the next push to main replaces every page. Corrections go to docs/wiki/ by pull request.
GYST
- Home
- Why GYST exists
- Getting started
- Design rules
- Secrets: Doppler and OIDC
- Security scanning explained
- The baseline and the weekly audit
- Releases and supply chain
- Keeping a project board current
- Adopting GYST in your own project
- Glossary
- Roadmap
Learn and contribute
- Learning path
- Which workflow do I need?
- Repository map
- Egress control
- Troubleshooting
- Lessons learned
- Testing and the contract
- Contributing and developing
- Maintaining this wiki
- Verify main
- FAQ
CI
Security
Release
- container-release
- python-docker-release
- python-package-release
- artifact-release
- verify-published
- base-image-digest
Docs and project
- docs-pages
- wiki-publish
- project-sync
- threat-model
- lory-audit
- agent-scan
- token-drift
- node-typecheck
- pr-title-lint
- vendored-drift
- upstream-sync
- repin
- pin-comments
Tools