chore: Use CircleCI native timing-based test splitting for acceptance shards#6889
chore: Use CircleCI native timing-based test splitting for acceptance shards#6889danskmt wants to merge 1 commit into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
be2b704 to
cd2482b
Compare
This comment has been minimized.
This comment has been minimized.
| - run: | ||
| name: Normalize junit file paths for timing data | ||
| when: always | ||
| shell: << parameters.test_shell >> | ||
| command: node scripts/normalize-junit-file-paths.js test/reports |
There was a problem hiding this comment.
This step is necessary because CircleCI doesn't automatically save paths like this for Windows:
test/jest/acceptance/snyk-code/snyk-code-user-journey.spec.ts
And then would mismatch, never finding the files, as CircleCI expects in this format.
There was a problem hiding this comment.
question: would this still be the case if we didn't use bash in Windows?
| Write-Host "Failed to upgrade pip, continuing: $($_.Exception.Message)" | ||
| } | ||
|
|
||
| & $python.Path -m pip install uv |
There was a problem hiding this comment.
Worth to get rid of uv for CI - maybe in a separate Jira
There was a problem hiding this comment.
mmmh there is src/lib/plugins/uv/uv.spec.ts... let's forget about that jira
robertolopezlopez
left a comment
There was a problem hiding this comment.
LGTM! Good job
| "jest-junit": { | ||
| "reportTestSuiteErrors": "true" | ||
| "reportTestSuiteErrors": "true", | ||
| "addFileAttribute": "true" |
There was a problem hiding this comment.
We need this addFileAttribute: true to jest-junit config so JUnit XML includes file="..." on each , which CircleCI needs for file-based timing matching.
| test_shell: bash.exe | ||
| pre_test_cmds: | | ||
| if (Test-Path '<< pipeline.parameters.windows_cache_dir >>/<< pipeline.parameters.windows_env_script >>') { . '<< pipeline.parameters.windows_cache_dir >>/<< pipeline.parameters.windows_env_script >>' } | ||
| if [ -f '<< pipeline.parameters.windows_cache_dir >>/<< pipeline.parameters.windows_bash_env_script >>' ]; then source '<< pipeline.parameters.windows_cache_dir >>/<< pipeline.parameters.windows_bash_env_script >>'; fi | ||
|
|
There was a problem hiding this comment.
issue: let's stick to the existing shell being used. changing the shell here leads to other issues (which you fixed in your other changes) that aren't necessary.
| default: 4 | ||
| shard_calc_cmd: | ||
| default: 6 | ||
| test_shell: |
| circleci tests glob "test/jest/acceptance/**/*.spec.ts" "ts-binary-wrapper/test/acceptance/**/*.spec.ts" \ | ||
| | node -e "let input='';process.stdin.on('data',c=>input+=c);process.stdin.on('end',()=>process.stdout.write(input.split(String.fromCharCode(92)).join('/')))" \ | ||
| | circleci tests run \ | ||
| --command="xargs npx jest --maxWorkers=1 --selectProjects coreCli --reporters=jest-junit --reporters=default --" \ | ||
| --split-by=timings \ | ||
| --timings-type=file |
There was a problem hiding this comment.
suggest: a few things.
node -e "let input='';process.stdin.on('data',c=>input+=c);process.stdin.on('end',()=>process.stdout.write(input.split(String.fromCharCode(92)).join('/')))" seems necessary because we're running bash in a Windows env. With the comments above, I think this is unnecessary.
We can follow the same pattern as << parameters.pre_test_cmds >> and introduce a << parameters.test_cmds >> to split Powershell vs Bash test commands.
j-luong
left a comment
There was a problem hiding this comment.
I think introducing bash as the shell for Windows causes more problems than it solves, let's see if we can do this without needing bash for Windows. That way we can clean up the extra scripts you introduced
9c558a5 to
1dc3634
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1dc3634 to
c84875a
Compare
This comment has been minimized.
This comment has been minimized.
c84875a to
08d6deb
Compare
PR Reviewer Guide 🔍
|
Pull Request Submission Checklist
What does this PR do?
Replaces Jest's
--shardwith CircleCI's nativecircleci tests run --split-by=timingsso acceptance test shards are automatically balanced by historic runtime data — no manually maintained weight files needed.--shard=<index>/<total>withcircleci tests glob | circleci tests run --split-by=timings --timings-type=filein theacceptance-testsjob.addFileAttribute: truetojest-junitconfig so JUnit XML includesfile="..."on each<testsuite>, which CircleCI needs for file-based timing matching.bash.exe(from PowerShell) since the command usesxargsand Unix pipe syntax. Sources the bash-compatible env script (snyk-env.sh) instead of the PowerShell one.Where should the reviewer start?
.circleci/config.yml— theacceptance-testsjob definition (replacedshard_calc_cmdparameter withtest_shell, newcircleci tests runcommand)package.json—addFileAttributeaddition injest-junitconfigHow should this be manually tested?
What's the product update that needs to be communicated to CLI users?
None. CI-only change; no CLI behavior change for end users.
Risk assessment (Low | Medium | High)?
Medium — changes how tests are distributed across CI shards on all platforms including Windows (shell change). First run may use name-based splitting until CircleCI accumulates timing data from JUnit reports.
Any background context you want to provide?
CircleCI stores timing data per job name across all branches, so existing
store_test_resultsuploads frommainshould provide immediate timing data. TheaddFileAttributeflag makesjest-junitemit thefileattribute on each<testsuite>, enabling CircleCI to match timing history to spec files. See CircleCI docs: Test splitting and parallelism.What are the relevant tickets?
CLI-1482
Screenshots (if appropriate)
Before (main) X Now (chore/CLI-1482-circleci-native-test-splitting):


Before (feat/CLI-1482-balance-acceptance-test-shards) X Now (chore/CLI-1482-circleci-native-test-splitting)