name: Mutants on: schedule: - cron: "41 4 * * 1" workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} env: CARGO_TERM_COLOR: always jobs: mutants: name: Mutants (shard ${{ matrix.shard }}/16) runs-on: ubuntu-latest timeout-minutes: 90 strategy: fail-fast: false max-parallel: 6 matrix: shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] env: SHARD: ${{ matrix.shard }} SHARDS: 16 CARGO_PROFILE_DEV_DEBUG: "false" CARGO_PROFILE_TEST_DEBUG: "false" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: $/.github/actions/rust with: cache-key: mutants - uses: taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2.90.5 with: tool: cargo-mutants - name: Run cargo-mutants on this shard run: | cargo mutants -p ferrovue-core -p ferrovue-router -p ferrovue-i18n -p ferrovue --in-place --shard "$SHARD/$SHARDS" --sharding round-robin --timeout 90 --annotations none --cargo-arg="--config=target.'cfg(all())'.runner = ['prlimit', '--as=4294967296', '--']" || status=$? if [[ "${status:-0}" != 0 && "${status:-0}" != 2 && "${status:-0}" != 3 ]]; then exit "$status"; fi touch mutants.out/shard-complete - name: Every surviving mutant is a known equivalent run: | sed -E 's/^([^:]+):[0-9]+:[0-9]+: /\1: /' mutants.out/missed.txt | sort > "$RUNNER_TEMP/missed.txt" grep -v -e '^#' -e '^$' .cargo/mutants-equivalent.txt | sort > "$RUNNER_TEMP/known.txt" comm -23 "$RUNNER_TEMP/missed.txt" "$RUNNER_TEMP/known.txt" > "$RUNNER_TEMP/unexplained.txt" { echo "### Mutants, shard $SHARD/$SHARDS" echo echo "| Caught | Timed out | Missed (known equivalent) | Missed (unexplained) | Unviable |" echo "|---:|---:|---:|---:|---:|" echo "| $(wc -l < mutants.out/caught.txt) | $(wc -l < mutants.out/timeout.txt) | $(( $(wc -l < mutants.out/missed.txt) - $(wc -l < "$RUNNER_TEMP/unexplained.txt") )) | $(wc -l < "$RUNNER_TEMP/unexplained.txt") | $(wc -l < mutants.out/unviable.txt) |" if [[ -s "$RUNNER_TEMP/unexplained.txt" ]]; then echo echo "Survivors with no test and no explanation:" echo echo '```text' cat "$RUNNER_TEMP/unexplained.txt" echo '```' fi } >> "$GITHUB_STEP_SUMMARY" if [[ -s "$RUNNER_TEMP/unexplained.txt" ]]; then cat "$RUNNER_TEMP/unexplained.txt" exit 1 fi - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() with: name: mutants-${{ matrix.shard }} path: mutants.out/ if-no-files-found: warn equivalents: name: Every listed equivalent and timeout still holds needs: mutants if: ${{ !cancelled() }} runs-on: ubuntu-latest timeout-minutes: 5 env: SHARDS: 16 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: mutants-* path: ${{ runner.temp }}/shards - name: Every shard ran to the end id: shards run: | incomplete=() for (( shard = 0; shard < SHARDS; shard++ )); do [[ -f "$RUNNER_TEMP/shards/mutants-$shard/shard-complete" ]] || incomplete+=("$shard") done if (( ${#incomplete[@]} > 0 )); then echo "complete=false" >> "$GITHUB_OUTPUT" echo "::warning title=Lists not checked for stale entries::Shards ${incomplete[*]} did not run to the end, so their missed and timed-out mutants are unknown" { echo "### Every listed equivalent and timeout still holds" echo echo "Not checked: shards ${incomplete[*]} of $SHARDS did not run to the end." } >> "$GITHUB_STEP_SUMMARY" else echo "complete=true" >> "$GITHUB_OUTPUT" fi - name: Every missed and timed-out mutant is listed run: | shopt -s nullglob reported() { cat /dev/null "$@" | sed -E 's/^([^:]+):[0-9]+:[0-9]+: /\1: /' | sort; } entries() { sed -e '/^#/d' -e '/^$/d' "$1" | sort; } section() { if [[ -s "$2" ]]; then echo echo "$1" echo echo '```text' cat "$2" echo '```' fi } reported "$RUNNER_TEMP"/shards/*/missed.txt > "$RUNNER_TEMP/missed.txt" reported "$RUNNER_TEMP"/shards/*/timeout.txt > "$RUNNER_TEMP/timeout.txt" entries .cargo/mutants-equivalent.txt > "$RUNNER_TEMP/equivalent.txt" entries .cargo/mutants-timeout.txt > "$RUNNER_TEMP/listed-timeout.txt" sort "$RUNNER_TEMP/equivalent.txt" "$RUNNER_TEMP/listed-timeout.txt" > "$RUNNER_TEMP/listed.txt" comm -23 "$RUNNER_TEMP/missed.txt" "$RUNNER_TEMP/equivalent.txt" > "$RUNNER_TEMP/unexplained-missed.txt" comm -23 "$RUNNER_TEMP/timeout.txt" "$RUNNER_TEMP/listed.txt" > "$RUNNER_TEMP/unexplained-timeout.txt" comm -12 "$RUNNER_TEMP/missed.txt" "$RUNNER_TEMP/equivalent.txt" > "$RUNNER_TEMP/listed-missed.txt" comm -12 "$RUNNER_TEMP/timeout.txt" "$RUNNER_TEMP/listed.txt" > "$RUNNER_TEMP/listed-timed-out.txt" { echo "### Missed and timed-out mutants" echo echo "| Missed (unexplained) | Timed out (unexplained) | Missed (known equivalent) | Timed out (listed) |" echo "|---:|---:|---:|---:|" echo "| $(wc -l < "$RUNNER_TEMP/unexplained-missed.txt") | $(wc -l < "$RUNNER_TEMP/unexplained-timeout.txt") | $(wc -l < "$RUNNER_TEMP/listed-missed.txt") | $(wc -l < "$RUNNER_TEMP/listed-timed-out.txt") |" section "Missed, with no test and no entry in .cargo/mutants-equivalent.txt: close it with a test, or list it there with its reason" "$RUNNER_TEMP/unexplained-missed.txt" section "Timed out, with no entry in .cargo/mutants-timeout.txt: make the loop fail under test, or list it there with its reason" "$RUNNER_TEMP/unexplained-timeout.txt" section "Missed, listed in .cargo/mutants-equivalent.txt:" "$RUNNER_TEMP/listed-missed.txt" section "Timed out, listed in .cargo/mutants-timeout.txt:" "$RUNNER_TEMP/listed-timed-out.txt" } >> "$GITHUB_STEP_SUMMARY" while IFS= read -r mutant; do echo "::error title=Missed mutant with no entry::$mutant"; done < "$RUNNER_TEMP/unexplained-missed.txt" while IFS= read -r mutant; do echo "::error title=Timed-out mutant with no entry::$mutant"; done < "$RUNNER_TEMP/unexplained-timeout.txt" if [[ -s "$RUNNER_TEMP/unexplained-missed.txt" || -s "$RUNNER_TEMP/unexplained-timeout.txt" ]]; then echo "Missed or timed out, and listed in neither .cargo/mutants-equivalent.txt nor .cargo/mutants-timeout.txt: close each with a test, or list it with its reason" exit 1 fi - name: No entry of .cargo/mutants-equivalent.txt or .cargo/mutants-timeout.txt is stale if: ${{ !cancelled() && steps.shards.outputs.complete == 'true' }} run: | sort "$RUNNER_TEMP/missed.txt" "$RUNNER_TEMP/timeout.txt" > "$RUNNER_TEMP/reported.txt" comm -13 "$RUNNER_TEMP/reported.txt" "$RUNNER_TEMP/equivalent.txt" > "$RUNNER_TEMP/stale-equivalent.txt" comm -13 "$RUNNER_TEMP/reported.txt" "$RUNNER_TEMP/listed-timeout.txt" > "$RUNNER_TEMP/stale-timeout.txt" if [[ -s "$RUNNER_TEMP/stale-equivalent.txt" ]]; then echo "Listed as equivalent, but no shard missed them: remove them from .cargo/mutants-equivalent.txt" cat "$RUNNER_TEMP/stale-equivalent.txt" fi if [[ -s "$RUNNER_TEMP/stale-timeout.txt" ]]; then echo "Listed as timing out, but no shard timed out on them: remove them from .cargo/mutants-timeout.txt" cat "$RUNNER_TEMP/stale-timeout.txt" fi if [[ -s "$RUNNER_TEMP/stale-equivalent.txt" || -s "$RUNNER_TEMP/stale-timeout.txt" ]]; then exit 1 fi typescript: name: Mutants (compiler, ${{ matrix.name }}) runs-on: ubuntu-latest timeout-minutes: 150 environment: ${{ github.ref == 'refs/heads/main' && 'stryker-dashboard' || '' }} strategy: fail-fast: false max-parallel: 3 matrix: include: - name: attributes and templates modules: attrs template - name: constants modules: constants const-decls const-values ts-exports - name: component choices modules: dynamic - name: expressions modules: expr members operators logical conditional - name: calls, globals and numbers modules: calls globals numbers - name: strings modules: strings - name: lists modules: lists array-literals borrows destructuring flat list-calls object-calls reduce sorting env: MODULES: ${{ matrix.modules }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: $/.github/actions/pnpm - name: Run Stryker on these modules, and hold their survivors and timeouts to stryker-equivalent.txt and stryker-timeout.txt if: github.ref != 'refs/heads/main' run: pnpm mutants:ts $MODULES - name: Run Stryker on these modules, upload their report to the Stryker Dashboard, and hold their survivors and timeouts to stryker-equivalent.txt and stryker-timeout.txt if: github.ref == 'refs/heads/main' env: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} run: pnpm mutants:ts $MODULES --reporters=clear-text,progress,json,html,dashboard "--dashboard.module=${MODULES// /-}" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() with: name: stryker-report-${{ strategy.job-index }} path: | target/stryker/mutation.html target/stryker/mutation.json if-no-files-found: warn report: name: Track a failing scheduled run needs: [mutants, equivalents, typescript] if: ${{ !cancelled() && github.event_name == 'schedule' && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} runs-on: ubuntu-latest timeout-minutes: 5 permissions: actions: read issues: write steps: - name: Open or update the tracking issue env: GH_TOKEN: ${{ github.token }} RUN_ID: ${{ github.run_id }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} SHA: ${{ github.sha }} TITLE: Weekly mutation testing failed run: | gh run view "$RUN_ID" -R "$GITHUB_REPOSITORY" --json jobs --jq '.jobs[] | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out") | "- [\(.name)](\(.url)): \(.conclusion)"' > "$RUNNER_TEMP/failing.md" { echo "The scheduled Mutants run $RUN_URL on \`$SHA\` failed." echo echo "Failing jobs:" echo cat "$RUNNER_TEMP/failing.md" } > "$RUNNER_TEMP/body.md" issue=$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search "\"$TITLE\" in:title" --json number,title --jq "map(select(.title == env.TITLE)) | first | .number // empty") if [[ -n "$issue" ]]; then gh issue comment "$issue" -R "$GITHUB_REPOSITORY" --body-file "$RUNNER_TEMP/body.md" else gh issue create -R "$GITHUB_REPOSITORY" --title "$TITLE" --body-file "$RUNNER_TEMP/body.md" fi