google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.23k stars 279 forks source link

Storybook error during build: `Error: Source and destination must not be the same.` #9220

Closed aaemnnosttv closed 1 week ago

aaemnnosttv commented 3 weeks ago

Bug Description

A warning is raised when building storybook that indicates a rejected promise but does not break the build.

Steps to reproduce

  1. Run npm run build:storybook
  2. Observe

Example

Run npm run test:visualtest

> googlesitekit@ pretest:visualtest /home/runner/work/site-kit-wp/site-kit-wp
> VRT=1 npm run build:storybook

> googlesitekit@ prebuild:storybook /home/runner/work/site-kit-wp/site-kit-wp
> npm run remove-dist

> googlesitekit@ remove-dist /home/runner/work/site-kit-wp/site-kit-wp
> rimraf ./dist

> googlesitekit@ build:storybook /home/runner/work/site-kit-wp/site-kit-wp
> build-storybook -c .storybook -o dist --quiet --loglevel warn

attention => Storybook now collects completely anonymous telemetry regarding usage.
This information is used to shape Storybook's roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://storybook.js.org/telemetry

(node:2623) UnhandledPromiseRejectionWarning: Error: Source and destination must not be the same.
    at /home/runner/work/site-kit-wp/site-kit-wp/node_modules/fs-extra/lib/util/stat.js:39:17
    at cb (util.js:290:31)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2623) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2623) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
info => Using PostCSS preset with postcss@7.0.39

https://github.com/google/site-kit-wp/actions/runs/10485387462/job/29044590798?pr=9195#step:5:27


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

benbowler commented 2 weeks ago

This appears to be down to this addition to the storybook config: https://github.com/google/site-kit-wp/blob/525342100d60df54fbe295d2f6be68e0af49ef4a/.storybook/main.js#L44

This line is asking storybook to add it's own build folder as static assets to it's build which leads to a call to fs-extra which is trying to copy /dist to /dist which causes the error.

Removing this line removes the error and the storybook build is unchanged.

aaemnnosttv commented 2 weeks ago

Nice find, thanks @benbowler !

IB ✅