Skip to content

Commit

Permalink
add sharding to speed up yarn tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac Boyd committed Aug 2, 2024
1 parent d6d6dbe commit 53999d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
node_version:
required: true
description: The version of Node.js to use.
shard:
required: true
description: Which shard we're on.

runs:
using: composite
Expand All @@ -25,8 +28,8 @@ runs:
TESTFILES=$(find lib -name '*.spec.ts')
for file in $TESTFILES; do
filename=$(basename "$file" .spec.ts)
JEST_JUNIT_OUTPUT_NAME="${{ github.sha }}_${{ github.run_id }}_node${{ inputs.node_version }}_${filename}_results.xml" \
yarn test $file --ci --reporters=default --reporters=jest-junit
JEST_JUNIT_OUTPUT_NAME="${{ github.sha }}_${{ github.run_id }}_node${{ inputs.node_version }}_${{ inputs.shard }}_${filename}_results.xml" \
yarn test $file --ci --reporters=default --reporters=jest-junit --shard=${{ inputs.shard }}
done
env:
JEST_JUNIT_OUTPUT_DIR: ./test-reports/jest
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ jobs:
fail-fast: true # if one job fails, stop the rest
matrix:
node-version: [14, 16, 18, 20]
shard:
[
"1/10",
"2/10",
"3/10",
"4/10",
"5/10",
"6/10",
"7/10",
"8/10",
"9/10",
"10/10",
]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -34,7 +47,7 @@ jobs:
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-node-${{ matrix.node-version }}
name: test-results-node-${{ matrix.node-version }}-${{ matrix.shard }}
path: ./test-reports

- name: Test summary
Expand Down

0 comments on commit 53999d3

Please sign in to comment.