Repository navigation
Bump ruby/setup-ruby from 1.325.0 to 1.327.0 #125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: mutation | |
| # Push is scoped to main so a pull request runs this once rather than twice. | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| env: | |
| BUNDLE_WITHOUT: "benchmark" | |
| # Subjects per runner. Mutant costs anywhere from half a second to twenty | |
| # seconds a subject, depending on how many examples the subject drags in, so | |
| # 50 is the size that keeps even a shard of the slow ones inside the timeout | |
| # below while leaving an ordinary pull request on a single runner. | |
| SUBJECTS_PER_SHARD: 50 | |
| # A ceiling on the fan-out, so a formatting pass over the whole tree grows | |
| # the shards rather than the runners. Mutant selects a subject whose line | |
| # range the diff touches, and a comment removed above a method moves every | |
| # method below it, so such a change can select most of the library. | |
| MAX_SHARDS: 24 | |
| # Stryker runs the viewer's whole test suite per mutant, about a second on | |
| # a runner, and a module carries up to 240 mutants, so a shard of three | |
| # modules stays inside the timeout below with room to spare. | |
| MAX_FRONTEND_SHARDS: 6 | |
| jobs: | |
| plan: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| base: ${{ steps.plan.outputs.base }} | |
| count: ${{ steps.plan.outputs.count }} | |
| shards: ${{ steps.plan.outputs.shards }} | |
| total: ${{ steps.plan.outputs.total }} | |
| frontend: ${{ steps.plan.outputs.frontend }} | |
| frontend_shards: ${{ steps.plan.outputs.frontend_shards }} | |
| frontend_total: ${{ steps.plan.outputs.frontend_total }} | |
| steps: | |
| # Mutant selects subjects by diffing against a revision, so the | |
| # revision has to be in the clone: a shallow one has nothing to | |
| # compare against. | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ruby/setup-ruby@v1.327.0 | |
| with: | |
| ruby-version: ruby | |
| rubygems: default | |
| bundler-cache: true | |
| - name: Fetch the base branch | |
| if: github.event_name == 'pull_request' | |
| run: git fetch --no-tags origin ${{ github.base_ref }} | |
| # A pull request is diffed against its base branch. A push is diffed | |
| # against the head it replaced, so a multi-commit push is diffed as a | |
| # whole. A force push can leave that head unreachable, and then the diff | |
| # falls back to the tip commit alone, which covers the amend-and-push | |
| # case that produces most force pushes here. | |
| - name: Plan the shards | |
| id: plan | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| base="origin/${{ github.base_ref }}" | |
| else | |
| base="${{ github.event.before }}" | |
| if [ "$base" = "0000000000000000000000000000000000000000" ]; then | |
| base="HEAD~1" | |
| elif ! git cat-file -e "$base^{commit}" 2>/dev/null; then | |
| git fetch --no-tags origin "$base" 2>/dev/null || base="HEAD~1" | |
| fi | |
| fi | |
| base=$(git rev-parse "$base^{commit}") | |
| echo "Comparing against $base" | |
| count=$(bundle exec rake -s "mutant:subjects[$base]" | grep -c . || true) | |
| if [ "$count" -eq 0 ]; then | |
| total=0 | |
| else | |
| total=$(( (count + SUBJECTS_PER_SHARD - 1) / SUBJECTS_PER_SHARD )) | |
| if [ "$total" -gt "$MAX_SHARDS" ]; then total="$MAX_SHARDS"; fi | |
| fi | |
| echo "$count subject(s) across $total shard(s)" | |
| frontend=$(git diff --name-only "$base" -- html_frontend/src | grep -c '\.ts$' || true) | |
| frontend_total="$frontend" | |
| if [ "$frontend_total" -gt "$MAX_FRONTEND_SHARDS" ]; then frontend_total="$MAX_FRONTEND_SHARDS"; fi | |
| echo "$frontend frontend module(s) across $frontend_total shard(s)" | |
| { | |
| echo "base=$base" | |
| echo "count=$count" | |
| echo "total=$total" | |
| echo "shards=$(jq -nc --argjson n "$total" '[range($n)]')" | |
| echo "frontend=$frontend" | |
| echo "frontend_total=$frontend_total" | |
| echo "frontend_shards=$(jq -nc --argjson n "$frontend_total" '[range($n)]')" | |
| } >> "$GITHUB_OUTPUT" | |
| # A change that touches no library code selects nothing and never reaches | |
| # here, which is what a docs- or spec-only change should do. | |
| mutate: | |
| needs: plan | |
| if: needs.plan.outputs.count != '0' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| strategy: | |
| # Every shard reports its own survivors. Stopping the others on the | |
| # first failure would hide the rest of them. | |
| fail-fast: false | |
| matrix: | |
| shard: ${{ fromJSON(needs.plan.outputs.shards) }} | |
| steps: | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ruby/setup-ruby@v1.327.0 | |
| with: | |
| ruby-version: ruby | |
| rubygems: default | |
| bundler-cache: true | |
| - name: Make the base revision available | |
| run: | | |
| git cat-file -e "${{ needs.plan.outputs.base }}^{commit}" 2>/dev/null || | |
| git fetch --no-tags origin "${{ needs.plan.outputs.base }}" | |
| - name: Analyse this shard of the mutations the change touches | |
| run: | | |
| bundle exec rake \ | |
| "mutant:shard[${{ needs.plan.outputs.base }},${{ matrix.shard }},${{ needs.plan.outputs.total }}]" | |
| # The viewer's modules the change touches go through Stryker the same way, | |
| # a module per shard until the cap, then round robin. A test-only change | |
| # selects nothing, as on the Ruby side. | |
| mutate-frontend: | |
| needs: plan | |
| if: needs.plan.outputs.frontend != '0' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: ${{ fromJSON(needs.plan.outputs.frontend_shards) }} | |
| steps: | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: ruby/setup-ruby@v1.327.0 | |
| with: | |
| ruby-version: ruby | |
| rubygems: default | |
| bundler-cache: true | |
| - name: Make the base revision available | |
| run: | | |
| git cat-file -e "${{ needs.plan.outputs.base }}^{commit}" 2>/dev/null || | |
| git fetch --no-tags origin "${{ needs.plan.outputs.base }}" | |
| - name: Mutation-test this shard of the frontend modules the change touches | |
| run: | | |
| bundle exec rake \ | |
| "frontend:mutate:shard[${{ needs.plan.outputs.base }},${{ matrix.shard }},${{ needs.plan.outputs.frontend_total }}]" |