Skip to the content
Howdah

being built · no release yet

Search

Skip the list of pages

Running the gate in CI

A CI run has three steps:

  • plan works out what to mutate and cuts it into shards;
  • run mutates one shard, once per shard and in parallel;
  • verdict merges every shard's result and judges the floors. It is the check to require before a merge.

A proof ledger lets each step skip what an earlier run already proved. Where it is kept, and who may write it, is in proofs and trust.

vendor/bin/mutation-gate init --ci writes the definition for the CI it detects, or for the one you name:

CIinit optionPage
GitHub Actions--ci=githubgithub-actions.md
GitLab CI--ci=gitlabgitlab.md
Buildkite--ci=buildkitebuildkite.md
CircleCI--ci=circlecicircleci.md
Azure DevOps--ci=azureazure-devops.md
Bitbucket Pipelines--ci=bitbucketbitbucket.md
Jenkins--ci=jenkinsjenkins.md
Anything elseplan --ci=jsonother.md

The package's own CI checks each definition init writes: the GitHub ones with actionlint, the YAML ones against their provider's published JSON Schema, and the Jenkinsfile, which has no schema, with a snapshot test.

What every setup needs

  • A scheduled full run. Run the gate on the default branch with no --changed-since at least once a week, on every CI. It catches what a change's reach cannot see (ADR-0005). On GitHub Actions, run it twice a week: GitHub evicts a cache entry nothing restores for seven days (ADR-0013).
  • The Pest patches, for sharded Pest runs. Set pest.patch: true, and add @php vendor/bin/mutation-gate pest:patch to post-install-cmd and post-update-cmd in composer.json. Every shard then reuses the planning job's coverage instead of running the whole suite again, and each mutant is allowed the time its own covering tests take, not the whole suite's.
  • The Infection patch, with Infection as the runner. Add @php vendor/bin/mutation-gate infection:patch to post-install-cmd and post-update-cmd, so each mutant gets the gate's limit, with its timeouts.seconds floor, and its silence limit, and a test that stats a dangling link or an unreadable file reads it as PHP does while Infection's include-interceptor serves the mutant. It patches only the Infection releases the gate supports. Unpatched, each mutant keeps Infection's own limit, and every run says so in its report.

A pull request that cannot pass

A pull request's run mutates every unit it planned, and the verdict names every survivor, so one run lists everything to fix. Its shard still fails as soon as it can tell the run cannot pass, as run.failFast says (ADR-0103). The run cannot pass once a survivor did not prove flaky, no ignore leaves it out, static analysis neither killed it nor proved it equivalent, and its tree's floor is 100, or its line is one the change added or modified and the new-code floor is 100.

  • mark, the default: the shard judges every unit, then fails, and the verdict warns how many runner minutes stop and cancel would have saved.
  • stop: the shard runs its units riskiest first, in chunks of about fifteen minutes of expected work, and stops after the chunk that confirms such a survivor, which saves runner minutes on a run that fails anyway.
  • cancel: as stop, and in the reusable workflow GitHub then cancels the other shards of the matrix; on any other CI it acts as stop.
  • off: the shard passes, and the verdict alone fails.

Its result names the survivor under doomed in .mutation-gate/results/<id>.json:

"doomed": {"unit": "src/Money.php", "mutant": "3f9c2a1b7d4e", "tree": "src", "floor": 100, "why": "tree", "after": 412.5, "stopped": true}

why is tree or newCode, after the seconds into its mutating the shard found the survivor, and stopped whether it stopped there. A CI step that reads only that result, and runs none of the project's code, fails the shard's job; the other shards run on, each to its end or its own sure survivor, unless cancel cancels them. The verdict reads a shard that left no result beside one that stopped as stopped. The units the run did not mutate count by their newest results, as under a budget, and the verdict fails naming the survivor.