-
Notifications
You must be signed in to change notification settings - Fork 704
feat(ci): implement sharding for unit test performance #9021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f85e89d
fix(core): discovery url handling, error code review helper, and pack…
bshaffer 639081b
fix(gcp-metadata): use recursive getErrorCodes helper for nested wrap…
bshaffer 4bc3be3
chore(core): remove pack-n-play timeout fixes (moved to #9021)
bshaffer ef76bc0
chore(core): add pack-n-play timeout fixes back to core PR
bshaffer ac1f478
add tests for error.cause and AggregateError
bshaffer 66743ae
feat(ci): add matrix sharding for unit test performance
bshaffer 491aba8
core test fixes
bshaffer 15e7e0a
Merge branch 'main' into improve-test-performance
bshaffer 4339fd1
revert unnecessary addition of port
bshaffer dc343c6
Revert "core test fixes"
bshaffer e13a364
Merge branch 'core-ci-fixes' into improve-test-performance
bshaffer 3573acb
Merge branch 'main' into improve-test-performance
bshaffer cce72d4
Merge branch 'main' into improve-test-performance
bshaffer d5aeba8
fix regressions from recent PRs
bshaffer 40133a2
attempt to fix bigtable unit tests
bshaffer 5259b8f
increase timeouts for pack-n-play
bshaffer ad7d031
Merge branch 'main' into improve-test-performance
bshaffer ff66947
Apply suggestion from @bshaffer
bshaffer 646734e
Apply suggestion from @bshaffer
bshaffer 3234034
change DRY_RUN_SHARD to RUN_TESTS_MDOE and fix merge
bshaffer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: "Calculate Shard Matrix" | ||
| description: "Calculates the dynamic test shard matrix and shard total" | ||
| outputs: | ||
| shard_matrix: | ||
| description: "JSON array of shard indices" | ||
| value: ${{ steps.set-matrix.outputs.shard_matrix }} | ||
| shard_total: | ||
| description: "Total number of shards" | ||
| value: ${{ steps.set-matrix.outputs.shard_total }} | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Calculate Matrix | ||
| id: set-matrix | ||
| shell: bash | ||
| env: | ||
| RUN_TESTS_MODE: CALCULATE_SHARD_MATRIX | ||
| BUILD_TYPE: presubmit | ||
| TEST_TYPE: units | ||
| GIT_DIFF_ARG: "HEAD^1" | ||
| run: | | ||
| bash ci/run_conditional_tests.sh --strict |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: "Check Shard Status" | ||
| description: "Checks if all unit test shards passed for a given Node version" | ||
| inputs: | ||
| node-version: | ||
| required: true | ||
| description: "Node version to check" | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Check shard status | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | ||
| with: | ||
| script: | | ||
| const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: context.runId, | ||
| }); | ||
| const nodeVersion = '${{ inputs.node-version }}'; | ||
| const shardJobs = jobs.filter(j => j.name.includes(`units (Node ${nodeVersion},`)); | ||
| if (shardJobs.length === 0) { | ||
| core.setFailed(`No shard jobs found for Node ${nodeVersion}`); | ||
| return; | ||
| } | ||
| const failed = shardJobs.filter(j => j.conclusion !== 'success'); | ||
| if (failed.length > 0) { | ||
| const failedLinks = failed.map(j => `- ${j.name}: ${j.html_url}`).join('\n'); | ||
| core.setFailed(`${failed.length} shards failed for Node ${nodeVersion}:\n${failedLinks}`); | ||
| } else { | ||
| core.info(`All shards passed for Node ${nodeVersion}`); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: "Run Unit Test Shard" | ||
| description: "Sets up Node.js, pnpm, and runs a unit test shard" | ||
| inputs: | ||
| node-version: | ||
| required: true | ||
| description: "Node.js version to test" | ||
| shard-total: | ||
| required: true | ||
| description: "Total number of shards" | ||
| shard-index: | ||
| required: true | ||
| description: "0-based shard index" | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Use Node.js ${{ inputs.node-version }} | ||
| uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 | ||
| with: | ||
| node-version: ${{ inputs.node-version }} | ||
| - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 | ||
| with: | ||
| version: ^10.0.0 | ||
| - run: node --version | ||
| shell: bash | ||
| - name: Run unit tests | ||
| shell: bash | ||
| run: bash ci/run_conditional_tests.sh --strict | ||
| env: | ||
| RUN_TESTS_MODE: RUN_UNIT_TESTS | ||
| BUILD_TYPE: presubmit | ||
| TEST_TYPE: units | ||
| SHARD_TOTAL: ${{ inputs.shard-total }} | ||
| SHARD_INDEX: ${{ inputs.shard-index }} | ||
| GIT_DIFF_ARG: HEAD^1 |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| module.exports = { | ||
| hooks: { | ||
| readPackage(pkg, context) { | ||
| // Override yargs for Node >= 24 to prevent ESM scope require errors | ||
| if (pkg.dependencies && pkg.dependencies.yargs) { | ||
| mutateYargs(pkg.dependencies, pkg.name, 'dependencies', context); | ||
| } | ||
| if (pkg.devDependencies && pkg.devDependencies.yargs) { | ||
| mutateYargs(pkg.devDependencies, pkg.name, 'devDependencies', context); | ||
| } | ||
| return pkg; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| function mutateYargs(deps, pkgName, depType, context) { | ||
| const nodeVersion = process.version; | ||
| const majorVersion = parseInt(nodeVersion.replace('v', '').split('.')[0], 10); | ||
|
|
||
| if (majorVersion >= 24) { | ||
| console.log(`[pnpmfile] Node.js version is ${nodeVersion} (>= 24). Overriding yargs to 18.0.0 in ${pkgName}`); | ||
| deps.yargs = '18.0.0'; | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.