Skip to content

[Chore] Require changed-code mutation tests before review #4

[Chore] Require changed-code mutation tests before review

[Chore] Require changed-code mutation tests before review #4

name: Changed-code mutation testing
on:
pull_request:
types: [edited, opened, reopened, ready_for_review, synchronize]
merge_group:
types: [checks_requested]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
mutation-diff:
name: mutation-diff
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Record merge-queue enforcement
if: github.event_name == 'merge_group'
run: |
echo "## Changed-code mutation testing" >> "$GITHUB_STEP_SUMMARY"
echo "Mutation testing was enforced on each pull request before it entered the merge queue." >> "$GITHUB_STEP_SUMMARY"
- name: Checkout pull request head
if: github.event_name == 'pull_request'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- name: Fetch pull request base
if: github.event_name == 'pull_request'
env:
BASE_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}.git
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: git fetch --no-tags "$BASE_REPOSITORY_URL" "$BASE_SHA"
- name: Setup Node.js and pnpm
if: github.event_name == 'pull_request'
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Test mutation gate logic
if: github.event_name == 'pull_request'
run: pnpm test:mutation-ci
- name: Run Stryker integration smoke
if: github.event_name == 'pull_request'
run: pnpm test:mutation-smoke
- name: Mutate changed executable lines
if: github.event_name == 'pull_request'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: node scripts/stryker-diff.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"
- name: Upload mutation reports
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: changed-code-mutation-report
path: reports/mutation/
if-no-files-found: ignore
retention-days: 7