|
| 1 | +name: Changed-code mutation testing |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [edited, opened, reopened, ready_for_review, synchronize] |
| 6 | + merge_group: |
| 7 | + types: [checks_requested] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + mutation-diff: |
| 18 | + name: mutation-diff |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 30 |
| 21 | + steps: |
| 22 | + - name: Record merge-queue enforcement |
| 23 | + if: github.event_name == 'merge_group' |
| 24 | + run: | |
| 25 | + echo "## Changed-code mutation testing" >> "$GITHUB_STEP_SUMMARY" |
| 26 | + echo "Mutation testing was enforced on each pull request before it entered the merge queue." >> "$GITHUB_STEP_SUMMARY" |
| 27 | +
|
| 28 | + - name: Checkout pull request merge result |
| 29 | + if: github.event_name == 'pull_request' |
| 30 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 31 | + with: |
| 32 | + ref: ${{ github.sha }} |
| 33 | + fetch-depth: 0 |
| 34 | + persist-credentials: false |
| 35 | + |
| 36 | + - name: Fetch pull request base |
| 37 | + if: github.event_name == 'pull_request' |
| 38 | + env: |
| 39 | + BASE_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}.git |
| 40 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 41 | + run: git fetch --no-tags "$BASE_REPOSITORY_URL" "$BASE_SHA" |
| 42 | + |
| 43 | + - name: Setup Node.js and pnpm |
| 44 | + if: github.event_name == 'pull_request' |
| 45 | + uses: ./.github/actions/setup-node-pnpm |
| 46 | + with: |
| 47 | + install-args: "--frozen-lockfile" |
| 48 | + |
| 49 | + - name: Test mutation gate logic |
| 50 | + if: github.event_name == 'pull_request' |
| 51 | + run: pnpm test:mutation-ci |
| 52 | + |
| 53 | + - name: Mutate changed executable lines |
| 54 | + if: github.event_name == 'pull_request' |
| 55 | + env: |
| 56 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 57 | + HEAD_SHA: ${{ github.sha }} |
| 58 | + run: node scripts/stryker-diff.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA" |
| 59 | + |
| 60 | + - name: Upload mutation reports |
| 61 | + id: mutation_report |
| 62 | + if: always() && github.event_name == 'pull_request' |
| 63 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 64 | + with: |
| 65 | + name: changed-code-mutation-report |
| 66 | + path: reports/mutation/ |
| 67 | + if-no-files-found: ignore |
| 68 | + retention-days: 7 |
| 69 | + |
| 70 | + - name: Link mutation report artifact |
| 71 | + if: always() && github.event_name == 'pull_request' && steps.mutation_report.outputs.artifact-url != '' |
| 72 | + env: |
| 73 | + ARTIFACT_URL: ${{ steps.mutation_report.outputs.artifact-url }} |
| 74 | + run: | |
| 75 | + { |
| 76 | + echo "" |
| 77 | + echo "### Download mutation reports" |
| 78 | + echo "[Open the changed-code-mutation-report artifact]($ARTIFACT_URL), then open the package's mutation.html file." |
| 79 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments