Skip to content

Automated Testing: Add GitHub Actions workflow for Storybook smoke testing #69679

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 20 commits into from
Apr 10, 2025

Conversation

im3dabasia
Copy link
Contributor

@im3dabasia im3dabasia commented Mar 24, 2025

What?

Closes #41456

Why?

Code changes can break Storybook stories without anyone noticing until much later. Since our Storybook contains realistic usage examples, broken stories may indicate issues for third-party consumers.

How?

Added a GitHub Actions workflow that:

  1. Runs on pull requests
  2. Builds and serves Storybook
  3. Uses @storybook/test-runner to check all stories render without errors
  4. Properly manages the server process lifecycle

This catches breaking changes early before they're merged.

Screenshots

This is the Action Link
image

@im3dabasia im3dabasia marked this pull request as ready for review March 26, 2025 12:44
@im3dabasia im3dabasia requested a review from desrosj as a code owner March 26, 2025 12:44
Copy link

github-actions bot commented Mar 26, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@im3dabasia
Copy link
Contributor Author

Hi @mirka,

When you have a moment I'd like to hear your thoughts on this Enhancement on our CI/CD Automated testing.
Looking forward to your feedback

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Yes, I think the overall approach of using test-storybook for automated smoke tests is solid!

I don't have the bandwidth to go super deep on reviewing/testing the workflow itself, but a few thoughts I had:

  • Any reason we're doing the pid thing rather than something more like the official example here?
  • And if we do switch to the build-based approach like the example above, maybe we can save time by running the smoke tests in this existing workflow?

@t-hamano t-hamano added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. Storybook Storybook and its stories for components labels Mar 27, 2025
@im3dabasia
Copy link
Contributor Author

Thank you @mirka for your feedback.

I have implemented the necessary changes in this commit: 06a6c1c.

This is the related CI test action from the above commit: Storybook build and Smoke Tests

I've now integrated the concurrently package to properly handle process termination when tests finish. The smoke tests have been incorporated into the existing storybook-check.yml file, and I've renamed the workflow to "Storybook Build and Smoke Tests" to better reflect its expanded functionality.

Since you mentioned you have limited bandwidth, I'll tag @Mamaduka and @t-hamano to continue the review process from here.

Thank you for your guidance!

- name: Install Playwright dependencies
run: npx playwright install

- name: Serve Storybook and run tests
Copy link
Member

Choose a reason for hiding this comment

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

Can "serve" and "run tests" parts be split into separate steps? It can make it more clear what is actually failing when issues are encountered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@desrosj I did that previously, but I was advised that we should follow the example in the Storybook documentation here.

@im3dabasia im3dabasia requested review from mirka and desrosj March 31, 2025 16:22
Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Ok, so all the Playwright tests we added here only seem to be adding a couple minutes to the previous version of the Storybook workflow, which seems reasonable!

Let's keep an eye out for anomalies, and tweak or remove if this turns out to be more trouble than it's worth 😂 I'll preemptively suggest a possible optimization: Historically, certain sections of the Storybook have been more prone to breakage (e.g. Block Editor Playground), so if testing every story ends up being too costly, we could maybe limit it to the problem sections.

Thanks @im3dabasia for your persistence here!

@im3dabasia
Copy link
Contributor Author

Hey @mirka ,

Could we merge these and see how it performs? We'd get a fair idea on if any improvements are needed after testing it in the Pipeline.

Let me know, if further changes are needed .

Regards.

@t-hamano t-hamano merged commit 2fc05aa into WordPress:trunk Apr 10, 2025
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.7 milestone Apr 10, 2025
@t-hamano
Copy link
Contributor

All of the feedback has been addressed, and the GitHub Action logs seem to be as expected, so I've merged it. Let's follow up and improve it as needed.

chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…sting (WordPress#69679)

* feat: Add test-runner and setup smoke tests for storybook

* feat: Add build command

* fix: Script command in package.json

* restore: package-lock from trunk

* restore: Old package.json

* feat: Add storybook package

* fix: Add node in types

* remove: test-runner dep

* fix: Update the smoke test run command

* feat: Dev server to work in bg mode, sleep logic

* fix: yaml file run command

* chore: Add playwright install command

* fix: Add concurrent exition logic when tests are run

* fix: Increase stories timeout and added sleep

* fix: Add timeout between jobs

* chore: Add the smoke tests to storybook-check workflow

* chore: Remove the storybook-test yaml

* fix: Use http-server and removed sleep time

* fix: Update the static path in the yaml

* chore: Add with deps flag in playwright install

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storybook Storybook and its stories for components [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storybook: Add smoke tests
4 participants