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

monorepo build fails due to storybookBaseDir check in v11.3.1 #975

Closed
Shunya078 opened this issue May 7, 2024 · 7 comments · Fixed by #976
Closed

monorepo build fails due to storybookBaseDir check in v11.3.1 #975

Shunya078 opened this issue May 7, 2024 · 7 comments · Fixed by #976
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation

Comments

@Shunya078
Copy link

Bug report

We have TurboSnap enabled in monorepo.

The working dir configuration is as follows

.
├── config file
├── backend
│   ├── ...
│   ...
│
├── frontend
│   ├── .storybook
│   ├── apps
│   │    ├── appA
│   │    │   ├── .storybook
│   │    ├── appB
│   │    │   ├── .storybook
│   │    ├── ...
│   │    ...
│   └── package.json
│
├── config file

In the previous configuration, the build succeeded by specifying the workingDir: frontend. (Until v11.3.0)

Starting with v11.3.1, if storybookBaseDir: frontend is not specified, the build will fail.

Is this an intentional change?
If so, it would be a destructive change, so I will create an issue here just in case.

In v11.3.1, chromaui logs of failed builds are listed below.

10:44:51.772      → Traversing dependencies for 6 files that changed since the last build
10:44:51.789  Storybook base directory: /home/runner/work/app
10:44:51.794  Not found: /home/runner/work/app/sb-preview/runtime.js
10:44:51.795  Not found: /home/runner/work/app/virtual:/@storybook/builder-vite/vite-app.js
...
10:44:51.818  Failed to retrieve dependent story files {"statsPath":"/tmp/chromatic--...","changedFiles":[".github/..."],"err":{}}
10:44:51.819      → Could not retrieve dependent story files.
              ✖ TurboSnap disabled until base directory is set correctly
              The base directory allows TurboSnap to trace files.
              Set the --storybook-base-dir option as the relative path from the repository root to the Storybook project root.

In v11.3.0, chromaui is able to find the dir where the storybook is located.

11:37:09.882  Storybook base directory: 
11:37:09.887  Not found: sb-preview/runtime.js
11:37:09.888  Not found: /virtual:/@storybook/builder-vite/vite-app.js
11:37:09.888  Not found: /virtual:/@storybook/builder-vite/setup-addons.js
11:37:09.888  Not found: /virtual:/@storybook/builder-vite/storybook-stories.js
11:37:09.900  BASE Directory: frontend
11:37:09.900  Storybook CONFIG Directory: frontend/.storybook
11:37:09.903  Found affected story files:
@Shunya078 Shunya078 added bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation labels May 7, 2024
@Shunya078
Copy link
Author

Shunya078 commented May 7, 2024

I think the priority is to maintain compatibility, and since it appears to be stuck in a error callback (Maybe try/catch...), I think the following corrective approach should be taken.

  • Check ctx.options.storybookBaseDir at the upload.ts
    • but... i think there is a better approach as knowing the contents of the ctx is out of the responsibilities.
- await checkStorybookBaseDir(ctx, stats);
+ ctx.options.storybookBaseDir !== '' && await checkStorybookBaseDir(ctx, stats);

await checkStorybookBaseDir(ctx, stats);

@repomadness
Copy link

@Shunya078 there were some changes made on #974 that resulted in Chromatic adjusting how storybookBaseDir is checked. Prior to v.11.3.1, storybookBaseDir was checked as a relative path whereas it is now we use the repository root instead of the cwd to check the value. If you add storybookBaseDir and make sure the value is relative from the repository root, it should resolve the error.

@Shunya078
Copy link
Author

Shunya078 commented May 8, 2024

Thanks, @repomadness .

In my repository, v11.3.1 with storybookBaseDir works as before v11.3.0 without any problem.

However, my concern is that #974 makes storybookBaseDir required for monorepo users.

If v11.3.1 is to be compatible with v11.3.0 and earlier, it should not exit on fallback.

If it is not necessary to maintain compatibility, this issue may be closed, but it is necessary to inform developers of this issue through the Document, Release Note, JSDoc, etc.
If any of these tasks are necessary, please feel free to let me know and I will create a pull request.

@hayashi-ay
Copy link

Temporary workaround for those using the chromaui/action in Github Actions: specify v11.3.0 as the version to avoid this issue until it is resolved in a future release.

      - name: Publish to Chromatic
        uses: chromaui/action@v11.3.0

@ghengeveld
Copy link
Member

Thanks all for chiming in. I overlooked that the current behavior for storybookBaseDir is for it to default to the current working directory relative to the Git repository root. The storybookBaseDir check that was updated in v11.3.1 did not account for that behavior. I've put up #976 to address this oversight and will try to get this released soon.

@Shunya078
Copy link
Author

@ghengeveld
Thanks for the quick fix !!
Using v11.3.2, I was able to confirm locally that it works with the same configuration as v11.3.0!

@ghengeveld
Copy link
Member

Thanks, good to know it works for you! 🧡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working needs triage Tracking: Issue needs confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants