Skip to content
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

Addon Test: Fix run request while booting or restarting Vitest #29829

Merged
merged 9 commits into from
Dec 6, 2024

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Dec 6, 2024

Fixes #29784

What I did

  • Added an event queue for events that come in while Vitest is booting, and resends them as soon as Vitest is ready.
  • Added a vitestRestartPromise which is pending while Vitest is restarting, and is awaited before starting a test run.
  • Cleared progress when starting a new test run.

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>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B -1.41 0%
initSize 130 MB 130 MB 168 B -1.27 0%
diffSize 52.5 MB 52.5 MB 168 B 1.36 0%
buildSize 6.75 MB 6.75 MB 56 B Infinity 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 56 B Infinity 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.57 MB 3.57 MB 56 B Infinity 0%
buildPreviewSize 3.19 MB 3.19 MB 0 B - 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 6.4s 6.5s 49ms -0.83 0.8%
generateTime 18.8s 20.6s 1.8s -0.05 9%
initTime 12.1s 15.1s 2.9s 1.8 🔺19.6%
buildTime 8.9s 7.6s -1s -334ms -1.95 🔰-17.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.6s 4.2s -412ms -1.09 -9.7%
devManagerResponsive 3.5s 3.1s -365ms -0.97 -11.6%
devManagerHeaderVisible 509ms 503ms -6ms -1.09 -1.2%
devManagerIndexVisible 573ms 533ms -40ms -1.97 🔰-7.5%
devStoryVisibleUncached 1.7s 1.7s -51ms -0.53 -2.9%
devStoryVisible 574ms 530ms -44ms -2.19 🔰-8.3%
devAutodocsVisible 505ms 515ms 10ms 1.67 1.9%
devMDXVisible 499ms 463ms -36ms -2.08 🔰-7.8%
buildManagerHeaderVisible 530ms 485ms -45ms -1.92 🔰-9.3%
buildManagerIndexVisible 606ms 550ms -56ms -2.09 🔰-10.2%
buildStoryVisible 491ms 443ms -48ms -2.35 🔰-10.8%
buildAutodocsVisible 381ms 383ms 2ms -0.66 0.5%
buildMDXVisible 403ms 389ms -14ms -1.72 -3.6%

Greptile Summary

Improved test run handling in Storybook's Vitest integration by adding event queuing during boot/restart phases and proper state management through promises.

  • Added event queue in boot-test-runner.ts to store and replay events that occur while Vitest is initializing
  • Added vitestRestartPromise in vitest-manager.ts to properly sequence operations during Vitest restarts
  • Refactored static file handling to be synchronous in server-statics.ts for better startup reliability
  • Fixed state management in experimental_testmodule.ts to correctly handle test provider state clearing and progress tracking
  • Added proper error handling for static directory configuration in Vitest plugin integration

@ghengeveld ghengeveld changed the base branch from next to 29772-bug-staticdirs-api-not-compatible-with-vitest-plugin December 6, 2024 09:28
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

code/addons/test/src/node/test-manager.ts Outdated Show resolved Hide resolved
code/addons/test/src/node/boot-test-runner.ts Show resolved Hide resolved
code/addons/test/src/node/boot-test-runner.ts Show resolved Hide resolved
code/addons/test/src/node/vitest-manager.ts Outdated Show resolved Hide resolved
Copy link

nx-cloud bot commented Dec 6, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d0f080b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Base automatically changed from 29772-bug-staticdirs-api-not-compatible-with-vitest-plugin to next December 6, 2024 14:09
@ghengeveld ghengeveld merged commit 4d550be into next Dec 6, 2024
57 checks passed
@ghengeveld ghengeveld deleted the fix-run-during-boot-or-restart branch December 6, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing Module doesn't communicate properly that Vitest is unresponsive/restarting
2 participants