From 54674be2627bd13fc5f6f3146d82ba9df58fc601 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 20:24:26 -0700 Subject: [PATCH 01/11] ci: Make jest matrix config dynamic for PR runs --- .github/workflows/frontend.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 80c6310c737e..22d417b28395 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -35,6 +35,7 @@ jobs: frontend_all_files: ${{ steps.changes.outputs.frontend_all_files }} merge_base: ${{ steps.merge_base.outputs.merge_base }} merge_base_strategy: ${{ steps.merge_base.outputs.merge_base_strategy }} + jest_test_matrix: ${{ steps.calc-test-matrix.outputs.jest_test_matrix }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -74,6 +75,18 @@ jobs: echo "merge_base=${MERGE_BASE:-}" >> "$GITHUB_OUTPUT" echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" + - name: Calculate Test Matrix + id: calc-test-matrix + run: | + RUNNERS=8 + if [ "$STRATEGY" == "changedSince" ]; then + RUNNERS=1 + fi + # Create a JSON array for indices [1, 2, ... RUNNERS] + JSON_ARRAY=$(seq 1 $RUNNERS | jq -R . | jq -s .) + # Output the full matrix object + echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" '{index: $indices, total: [$RUNNERS]}')" >> $GITHUB_OUTPUT + typescript: if: needs.files-changed.outputs.frontend_all == 'true' needs: files-changed @@ -179,9 +192,7 @@ jobs: # and reducing the risk that one of many runs would turn red again (read: intermittent tests) fail-fast: false matrix: - # XXX: When updating this, make sure you also update CI_NODE_TOTAL. - - instance: [0, 1, 2, 3, 4, 5, 6, 7] + instance: ${{ fromJson(needs.files-changed.outputs.jest_test_matrix) }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -198,7 +209,7 @@ jobs: path: | .cache/jest ~/.cache/swc - key: jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}-${{ matrix.instance }} + key: jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}-${{ matrix.instance.index }} restore-keys: | jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}- jest-cache-${{ runner.os }}- @@ -218,13 +229,12 @@ jobs: - name: jest env: + CI_NODE_TOTAL: ${{ matrix.instance.total }} + CI_NODE_INDEX: ${{ matrix.instance.index }} + GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }} - # XXX: CI_NODE_TOTAL must be hardcoded to the length of strategy.matrix.instance. - # Otherwise, if there are other things in the matrix, using strategy.job-total - # wouldn't be correct. - CI_NODE_TOTAL: 8 - CI_NODE_INDEX: ${{ matrix.instance }} + # Disable testing-library from printing out any of of the DOM to # stdout. No one actually looks through this in CI, they're just # going to run it locally. From f7df4701d535e5b5cb9f0f87e6506260a17ca2f4 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 21:11:33 -0700 Subject: [PATCH 02/11] fix bugs from bot review --- .github/workflows/frontend.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 22d417b28395..1faebfeb5379 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -75,9 +75,6 @@ jobs: echo "merge_base=${MERGE_BASE:-}" >> "$GITHUB_OUTPUT" echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" - - name: Calculate Test Matrix - id: calc-test-matrix - run: | RUNNERS=8 if [ "$STRATEGY" == "changedSince" ]; then RUNNERS=1 @@ -85,7 +82,7 @@ jobs: # Create a JSON array for indices [1, 2, ... RUNNERS] JSON_ARRAY=$(seq 1 $RUNNERS | jq -R . | jq -s .) # Output the full matrix object - echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" '{index: $indices, total: [$RUNNERS]}')" >> $GITHUB_OUTPUT + echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT typescript: if: needs.files-changed.outputs.frontend_all == 'true' From b3d44364414c0abe93a379fe2197217b1424034e Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 21:14:34 -0700 Subject: [PATCH 03/11] fix 1-based array values, should be 0-indexed --- .github/workflows/frontend.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 1faebfeb5379..2a2f52f25ed0 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -75,12 +75,12 @@ jobs: echo "merge_base=${MERGE_BASE:-}" >> "$GITHUB_OUTPUT" echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" - RUNNERS=8 + RUNNERS=7 if [ "$STRATEGY" == "changedSince" ]; then - RUNNERS=1 + RUNNERS=0 fi - # Create a JSON array for indices [1, 2, ... RUNNERS] - JSON_ARRAY=$(seq 1 $RUNNERS | jq -R . | jq -s .) + # Create a JSON array for indices [0, 1, ... RUNNERS] + JSON_ARRAY=$(seq 0 $RUNNERS | jq -R . | jq -s .) # Output the full matrix object echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT From 35035db9a3375412290be92844927bb9ef23095b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 21:15:46 -0700 Subject: [PATCH 04/11] rename output var name --- .github/workflows/frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 2a2f52f25ed0..8bc90518019e 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -35,7 +35,7 @@ jobs: frontend_all_files: ${{ steps.changes.outputs.frontend_all_files }} merge_base: ${{ steps.merge_base.outputs.merge_base }} merge_base_strategy: ${{ steps.merge_base.outputs.merge_base_strategy }} - jest_test_matrix: ${{ steps.calc-test-matrix.outputs.jest_test_matrix }} + jest_test_matrix: ${{ steps.merge_base.outputs.jest_test_matrix }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: From c6efa0720f19c3035f00e3488c5b5f6646cf9940 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 21:46:54 -0700 Subject: [PATCH 05/11] fix off-by-one error with the runner count --- .github/workflows/frontend.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 8bc90518019e..c76e4c0463cf 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -75,12 +75,12 @@ jobs: echo "merge_base=${MERGE_BASE:-}" >> "$GITHUB_OUTPUT" echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" - RUNNERS=7 + RUNNERS=8 if [ "$STRATEGY" == "changedSince" ]; then - RUNNERS=0 + RUNNERS=1 fi - # Create a JSON array for indices [0, 1, ... RUNNERS] - JSON_ARRAY=$(seq 0 $RUNNERS | jq -R . | jq -s .) + # Create a JSON array for indices [0, 1, ... RUNNERS-1] + JSON_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -R . | jq -s .) # Output the full matrix object echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT From f859ab73b1e8d26ed893a2419b5261541890476b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 22:00:02 -0700 Subject: [PATCH 06/11] single-line jest_test_matrix output --- .github/workflows/frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index c76e4c0463cf..2d2f15409bf7 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -82,7 +82,7 @@ jobs: # Create a JSON array for indices [0, 1, ... RUNNERS-1] JSON_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -R . | jq -s .) # Output the full matrix object - echo "jest_test_matrix=$(jq -n --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT + echo "jest_test_matrix=$(jq -nc --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT typescript: if: needs.files-changed.outputs.frontend_all == 'true' From 5fed63b2cfcf9cfcfbbdeb3c642eef09a5fb9fc2 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 1 Jun 2026 22:09:03 -0700 Subject: [PATCH 07/11] Jest Matrix Config step --- .github/workflows/frontend.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 2d2f15409bf7..32b516ef949a 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -75,11 +75,13 @@ jobs: echo "merge_base=${MERGE_BASE:-}" >> "$GITHUB_OUTPUT" echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" + - name: Jest Matrix Config + run: | RUNNERS=8 - if [ "$STRATEGY" == "changedSince" ]; then + if [ "${{ steps.merge_base.outputs.merge_base_strategy }}" == "changedSince" ]; then RUNNERS=1 fi - # Create a JSON array for indices [0, 1, ... RUNNERS-1] + JSON_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -R . | jq -s .) # Output the full matrix object echo "jest_test_matrix=$(jq -nc --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT From 95eefcdd1212cff6c96b82a499741b7c4495b04b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 2 Jun 2026 09:34:10 -0700 Subject: [PATCH 08/11] add missing step id --- .github/workflows/frontend.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 32b516ef949a..3de1af1d2f2c 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -35,7 +35,7 @@ jobs: frontend_all_files: ${{ steps.changes.outputs.frontend_all_files }} merge_base: ${{ steps.merge_base.outputs.merge_base }} merge_base_strategy: ${{ steps.merge_base.outputs.merge_base_strategy }} - jest_test_matrix: ${{ steps.merge_base.outputs.jest_test_matrix }} + jest_test_matrix: ${{ steps.jest_matrix_config.outputs.jest_test_matrix }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -76,6 +76,7 @@ jobs: echo "merge_base_strategy=${STRATEGY}" >> "$GITHUB_OUTPUT" - name: Jest Matrix Config + id: jest_matrix_config run: | RUNNERS=8 if [ "${{ steps.merge_base.outputs.merge_base_strategy }}" == "changedSince" ]; then From fd6e06bfddcce8265fad9b1d17bbd521e42acf01 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 2 Jun 2026 10:49:38 -0700 Subject: [PATCH 09/11] iterate on the jest_test_matrix var --- .github/workflows/frontend.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 3de1af1d2f2c..64ea1b9ddc14 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -85,7 +85,7 @@ jobs: JSON_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -R . | jq -s .) # Output the full matrix object - echo "jest_test_matrix=$(jq -nc --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{index: $indices, total: $total}')" >> $GITHUB_OUTPUT + echo "jest_test_matrix=$(jq -nc --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{instance: {index: $indices, total: $total}}')" >> $GITHUB_OUTPUT typescript: if: needs.files-changed.outputs.frontend_all == 'true' @@ -191,8 +191,7 @@ jobs: # This helps not having to run multiple jobs because one fails, thus, reducing resource usage # and reducing the risk that one of many runs would turn red again (read: intermittent tests) fail-fast: false - matrix: - instance: ${{ fromJson(needs.files-changed.outputs.jest_test_matrix) }} + matrix: ${{ fromJson(needs.files-changed.outputs.jest_test_matrix) }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 From 71a113c5e7c2e11155376f56f0b23b47b5f0f8c0 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 2 Jun 2026 15:36:25 -0700 Subject: [PATCH 10/11] ci(frontend): Simplify jest test matrix output format Use native GitHub Actions matrix dimensions instead of an array of objects under an `instance` key. Drop `jq -R` so indices are integers rather than strings. Output is now `{index: [0..7], total: 8}` (or `{index: [0], total: 1}` for changedSince) accessed via `matrix.index` / `matrix.total`. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/frontend.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 64ea1b9ddc14..9b8db13acfe9 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -83,9 +83,8 @@ jobs: RUNNERS=1 fi - JSON_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -R . | jq -s .) - # Output the full matrix object - echo "jest_test_matrix=$(jq -nc --argjson indices "$JSON_ARRAY" --argjson total "$RUNNERS" '{instance: {index: $indices, total: $total}}')" >> $GITHUB_OUTPUT + INDEX_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -s .) + echo "jest_test_matrix=$(jq -nc --argjson index "$INDEX_ARRAY" --argjson total "$RUNNERS" '{index: $index, total: $total}')" >> $GITHUB_OUTPUT typescript: if: needs.files-changed.outputs.frontend_all == 'true' @@ -208,7 +207,7 @@ jobs: path: | .cache/jest ~/.cache/swc - key: jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}-${{ matrix.instance.index }} + key: jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}-${{ matrix.index }} restore-keys: | jest-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'jest.config.ts') }}- jest-cache-${{ runner.os }}- @@ -228,8 +227,8 @@ jobs: - name: jest env: - CI_NODE_TOTAL: ${{ matrix.instance.total }} - CI_NODE_INDEX: ${{ matrix.instance.index }} + CI_NODE_TOTAL: ${{ matrix.total }} + CI_NODE_INDEX: ${{ matrix.index }} GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }} GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }} From 96458a512e6c85000acb643406089bfff9ac292b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 2 Jun 2026 16:29:36 -0700 Subject: [PATCH 11/11] fix(ci): Wrap matrix total in array for fromJson compatibility GitHub Actions fromJson requires all matrix values to be arrays. A bare scalar like `total: 8` causes "Unexpected value" errors. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 9b8db13acfe9..db051592becf 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -84,7 +84,7 @@ jobs: fi INDEX_ARRAY=$(seq 0 $(( RUNNERS - 1 )) | jq -s .) - echo "jest_test_matrix=$(jq -nc --argjson index "$INDEX_ARRAY" --argjson total "$RUNNERS" '{index: $index, total: $total}')" >> $GITHUB_OUTPUT + echo "jest_test_matrix=$(jq -nc --argjson index "$INDEX_ARRAY" --argjson total "$RUNNERS" '{index: $index, total: [$total]}')" >> $GITHUB_OUTPUT typescript: if: needs.files-changed.outputs.frontend_all == 'true'