Skip to content

CI: Update CircleCI config to support "Rerun failed tests" feature#31993

Merged
ghengeveld merged 25 commits into
nextfrom
circleci-rerun-tests
Jul 11, 2025
Merged

CI: Update CircleCI config to support "Rerun failed tests" feature#31993
ghengeveld merged 25 commits into
nextfrom
circleci-rerun-tests

Conversation

@ghengeveld

@ghengeveld ghengeveld commented Jul 9, 2025

Copy link
Copy Markdown
Member

Closes #31292

What I did

Updated the CircleCI config to enable the "Rerun failed tests" feature. This allows us to rerun only the unit tests that failed (example).

I've also simplified the setup by removing the separate store-test-results step. With the new setup it doesn't seem to be necessary to manually merge test results into a single junit.xml anymore. CircleCI accepts a separate junit.xml file from each parallel run, and reports the (correct) total number of tests. An extra benefit is that the test results are now reported on the unit-test task itself (e.g. here) rather than a separate later task (e.g. here).

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

Updates CircleCI configuration to support the 'Rerun failed tests' feature, improving test execution efficiency and reliability.

  • Adds new .circleci/scripts/run-tests.sh for intelligent test sharding and execution using Vitest
  • Moves test execution commands from config.yml to dedicated shell script for better organization
  • Implements CircleCI's test splitting functionality for parallel test execution
  • Updates .editorconfig to enforce single quotes in YAML files
  • Preserves core functionality while enabling partial test reruns

@ghengeveld ghengeveld added build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). labels Jul 9, 2025

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

Comment thread .circleci/scripts/run-tests.sh Outdated
yarn test --reporter=blob --reporter=default $TEST_PATTERNS
else
echo "No test files found for this shard"
exit 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Exit code 0 for no tests could mask CI issues. Consider non-zero exit for unexpected empty shards

Comment thread .editorconfig
@nx-cloud

nx-cloud Bot commented Jul 9, 2025

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 5a86dce

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 15s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-11 09:16:15 UTC

ghengeveld added 10 commits July 9, 2025 10:21
- Ensure .vitest-reports directory exists before test execution
- Create empty test report when no files assigned to shard
- Add robust error handling in store-test-results for missing reports
- Prevent workspace persistence failures on first run with no timing data

Fixes "No test files found for this shard" and workspace persistence
errors that occurred when CircleCI test splitting had no historical
timing data to work with.
- Add output logging for circleci tests glob command before splitting
- Show glob results to understand why test files aren't being found
- Compare find vs circleci tests glob output for troubleshooting

Helps diagnose why "No test files found for this shard" occurs despite
test files being visible to the find command.
@storybook-app-bot

storybook-app-bot Bot commented Jul 9, 2025

Copy link
Copy Markdown

Package Benchmarks

Commit: 5a86dce, ran on 11 July 2025 at 08:59:55 UTC

No significant changes detected, all good. 👏

Comment thread code/core/src/common/utils/cli.test.ts Outdated
@ghengeveld ghengeveld requested review from ndelangen and yannbf July 9, 2025 14:57
@ghengeveld ghengeveld merged commit 53875fe into next Jul 11, 2025
54 checks passed
@ghengeveld ghengeveld deleted the circleci-rerun-tests branch July 11, 2025 14:20
@github-actions github-actions Bot mentioned this pull request Jul 11, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate and enable CircleCI’s “Rerun Failed Tests” feature

2 participants