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

fix: check no "ERR!" string is in stderr when running Storybook build #3509

Conversation

virtuoushub
Copy link
Collaborator

@virtuoushub virtuoushub commented Oct 5, 2021

Avoid false positive. It seems stderr contains info as well as error, so just checking if it is '' will not work.

See Also:

cc: @thedavidprice


note: while #3154 looks to fix the "connection time out" error we were seeing in CI checks; speaking from experience, there still can be inadvertent regressions added to the CI when upgrading Storybook, or other "unrelated" dependencies. This PR ( and #3508 even though the check was wrong ) makes sure that if there are build errors output, the stderr is surfaced to the CI so that maintainers can more easily see the potential issue.

hope to avoid `Cannot read properties of undefined (reading 'split')`
see: https://github.com/redwoodjs/redwood/runs/3802028363?check_suite_focus=true
@thedavidprice
Copy link
Contributor

thedavidprice commented Oct 5, 2021

Ok, I'm following you here and the Cypress changes are really helpful to see (I personally am not very experienced with Cypress outside this project).Bare with me as I walk through a thought process that got us here.

This is all just fwiw exploration. I'm game to punt on further exploration and just merge this as is.

False positives and false negatives == why even try 🤷‍♂️

Admittedly this is a hacky, brittle way to test Storybook. It's actually my hack, inspired by the facts 1) we don't have a way to both start and stop a Storybook process using Cypress in this manner (also, resource constraints) and 2) we already have yarn rw dev running which is serving static assets in web/public. Viola... Hack!

So we run into scenarios like this one, where the Storybook spec is failing, but yet it's not really failing. When I run yarn rw sb --build locally I get warnings but no errors:

SB --build locally
info @storybook/react v6.3.8
info 
info => Cleaning outputDir: /Users/price/Repos/tdp-redwood-tutorial-test/web/public/storybook
info => Loading presets
info => Compiling manager..
info => Compiling preview..
info => Loading custom babel config as JS
info => Loading custom babel config as JS
info => Loading 1 config file in "/Users/price/Repos/tdp-redwood-tutorial-test/node_modules/@redwoodjs/testing/config/storybook"
info => Loading 2 other files in "/Users/price/Repos/tdp-redwood-tutorial-test/node_modules/@redwoodjs/testing/config/storybook"
info => Adding stories defined in "/Users/price/Repos/tdp-redwood-tutorial-test/node_modules/@redwoodjs/testing/config/storybook/main.js"
info => Using implicit CSS loaders
info => Using default Webpack5 setup
92% sealing asset processing TerserPlugininfo => Manager built (12 s)
info => Preview built (21 s)
WARN DefinePlugin
WARN Conflicting values for 'process.env'
WARN asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
WARN This can impact web performance.
WARN Assets: 
WARN   main.ff1be6a9.iframe.bundle.js (1.86 MiB)
WARN entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
WARN Entrypoints:
WARN   main (1.86 MiB)
WARN       static/css/main.62eb66b7.css
WARN       main.ff1be6a9.iframe.bundle.js
WARN 
info => Output directory: /Users/price/Repos/tdp-redwood-tutorial-test/web/public/storybook

And even in the output from #3508 there were no Errors in the stderr:

Sanity check --> are you seeing something different locally and in the CI runs? Maybe there's a Storybook error buried in there somewhere that needs to be resolved. (But in that case I don't understand why this one is passing...?)

So why was the spec failing?

We've ended up assuming that failures like this are just resource constraints and can't be resolved until we rewrite tests for these cases using something other than Cypress.

@virtuoushub are you seeing something different locally and in the CI runs? It's possible I'm just missing real errors

But maybe what you're doing here is resolving an issue we had with the cy.exec never "returning" anything (error or success), so Cypress was either timing out or waiting or trying to move to the next step before the build process was complete.

I don't know Cypress well enough to know. But given that this is passing, do you think there's actually an improvement beyond error capture?

An alternate test

Originally, we just wanted to check if start-storybook would successfully run the process. This would include the step to build the stories and then fire up the Storybook server.

At one time I looked into using yarn start-storybook --smoke-test, which is designed for this use case. See my draft PR here:

I didn't finish it because I never worked through how to "capture" the output to check in Cypress.

I'll defer to you, but would you be interested in exploring a full replacement of this current Storybook spec with a way to use --smoke-test? (In which case, we wouldn't worry about doing E2E on the individual stories... that's not necessary.)

Note: you can try this locally by passing the path to the Storybook config you see when you run yarn rw sb. E.g:

yarn build-storybook --config-dir path-to-project/node_modules/@redwoodjs/testing/config/storybook --output-dir path-to/output-dir

@virtuoushub
Copy link
Collaborator Author

I'll defer to you, but would you be interested in exploring a full replacement of this current Storybook spec with a way to use --smoke-test? (In which case, we wouldn't worry about doing E2E on the individual stories... that's not necessary.)

Yes, that interests me.

I do advocate in the short term we go with this fix as "hacky" as it is. There is still some value in the checks as they are.

I opened #3511 to illustrate how this change might surface actual build errors.

virtuoushub added a commit to virtuoushub/redwood that referenced this pull request Oct 5, 2021
virtuoushub added a commit to virtuoushub/redwood that referenced this pull request Oct 5, 2021
chore: take in changes from redwoodjs#3509 to illustrate build failures
@thedavidprice
Copy link
Contributor

I do advocate in the short term we go with this fix as "hacky" as it is.

Agreed! Merging now (and letting my original hack continue to propagate).

Will continue discussion in #3511

@thedavidprice thedavidprice merged commit 21f2a49 into redwoodjs:main Oct 5, 2021
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Oct 5, 2021
@virtuoushub virtuoushub deleted the chore/improve-stderr-check-in-storybook-e2e branch October 7, 2021 09:33
@thedavidprice thedavidprice modified the milestones: next-release, v0.38.0 Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants