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

Directly execute build-archive-storybook if we can't resolve it #917

Merged
merged 7 commits into from
Feb 8, 2024

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Feb 8, 2024

In the GitHub action, we cannot import peer dependencies (or anything really). However we should be able to npm exec <bin-command> inside the user's project dir, if the package is installed.

πŸ“¦ Published PR as canary version: 10.9.3--canary.917.7834066638.0

✨ Test out this PR locally via:

npm install chromatic@10.9.3--canary.917.7834066638.0
# or 
yarn add chromatic@10.9.3--canary.917.7834066638.0

@tmeasday tmeasday added release Auto: Create a `latest` release when merged patch Auto: Increment the patch version when merged labels Feb 8, 2024
Copy link
Member

@thafryer thafryer left a comment

Choose a reason for hiding this comment

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

As an eventual follow-up, I'll note a ticket to add some playwright and cypress tests to CI. So, we know if anything breaks as early as possible.

@tmeasday
Copy link
Member Author

tmeasday commented Feb 8, 2024

@tevanoff I managed to get the action to run in the wrong dir and show the error here:

image

Copy link
Contributor

@tevanoff tevanoff left a comment

Choose a reason for hiding this comment

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

All worked in a few different test cases for me! πŸ’―

@tevanoff tevanoff added this pull request to the merge queue Feb 8, 2024
Merged via the queue into main with commit a612bca Feb 8, 2024
20 checks passed
@tevanoff tevanoff deleted the tom/fix-action-e2e branch February 8, 2024 18:12
@ghengeveld
Copy link
Member

πŸš€ PR was released in v10.9.2 πŸš€

@ghengeveld ghengeveld added the released Verdict: This issue/pull request has been released label Feb 8, 2024
@shrink
Copy link

shrink commented Feb 20, 2024

I think this change has caused some important errors to be swallowed. I was encountering an error that presented as follows:

Building your Storybook
    β†’ Running command: npm exec build-archive-storybook --output-dir /tmp/chromatic--1880-VEzc3CPix51U --webpack-stats-json /tmp/chromatic--1880-VEzc3CPix51U
    β†’ [*                   ]
βœ– Failed to import `@chromatic-com/playwright`, is it installed in `package.json`?
    β†’ Command failed: npm exec build-archive-storybook --output-dir /tmp/chromatic--1880-VEzc3CPix51U --webpack-stats-json /tmp/chromatic--1880-VEzc3CPix51U

β„Ή To run `chromatic --playwright` you must have `@chromatic-com/playwright` installed.

So I spent a while debugging my dependencies and trying to find out why @chromatic-com/playwright wasn't available. Anyway, after a while I decided that the error message must be wrong and dug in further by running the npm exec build-archive-storybook command in my Workflow myself which led me to the real error:

Error: Chromatic archives directory cannot be found: /home/runner/work/_/_/test-results/chromatic-archives
Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARCHIVE_LOCATION env var if the output directory for the tests is not in the standard location.

Looking at this change, there's this comment:

// If we tried to run the E2E package's bin directly (due to being in the action)
// and it failed, that means we couldn't find it. This probably means they haven't
// installed the right dependency or run from the right directory

I think that's probably the wrong logic because build-archive-storybook could fail to execute for many different reasons. I think the easiest fix would be to dump out the underlying error (so that there's a clue for someone encountering a different error) or I think the ideal fix would be to limit the missingDependency error to only cases where the dependency was missing.

@tmeasday
Copy link
Member Author

Thanks for the investigation @shrink and that's a great point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Auto: Increment the patch version when merged release Auto: Create a `latest` release when merged released Verdict: This issue/pull request has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants