GitHub Actions
The repository is also a GitHub Action. Pin it to a full commit SHA. A gate
installed from main pins it to the commit your composer.lock holds, as
init --ci=github does, and the action runs the copy of the gate your
composer.json requires. A release has its own tag, such as v0.1.0,
written in a comment after the SHA, and the release workflow moves the tag of
its line, v0.1, to each new release of 0.1.
One action in two jobs, for most projects
In the first job the action sets up PHP, installs your dependencies, keeps the
proof ledger in the Actions cache and runs the whole gate. It writes line
annotations and the step summary, and holds no token once your code runs. In
the second job, with deliver: 'true', it runs none of your code. It posts
the sticky PR comment and, on a trusted run, writes the ledger to the store
MUTATION_GATE_STORE names, where it names one. Its steps run python3, jq,
gh and, for the PHAR, gpg, which GitHub's hosted runners hold; a
self-hosted runner needs them on its PATH.
name: mutation
on:
pull_request:
merge_group: # runs only where the default branch has a merge queue
push:
branches: [main] # your default branch
schedule:
- cron: '0 3 * * 1'
permissions:
contents: read
concurrency: # cancels only a pull request's older runs: see Concurrency below
group: mutation-${{ contains(fromJSON('["pull_request","push"]'), github.event_name) && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
mutation:
name: mutation / verdict # the check ci.check names by default
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@<sha> # <tag>
with:
fetch-depth: 0
persist-credentials: false
- uses: nightworksio/php-mutation-gate@<sha> # the commit of main composer.lock holds
with:
php-version: '8.5'
# Sends what the run left: the pull request comment, and on a trusted run
# the ledger a store keeps. It checks nothing out and runs none of the
# project's code.
deliver:
needs: mutation
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
permissions:
contents: read
actions: read # the comment links the run's HTML report
pull-requests: write
id-token: write # only for a store that signs in through OIDC
steps:
- uses: nightworksio/php-mutation-gate@<sha> # the commit of main composer.lock holds
with:
deliver: 'true'
php-version: '8.5'| Input | Default |
|---|---|
config | the config file the gate finds |
php-version | 8.5 |
extensions | none; PHP extensions to set up besides setup-php's defaults, such as zstd, which the gate packs its ledger with where it is loaded (proofs.compression), or ones the project's suite needs |
ini-values | none; PHP ini values to set, as setup-php takes them, such as memory_limit=2G |
runner | the config's, or the one installed |
shard | none: the whole gate runs |
leftover | none: the shard itself; with shard, the share of the mutants that shard left at its deadline to judge, as leftovers cut them (ADR-0190) |
mode | auto: change-scoped on pull requests, merge groups and pushes, full on schedules, manual runs, releases and tags; or full, or changed, or sampled: what auto considers, with the units no run knows exactly sampled, as --sample asks |
changed-since | on pull_request, the commit its merge checkout merges it onto, the merge's first parent, which is where its base branch stands now (its base's sha where the checkout is no merge); the group's merge_group.base_sha on merge_group, the default branch on any other branch, last-passed on the default branch; used when the mode is change-scoped |
budget | none |
reports | none; <name>:<path> lines, such as sarif:build/mutation.sarif |
cache | true: keep the ledger in the Actions cache |
merged-records | true: keeps a passing pull request's pass as an artifact and reads it on the push that merged it or a merge group built for it, which reuse.identical needs where the Actions cache keeps the ledgers; the job needs actions: read and pull-requests: read, without which no pass is read and the run warns so |
merged-records-days | 30: how many days that pass stays readable; a merge later than that is judged again |
deliver | false; true in a job of its own, after the run's, to send what the run left |
install | auto: the project's own copy where its composer.json requires nightworksio/mutation-gate, the release's PHAR where it does not; or composer, or phar |
judge | none; a judge's PHAR to run in the place of the gate install chooses, as the reusable workflow's judge job leaves it (ADR-0140) |
prepare | none; a shell command run right after the project's dependencies install, with no secret, such as an install the tests need besides them (ADR-0151) |
composer-auth | none; the credentials Composer installs the project's dependencies with, as COMPOSER_AUTH holds them, for a private repository. Pass a secret: only the install step reads it, and that step runs the project's Composer scripts and plugins, which can read it |
A project that does not require the gate with Composer, such as one whose
constraints conflict with the gate's, runs the release's PHAR, which needs the
action pinned to a release. The action reads which release from the ref it is
pinned to: a release's tag, its line's tag, or the commit a release's tag
points at. It downloads that release's mutation-gate.phar and mutation-gate.phar.asc,
checks that the release key whose fingerprint
SECURITY.md names signed it, and
that release.yml attested it for that tag, before the project's
dependencies install. It runs nothing that fails either check. A ref that is
no release refuses, as does the Pest runner, which only the Composer package
runs: require the gate with Composer to run either
(ADR-0051).
Its outputs are verdict (passed, failed or cannot-judge), scores
(JSON), report-paths (JSON) and plan (JSON). The one-step action writes
the badge and trend to .mutation-gate/publish but does not publish them,
because that needs contents: write in a job that also runs on pull requests.
The reusable workflow publishes them.
The run's job runs the project's tests, so it holds no token and no secret:
any step after the tests can be changed by them. What needs a credential, the
pull request comment and the ledger a store keeps, it leaves as the artifact
mutation-gate-delivery. The deliver job sends it with the job's token,
running the gate from its own copy at the action's path, never from the
project's vendor. That copy holds the gate's runtime packages and the S3
store's client, installed from the lock under resources/action/keyed with
no scripts or plugins; without that lock it installs nothing.
The directory store is the Actions cache, which the run's job keeps itself, so
a project that keeps its ledger there needs only that token.
For an S3 store, add AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as secrets
of the environment mutation-gate-store, whose deployment branches are the
default branch alone, name the store in the repository variables
MUTATION_GATE_STORE and its location, as for the reusable workflow below, and
hand them to the deliver job's step. Azure and GCS sign in through GitHub's
OIDC instead, from the repository variables AZURE_TENANT_ID and
AZURE_CLIENT_ID, or MUTATION_GATE_GCS_PROVIDER and
MUTATION_GATE_GCS_SERVICE_ACCOUNT. The job init --ci=github --single
writes enters that environment on a push, a schedule or a manual run of the
default branch, and none on any other run, so a pull request's run reads the
store through proofs.store.with.publicUrl. A branch can edit the workflow,
so the environment's restriction, not the job's condition, keeps the keys from
other branches.
Sharded, for large projects
The reusable workflow runs a plan job, one shard job per shard and a
verdict job. Once a confirmed survivor leaves a pull request's run no way to
pass, its shard's job fails, as run.failFast says: by default after judging
every unit, so the verdict names every survivor; under stop at once; and
under cancel at once, with GitHub cancelling the other shards of the matrix.
The verdict still runs and fails, naming the survivor. A shard's gate stops
at shards.target, ten minutes by default, less the setup its job took
before the gate started, the wind-down recent gates took and
shards.margin
(ADR-0196);
a leftovers job then cuts the mutants
each shard left into shares, each predicted to fit a job of the same stop
where 256 shares, the most a matrix holds, can hold them all, and one leftover job per share judges them as the shard would have, its
result read by the verdict beside the shards'
(ADR-0190).
A last job, publish, runs on the default branch only and
publishes the badge and trend.
name: mutation
on:
pull_request:
merge_group: # runs only where the default branch has a merge queue
push:
branches: [main] # your default branch
schedule:
- cron: '0 3 * * 1'
permissions:
contents: read
concurrency: # cancels only a pull request's older runs: see Concurrency below
group: mutation-${{ contains(fromJSON('["pull_request","push"]'), github.event_name) && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
mutation:
uses: nightworksio/php-mutation-gate/.github/workflows/mutation-gate.yml@<sha> # the commit of main composer.lock holds
permissions:
contents: write # used only by publish, on the default branch, which writes the badge and the trend
actions: read # used only by verdict and deliver, to find the run's HTML report the comment links
pull-requests: write # used only by the deliver jobs, which post the comment and run none of the project's code
id-token: write # used only by fetch and deliver, for a store that signs in through OIDC
with:
php-version: '8.5'
secrets:
MUTATION_GATE_READ_AWS_ACCESS_KEY_ID: ${{ secrets.MUTATION_GATE_READ_AWS_ACCESS_KEY_ID }}
MUTATION_GATE_READ_AWS_SECRET_ACCESS_KEY: ${{ secrets.MUTATION_GATE_READ_AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}It takes the action's inputs less shard, deliver, install,
composer-auth and the action's judge, and its own: coverage, judge,
runs-on, keyed-runs-on, plan-timeout (60), shard-timeout (360),
verdict-timeout (30) and download-timeout (2), how long each artifact
download may take before it is tried once again, each in minutes,
keep-logs (false), with which each shard's job and each job of the wave
after uploads the JUnit logs of the unmutated runs behind its kills as
mutation-gate-logs-*, kept one day, as the repository variable
MUTATION_GATE_KEEP_LOGS set to true does without a change to the caller,
plan-coverage (pcov), the driver
the plan sets up, publish-branch (mutation-gate), where publish writes
the badge and trend, early-only (false), with which the plan plans
nothing, and says why, where a full split-stream run cannot start without a
fresh map or the kept map cannot plan it (ADR-0320), job-started (empty), when the shard's job began, as seconds
since the epoch, which its stop is read from (ADR-0196), watch-jobs
(empty), the names of jobs of the calling run,
one per line, whose failure stops each shard before its next item
(ADR-0135), and gate-pcov (off), with which the gate's own PHP process
plans and runs each shard with pcov.enabled=0, as every process it
starts keeps PHP's own settings; on keeps pcov there (ADR-0186). It runs the copy of the gate the project requires with
Composer, or the gate judge names (ADR-0140), and its cache is a
boolean, where the action's is the text true or false.
Its outputs are verdict, scores, plan and suite, true
where a full early run's streams left how the suite ran in them as the
artifact mutation-gate-suite, and it uploads the reports as the artifact
mutation-gate-reports.
A project whose dependencies come from a private Composer repository passes
the credentials Composer installs with as the secret COMPOSER_AUTH, a
repository secret, since every job that runs the project's code installs it:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} under secrets. Only the step
that installs the project's dependencies reads it, in each of those jobs; the
tests, the mutants and the gate's own commands run without it. That step runs
the project's Composer scripts and plugins, which can read it, so give it
credentials that only read packages
(ADR-0029).
With the one-step action, pass it as the input composer-auth.
A project whose tests need more than its dependencies, such as a fixture
project of their own with a composer.json of its own, names the command
that installs it as prepare, such as
prepare: composer --working-dir=tests/fixture install. Each job that
installs the project's dependencies runs it right after them, under
bash -euo pipefail, so any part of it that fails fails the job. It runs
with no secret, like the tests.
A project whose tests reach a server, such as a database, names the
containers as services, a JSON object in the shape jobs.<job_id>.services
takes, and the plan, shard, leftover, survivors, survivors-report
and verdict jobs each start them
(ADR-0153).
Under services-start: background, the default, a job starts every
container at once, detached, before PHP, the dependencies or any of the
project's code, masking a private image's password and the services' env
values, and pulling a private image under a Docker config it removes at once;
it leaves only a list of the containers' names. Right before the project's
prepare or the gate, it waits, in a shell that inherits nothing of the
job's environment, for each container to report healthy, or to run where it
has no health check; one that exits, is unhealthy or is not healthy within
300 s fails the job with its log. services-start: job has the job's
services start them before its first step, one after another, as GitHub
starts them; use it where a step reads job.services, which the background
start leaves empty
(ADR-0189).
Pin each image by digest, publish a port the tests know, and hand the
address on through prepare, which writes it where the later steps read
it:
with:
services: >-
{"postgres": {"image": "postgres:17@sha256:<digest>",
"env": {"POSTGRES_HOST_AUTH_METHOD": "trust"}, "ports": ["5432:5432"],
"options": "--health-cmd=\"pg_isready --username=postgres\" --health-interval=5s --health-retries=30"}}
prepare: echo "DATABASE_URL=pgsql://postgres@127.0.0.1:5432/app" >> "$GITHUB_ENV"Service containers run on Linux runners only.
The plan, shard, leftovers, leftover, survivors, survivors-report
and verdict jobs run on ubuntu-latest unless runs-on names another runner: a label, such as
runs-on: ubuntu-24.04-arm, or a JSON list of labels a runner must all have,
such as runs-on: '["self-hosted", "linux"]'. They all run on it, because a
proof's key holds the machine's architecture. Changing the architecture makes
the next run carry no proofs. The jobs that hold a key or a token that writes,
fetch, the deliver jobs and publish, run on keyed-runs-on, also
ubuntu-latest by default and named the same way
(ADR-0039).
A self-hosted runner that is not ephemeral keeps what one job left for the
next, so a pull request's code that ran on it can reach a later job's keys.
Where runs-on names such a runner, keep keyed-runs-on on a GitHub-hosted
or an ephemeral one. With the one-step action, the same holds for the
deliver job's runs-on: never put it on a persistent runner that runs pull
requests' code. The one-step action runs on its own job's runs-on.
judge has another build of the gate judge the run, in the place of the
project's own copy
(ADR-0140).
release takes the newest signed release's judge, verified by its signature
and its attestation as the release's PHAR is, and a commit or tag of
nightworksio/php-mutation-gate builds the judge there. Only the gate's own
repository names merge-base, which builds it where the change branched, or
else at its base, or else takes the newest signed release's. The gate's own CI
passes merge-base on pull requests, and a push is judged by its own build.
Under a judge, a reach.everything glob whose files are all the gate's own
reaches nothing by itself, since the judge runs in their place; the plan names
each one it leaves out.
A judge job builds it once a run, cached by
commit, and the plan, shards, survivors and verdict run it. The judge's
classes sit under a namespace of their own, so it runs beside the project's
copy, and its Pest plugin takes the place of the copy's in every Pest process.
It brings the first-party extensions itself; an extension of the project's
own implements the gate's interfaces, not the judge's, so a project that
registers one runs without a judge.
By default the plan job runs the suite under coverage itself. Where a job of
yours runs it under coverage already, it can hand its map over instead, so the
suite runs once: add --coverage-php=<dir>/coverage.php to that run, then run
vendor/bin/mutation-gate coverage --from=<dir> --into=<map dir> in the same
job, upload <map dir>/map.json.gz as an artifact, and name that artifact in
coverage. The calling job then needs that job. The gate reads the runner's
report only in the job that wrote it, since reading one can run code; the map
it hands over is the gate's own JSON.
Pest's --coverage, which --min needs, writes its PHP report to a path of
its own, Pest\Support\Coverage::getPath(), in place of yours, and deletes it
once it has printed its summary. To keep it, create <dir>/coverage.php empty
before the run and hard-link Pest's path to it, as this package's own CI does:
report=$(php -r 'require "vendor/autoload.php"; echo \Pest\Support\Coverage::getPath();')
mkdir -p <dir> "$(dirname "${report}")"
: > <dir>/coverage.php
ln -f <dir>/coverage.php "${report}"
vendor/bin/pest --coverage --min=100A called workflow's job reads an environment's secret only under a name its caller passes. So the call passes each secret the store needs under its own name, as above, and never inherits them all, which would hand on every secret the repository holds. Each value comes from the environment of the one job that reads it, which wins over anything the caller passes, so these secrets stay in the environments below and never in the repository. The alerts and the trace are passed the same way, under the names listed in step 3.
The plan, shard, leftovers, leftover and verdict jobs run the
project's own code, so they hold no secret and no token that can write. Whatever needs a credential runs in a
job that installs none of the project's code and runs the gate from its own
installation, at the workflow's commit:
fetchreads the default branch's ledger from the proof store, and hands it to the plan and the verdict as the artifactmutation-gate-fetched-<attempt>, which they read from.mutation-gate/fetched, beside the copy the Actions cache keeps, so the project's config keepsproofs.storeatdirectory. Where both copies are there,proofs.copiessays which the run reads. It runs where the repository variableMUTATION_GATE_STOREnames a store, in the environmentmutation-gate-read.deliver-planposts the pull request comment's planned state, which the plan leaves as the artifactmutation-gate-delivery-plan-<attempt>.- On a pull request whose plan cuts a shard,
survivorsruns the last run's survivors again beside the shards, in as many jobs as the plan names: one per file of survivors, at mostsurvivorsFirst.shards. Each takes its share of the files withinsurvivorsFirst.budgetand leaves what it made as the artifactmutation-gate-survivors-<attempt>-<share>.survivors-reportpairs those with the survivors, says which no job reached, and leaves the comment's survivors re-checked state as the artifactmutation-gate-delivery-survivors-<attempt>, whichdeliver-survivorswrites over its planned one. The verdict judges nothing they found (ADR-0106). deliversends what the verdict leaves as the artifactmutation-gate-delivery-<attempt>. On every run it posts the comment. A trusted run, a push, schedule or dispatch on the default branch, enters the environmentmutation-gate-store, and there it also writes the ledger, whereMUTATION_GATE_STOREnames a store, sends the alerts and exports the trace. With no store named, the ledger stays in the Actions cache. GitHub refuses that environment to a run on any other branch, even one whose workflow names it.
<attempt> is the attempt of the run whose job wrote the artifact, and each
shard's result, mutation-gate-result-<attempt>-<shard>, carries its plan's.
Every job reads the attempt the job that wrote it gives. So Re-run all jobs
judges only what the new attempt wrote, and Re-run failed jobs judges what
the jobs it ran again wrote beside what the jobs it kept wrote. Each result
keeps beside it the attempt whose shard job wrote it, and the verdict lists
its attempt's jobs: a shard whose job ran again and wrote no result has its
earlier result removed, with an error saying so, and the verdict cannot judge
the run without it.
To keep the ledger in S3, R2 or MinIO, set these under Settings:
- Repository variables:
MUTATION_GATE_STOREset tos3, and the store's location,MUTATION_GATE_STORE_BUCKET,MUTATION_GATE_STORE_PREFIX,MUTATION_GATE_STORE_REGIONand, for R2 or MinIO,MUTATION_GATE_STORE_ENDPOINT, anhttps://URL. A location is no secret. The two jobs read it from these variables alone, never from a run of the project's code. - The environment
mutation-gate-read, with no deployment branch rule and the secretsMUTATION_GATE_READ_AWS_ACCESS_KEY_IDandMUTATION_GATE_READ_AWS_SECRET_ACCESS_KEY. Their key may only read the default branch's ledger:s3:GetObjecton<bucket>/<prefix>/refs/heads/<default branch>/*. Every run holds it, a pull request's among them. A fork's pull request is given no secret, and reads throughproofs.store.with.publicUrlinstead. - The environment
mutation-gate-store: under Deployment branches and tags choose Selected branches and tags, and add the default branch's name as its one rule. Its secrets areAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYand, for temporary keys,AWS_SESSION_TOKEN, whose key may read and write the default branch's ledger alone:s3:GetObjectands3:PutObjecton<bucket>/<prefix>/refs/heads/<default branch>/*. For alerts and traces, addMUTATION_GATE_SLACK_URL,MUTATION_GATE_DISCORD_URL,MUTATION_GATE_WEBHOOK_URL,MUTATION_GATE_WEBHOOK_SECRET,OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_EXPORTER_OTLP_HEADERSthere too.
Add the secrets to the environments, never to the repository: a repository secret reaches a run on any branch.
A public repository may read the ledger without a key instead: make the
default branch's prefix public in the bucket policy, set
proofs.store.with.publicUrl, and give mutation-gate-read no secrets. The
plan and the verdict then read the ledger through that URL, and fetch hands
over none.
GitHub may give a scheduled run no default branch name. Set the repository
variable MUTATION_GATE_DEFAULT_BRANCH to that name, and a scheduled run reads
it there. Without either, a scheduled run holds no secrets and says so in the
deliver job's summary.
The reusable workflow reaches S3 with those key secrets only. To assume an AWS
role through OIDC instead, use the action's two jobs: the deliver job already
has id-token: write, so add aws-actions/configure-aws-credentials before
the action there, and trust the role as described above: an environment only the
default branch may deploy to, or the job's job_workflow_ref.
Sharding with a matrix of your own
In a workflow of your own, plan --ci=github appends three step outputs to the file GITHUB_OUTPUT
names:
shards, a JSON array of{id, label}, one per shard, which a matrix reads withfromJson(needs.plan.outputs.shards);plan, the plan on one line;stands,truewhere the verdict of a commit that passed stands for the plan, which runs nothing, andfalseelsewhere (ADR-0062). The verdict then reads no shard's result and no coverage map.
An empty array skips the matrix job, and the verdict still runs. A matrix
runs at most 256 jobs, so a plan with more shards cannot be judged; set
shards.max to 256 or less.
Run the verdict even when a shard job failed (if: always()), so a missing
result is judged cannot judge (exit code 2) rather than skipped. Check out
with fetch-depth: 0: a kill proved at an earlier commit carries only where
the clone holds that commit.
What the gate writes under GitHub Actions
These reporters run on their own under GitHub Actions (reports):
github-annotations: line annotations, changed lines first.github-summary: the step summary, with every mutant counted as not killed.github-comment: one sticky comment on the pull request, updated in place. It needsGITHUB_TOKENandpull-requests: write. Its verdict links the run's HTML report: the artifactmutation-gate-report.html, which the action and the reusable workflow upload unarchived, so the link opens the page. It is found as the comment is written, withactions: read, so a comment updated in place links the run that wrote it. Where the run holds no such artifact, the comment says why instead. Where the project has a CODEOWNERS, it mentions each user and team in the update that first gives their code a survivor on a changed line, and never again on that pull request. Written withGITHUB_TOKEN, it names teams without a mention, since that token cannot read an organisation's teams;owners.mention: nevermentions no one (survivors and their owners).Runner time: the reusable workflow's verdict reads what each job of its run took, so the headline says exact runner time. The one-step action runs in one job, and reads none, so its headline says
(estimated), from the flows' own timings andshards.setup. Its cost section also says the minutes GitHub bills for the run's jobs, each rounded up to a whole minute, against what the plan expected, priced atcosts.perRunnerMinutewhere it is set (ADR-0240).badge: on the default branch,badge.json,trend.json,trend.svg,savings.jsonandsummary.json, what an organisation's dashboard reads, in--publish-dir(.mutation-gate/publishby default). Publishing that directory is up to your workflow. Published to a branch namedmutation-gate, the badge reads:
To see survivors in code scanning, add a sarif report and upload it with
github/codeql-action/upload-sarif.
Branch protection
Require the verdict's check in the default branch's protection rule. The
verdict reports under ci.check, mutation / verdict by default: the
action's first job above is named so, and the reusable workflow's verdict job
shows as <calling job> / verdict. It is the check through which a merged
pull request's verdict proves its commit, so a job named otherwise needs
ci.check set to its name. The verdict says cannot judge (exit code 2)
when the plan could not judge, or when any planned shard left no result. The
reusable workflow's verdict then names how each such shard's job ended: its
runner shut down or lost, cancelled once another shard failed, past its time
limit, or failed.
Run it on a schedule as well: the full run, weekly in the examples, which ci.schedule sets for init --ci. A reusable workflow cannot hold a trigger, so the schedule goes in the workflow that calls it.
Merge queues
With a merge queue on the default branch, GitHub reports a required check
only for a workflow that runs on merge_group, which every example here and
init --ci=github lists; the trigger fires only where a queue is on
(ADR-0022).
The required check stays the one ci.check names.
A group's run judges the commit the queue built, which holds the default branch, the pull requests ahead of it and its own:
mode: automutates what changed sincemerge_group.base_sha, the commit the queue built the group on, and holds the group's changed lines to the floor for new code, as a pull request's are.- The group has no proof scope. It reads the default branch's ledger alone, writes none, saves no ledger to the Actions cache, and posts no comment.
- A raise is reported, not required, since nothing can be committed to a group. A floor lowered without its reason fails it, as it fails a pull request.
Under reuse.identical, on by default, a group whose run reads inputs
identical to those its pull request's passing run read reuses that verdict
and plans nothing; any other group borrows that run's results, each of
which proves a unit only where its key matches, and is judged from its base
(ADR-0198). A pass from a fork's pull request is read only under
reuse.forks: true. Under reuse.delta: true, a group whose commit holds exactly the tree of its pull request's head, where
that pull request's verdict passed on that head, reaches nothing but the
units reuse.ownScopeProofs leaves to run again, and the push to the
default branch after the queue merges reaches nothing for a commit on which
a group's verdict passed
(ADR-0049).
An organisation's dashboard
mutation-gate dashboard --org=<org> --out=<dir> builds one page of every
repository of an organisation that published a summary, with its verdict,
score and trend, the trees below their floors, the time the gate saved
it in its costs.savingsWindow, 30 days by default, and, collapsed under its row, the ten mutators that cost
it the most (ADR-0076)
and its lowest-scoring files, each with its change against the base
(ADR-0100),
and the same as dashboard.json (ADR-0024). It reads
each repository's mutation-gate branch, where the reusable workflow
publishes, through GitHub's API with GITHUB_TOKEN, and shows the
repositories with the topic dashboard.topic (mutation-gate by default),
or those dashboard.repositories names.
A repository of the organisation whose composer.json requires the gate,
as a project's does, builds it daily and deploys it to its Pages site, with
Pages set to deploy from GitHub Actions; its config, if any, holds the
dashboard keys alone. The token reads
every repository it shows; for private ones, a fine-grained token with
contents: read, stored as a secret:
name: dashboard
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
dashboard:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: '8.5'
- run: composer install --no-interaction --no-progress
- run: vendor/bin/mutation-gate dashboard --org="${GITHUB_REPOSITORY_OWNER}" --out=site
env:
GITHUB_TOKEN: ${{ secrets.MUTATION_GATE_DASHBOARD_TOKEN }}
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: site
- id: deploy
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1It runs on the schedule and by hand only, and runs no pull request's code.
A private or internal repository is left out unless --include-private is
given, and then the dashboard refuses to build unless GitHub says the Pages
site of the repository it runs in is private, which needs GitHub Enterprise
Cloud.
Concurrency
Only a verdict writes the ledger, so a run on the default branch that is
cancelled leaves the next run to judge its units again. The examples above
cancel only a pull request's runs on its older heads, which nobody reads. A
push to the default branch waits for the run before it, and of several
pushes waiting, GitHub keeps the newest. A scheduled run, a merge group and
a manual run are each a group of their own. init --ci=github writes the
same group.
Proofs
On GitHub, cache scoping keeps a pull request from writing what the default branch reads, so the Actions cache can keep the ledger. A store in S3, Cloud Storage or Azure Blob Storage needs credentials only the default branch's runs hold: see proofs and trust.
With a store, the reusable workflow holds two copies of the default branch's
ledger: the store's, which fetch reads, and the Actions cache's. The
verdict saves the cache's copy, and deliver writes the store's after it, so
a run cancelled in between leaves the cache's copy the newer.
proofs.copies says which the plan and the verdict read:
proofs.copies | The run reads |
|---|---|
newest | the copy with the later record, and the store's where neither is later; for most projects |
together | the store's copy; the verdict saves no copy of the default branch's ledger in the cache, and deliver saves the one it wrote to the store, so the two copies move together; where the cache must never get ahead of the store, as where a fork's run reads it through publicUrl, or another system reads it |
merged | both copies as one: every proof either holds, and the later copy's runs; where each copy can hold proofs the other lacks, as where another pipeline also writes the store |