-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add storybook ci option to test that Storybook starts "ok" #3515
Add storybook ci option to test that Storybook starts "ok" #3515
Conversation
@thedavidprice - I am fairly certain where the exit code of With this knowledge, I was able to hack around the conditional logic by adding a dummy - ci && '--ci --smoke-test',
+ ci && '--ci --smoke-test --preview-url "ci"', |
@virtuoushub definitely looks like you're on to something here! (And, oh my, huge respect for the time it took to dig through SB's source... always an adventure.) Using this PR code via the GitPod workspace , I ran into a false positive when I try to force an error (surprisingly hard with SB). Here's how you can reproduce:
+ import StoryRouter from 'storybook-react-router'
import BlogPost from './BlogPost'
export const generated = () => {
return <BlogPost />
}
- export default { title: 'Components/BlogPost' }
+ export default { title: 'Components/BlogPost', decorators: [StoryRouter()] }
Looking at the source you highlighted, maybe you can also try including |
Was able to reproduce the false positive using your steps, thanks for these. notes: Using To see what is going on with the warning that is causing the exit code of - if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${previewWarnings}`);
+ if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`); this results in: ...
WARN preview: [
WARN {
WARN "message": "DefinePlugin\nConflicting values for 'process.env'",
WARN "details": "'{NODE_ENV: \"development\", NODE_PATH: [], STORYBOOK: \"true\", PUBLIC_URL: \".\"}' !== '\"MISSING_ENV_VAR\"'",
WARN "stack": "Error: DefinePlugin\nConflicting values for 'process.env'\n at /workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:573:24\n at Array.forEach (<anonymous>)\n at walkDefinitionsForValues (/workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:564:31)\n at /workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:591:5\n at Hook.eval [as call] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:291:1)\n at Hook.CALL_DELEGATE [as _call] (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)\n at Compiler.newCompilation (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1053:26)\n at /workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1097:29\n at Hook.eval [as callAsync] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)\n at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)\n at Compiler.compile (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1092:28)\n at /workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Watching.js:200:19\n at _next0 (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)\n at eval (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)\n at watchRunHook (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack-virtual-modules/lib/index.js:236:13)\n at Hook.eval [as callAsync] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)"
WARN }
WARN ]
... I think if we solve for this warning then |
It seems https://github.com/redwoodjs/redwood/blob/main/packages/core/config/webpack.common.js#L150-L156 might hold the key to resolving that warning. #742 looks related to Storybook, but it seems all that did is just shuffle around the above linked code block to allow it to be a shared plugin. I might need some help with webpack as I am a little out of my depth. (cc @peterp) |
@virtuoushub nice work here, pulling back the layers. I don't have much time to work on this now, but relaying a couple things that come to mind:
My guess is that something from |
I had tried leveraging
Not sure if something changed, but I was able to run with
|
Sorry for the slow response on this. Can you please tell me how to run this locally so I can debug the SB side? Thanks! 🙏 |
No worries @shilman, in terms of locally I might defer to @thedavidprice as to the most up to date how-to. I used the contributing guide myself. That being said, I have found the easiest way to get this PR running is via - Gitpod and then follow @thedavidprice's steps to reproduce comment |
@shilman Huge thank you for taking time to look at this. We got to this point because we're trying to improve our Storybook CI check. And our primary question is:
Note: to see the behavior, you'll need to edit this file: L68 👉 Here's a video walkthrough (under 5 mins!) that will get you up and running in a jiffy. GoogleChrome-26Oct21_20-19-58.mp4Links to FilesThe directories and files I mention in the video:
Dev Stuffz
|
@shilman gentle nudge |
be4ea3d
to
7ad48bb
Compare
@thedavidprice Sorry your gentle nudge got lost in the infinite sea of notifications & crazy SB 6.4 release. Thanks for the wonderful instructions, I'll take a proper look today!! |
Thanks again for your amazing instructions and great DX 😍 Based on a first pass, I think the problem is on the Redwood side. On a standalone project running SB6.3 I did the following $ yarn storybook --ci --smoke-test
$ echo $?
0 Then I introduced some errors:
This is all what I would expect. Introducing the I took a quick look at the |
^^ Saw the news about 6.4 but haven't dug in. Re: 6.5 Would be very excited to talk test runner. We just got v1-rc out with the goal to hit GA in Q1. So after the holidays could be a great time to get our heads together and plot a course 🚀 -- Thank you for taking another look at this. It's definitely hard to parse what's going on because there's layers of config and commands wrapping commands. But mentioning execa gave me an idea about how we can simplify diagnosing this. Under the hood, here's the command that's run from the
Reproduce --smoke-test exit(1)We can use my test project, currently at the latest version, to run the commands without wrappers.
The question --> any idea why step 6 works but 7 and 8 exit(1)? 🤷♂️ Step 6 (start-storybook) SuccessStep 7 and 8 (--smoke-test) exit with erro |
@thedavidprice - you might be able to leverage my hack from earlier where we modify - if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${previewWarnings}`);
+ if (previewWarnings.length > 0) _nodeLogger.logger.warn(`preview: ${JSON.stringify(previewWarnings, null, 2)}`); that way we can better see what is going on with
and hopefully determine why steps 7 & 8 are exit(1)ing. |
@thedavidprice There was a bug in the debugging output. It should have read:
So there are a few things going on here:
EDIT: @virtuoushub I see you've already gone through all this above. apologies for restating! |
28ab311
to
432b55b
Compare
@shilman - any advice on how to resolve this:
It looks to have started when I bumped to SB6.4 |
Heroic effort on this one @virtuoushub If you add up all the time we're about to save not having to wait as long on CI to pass, it was very very very worth it. Thank you again 🚀 |
…s-setup * 'main' of github.com:redwoodjs/redwood: (87 commits) Update scripts tsconfig (#4258) Update dependency @types/aws-lambda to v8.10.92 (#4260) Update dependency @apollo/client to v3.5.8 (#4262) Update dependency msw to v0.36.7 (#4252) Update typescript-eslint monorepo to v5.10.1 (#4256) Update dependency webpack-cli to v4.9.2 (#4254) Update dependency @supabase/supabase-js to v1.29.4 (#4253) Update dependency supertokens-auth-react to v0.18.4 (#4255) Update dependency ts-morph to v13.0.3 (#4251) Update dependency supertokens-auth-react to v0.18.3 (#4248) Update dependency esbuild to v0.14.13 (#4249) Fixed netlify api config (#4247) Add storybook ci option to test that Storybook starts "ok" (#3515) Update dependency react-hook-form to v7.25.0 (#4245) Update dependency firebase-admin to v10.0.2 (#4244) Fix type definitions for pages that take props (#4219) update yarn.lock v0.42.1 update yarn.lock Pin dependency @types/yargs to v16.0.4 (#4243) ...
@@ -172,6 +172,7 @@ const getSharedPlugins = (isEnvProduction) => { | |||
new Dotenv({ | |||
path: path.resolve(redwoodPaths.base, '.env'), | |||
silent: true, | |||
ignoreStub: true, // FIXME: this might not be necessary once the storybook webpack 4/5 stuff is ironed out. See also: https://github.com/mrsteele/dotenv-webpack#processenv-stubbing--replacing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @virtuoushub, me again! We have a small regression caused by this change here. Wondering if you could give me a little more context to what this change was for/why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, the Storbook --ci and --smoke-test flags were failing. (Please correct me if I am wrong.)
FYI, Pete, Danny is going to remove Dotenv entirely over here #4334 Based on all the research you did, any reaction as to whether this removal will have downstream affect on Storybook config? (We are assuming none.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dac09 , it was added to avoid:
...
WARN preview: [
WARN {
WARN "message": "DefinePlugin\nConflicting values for 'process.env'",
WARN "details": "'{NODE_ENV: \"development\", NODE_PATH: [], STORYBOOK: \"true\", PUBLIC_URL: \".\"}' !== '\"MISSING_ENV_VAR\"'",
WARN "stack": "Error: DefinePlugin\nConflicting values for 'process.env'\n at /workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:573:24\n at Array.forEach (<anonymous>)\n at walkDefinitionsForValues (/workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:564:31)\n at /workspace/rw-test-app/node_modules/webpack/lib/DefinePlugin.js:591:5\n at Hook.eval [as call] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:291:1)\n at Hook.CALL_DELEGATE [as _call] (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)\n at Compiler.newCompilation (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1053:26)\n at /workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1097:29\n at Hook.eval [as callAsync] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)\n at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)\n at Compiler.compile (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1092:28)\n at /workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Watching.js:200:19\n at _next0 (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)\n at eval (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)\n at watchRunHook (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack-virtual-modules/lib/index.js:236:13)\n at Hook.eval [as callAsync] (eval at create (/workspace/rw-test-app/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)"
WARN }
WARN ]
...
See also: #3515 (comment)
@thedavidprice , I think the removal should be safe; 🤞🏻 that the smoke test catches a regression if I am wrong.
meant to avoid: ```sh ... Error: PostCSS plugin autoprefixer requires PostCSS 8. ... ``` redwoodjs#3515 (comment) parcel-bundler/parcel#5160
meant to avoid: ```sh ... Error: PostCSS plugin autoprefixer requires PostCSS 8. ... ``` redwoodjs#3515 (comment) parcel-bundler/parcel#5160
meant to avoid: ```sh ... Error: PostCSS plugin autoprefixer requires PostCSS 8. ... ``` redwoodjs#3515 (comment) parcel-bundler/parcel#5160
fix: pin `autoprefixer` meant to avoid: ```sh ... Error: PostCSS plugin autoprefixer requires PostCSS 8. ... ``` redwoodjs#3515 (comment) parcel-bundler/parcel#5160 chore: test using `yarn`'s `resolutions` see: https://stackoverflow.com/a/66825007
fix: pin `autoprefixer` meant to avoid: ```sh ... Error: PostCSS plugin autoprefixer requires PostCSS 8. ... ``` redwoodjs#3515 (comment) parcel-bundler/parcel#5160 chore: test using `yarn`'s `resolutions` see: https://stackoverflow.com/a/66825007
Test to move away from current "e2e" approach with Cypress for Storybook, and towards leveraging the Storybook CLI tooling.
See: