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

Core: Introduce run over play in portable stories, and revert back play changes of 8.2 #28764

Merged
merged 19 commits into from
Jul 31, 2024

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Jul 31, 2024

What I did

We overloaded the play function in 8.2, so that it could be used to run the whole story when testingLibraryRender is set.

However, we found out that this design is hard to understand and doesn't work when you want to reuse a play function of one story in another story. Especially when we would move to CSF4 where every story will be portable by default.

Therefore we are introducing a new method of composeStories called run. Which is not overloaded, and will always run the whole story, including loaders, beforeEach, mount and play.

We are reverting that change. If you are already started using testingLibraryRender in combination with play it means that you need to move from using .play to .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/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 76.4 MB 76.4 MB 798 B 1.44 0%
initSize 198 MB 198 MB 599 B 1 0%
diffSize 122 MB 122 MB -199 B 0.94 0%
buildSize 7.6 MB 7.6 MB 316 B 3.64 0%
buildSbAddonsSize 1.63 MB 1.63 MB 192 B 13.56 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 0 B - 0%
buildSbPreviewSize 349 kB 349 kB 124 B Infinity 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.47 MB 4.47 MB 316 B 21.6 0%
buildPreviewSize 3.12 MB 3.12 MB 0 B 1.22 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 23.6s 7.4s -16s -183ms -1.17 -217.7%
generateTime 21.7s 22s 217ms -0.24 1%
initTime 24.6s 22s -2s -636ms -0.62 -12%
buildTime 14.7s 14.8s 150ms 0.58 1%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.9s 8.6s 677ms -0.33 7.8%
devManagerResponsive 5.2s 6s 842ms -0.01 13.9%
devManagerHeaderVisible 815ms 776ms -39ms -0.76 -5%
devManagerIndexVisible 821ms 785ms -36ms -0.88 -4.6%
devStoryVisibleUncached 1.3s 1.1s -129ms -0.95 -10.9%
devStoryVisible 885ms 834ms -51ms -0.75 -6.1%
devAutodocsVisible 730ms 727ms -3ms -0.81 -0.4%
devMDXVisible 738ms 760ms 22ms -0.2 2.9%
buildManagerHeaderVisible 685ms 734ms 49ms -0.92 6.7%
buildManagerIndexVisible 689ms 737ms 48ms -0.95 6.5%
buildStoryVisible 738ms 787ms 49ms -0.93 6.2%
buildAutodocsVisible 689ms 708ms 19ms -0.69 2.7%
buildMDXVisible 620ms 681ms 61ms -0.74 9%

Copy link

nx-cloud bot commented Jul 31, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2772623. 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.

@kasperpeulen kasperpeulen added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Jul 31, 2024
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, 30 comment(s)
Edit PR Review Bot Settings

@@ -44,7 +44,8 @@ export type ComposedStoryFn<
> = PartialArgsStoryFn<TRenderer, TArgs> & {
args: TArgs;
id: StoryId;
play: (context?: Partial<StoryContext<TRenderer, Partial<TArgs>>>) => Promise<void>;
play?: (context?: Partial<StoryContext<TRenderer, Partial<TArgs>>>) => Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Making play optional might cause issues if existing code relies on it being present.

code/core/src/types/modules/composedStory.ts Show resolved Hide resolved
@@ -117,6 +117,6 @@ it('should pass with decorators that need addons channel', () => {
// Batch snapshot testing
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName, Story]);
it.each(testCases)('Renders %s story', async (_storyName, Story) => {
await Story.play();
await Story.run();
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Verify that the run function maintains the same performance characteristics as play.

Copy link
Contributor

github-actions bot commented Jul 31, 2024

Fails
🚫 PR is marked with "BREAKING CHANGE" label.

Generated by 🚫 dangerJS against 2772623

docs/api/portable-stories/portable-stories-jest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-vitest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-vitest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-jest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-vitest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-jest.mdx Outdated Show resolved Hide resolved
docs/api/portable-stories/portable-stories-playwright.mdx Outdated Show resolved Hide resolved
@yannbf yannbf added ci:daily Run the CI jobs that normally run in the daily job. and removed ci:normal labels Jul 31, 2024
kasperpeulen and others added 2 commits July 31, 2024 15:50
Co-authored-by: Yann Braga <yannbf@gmail.com>
Co-authored-by: Yann Braga <yannbf@gmail.com>
@kasperpeulen kasperpeulen merged commit 3b65e72 into next Jul 31, 2024
102 of 104 checks passed
@kasperpeulen kasperpeulen deleted the kasper/introduce-run branch July 31, 2024 14:33
kasperpeulen added a commit that referenced this pull request Aug 1, 2024
Core: Introduce run over play in portable stories, and revert back play changes of 8.2
(cherry picked from commit 3b65e72)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE ci:daily Run the CI jobs that normally run in the daily job. patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants