jpvalery / yarn-percy-ci

GitHub Action >> Build with Yarn, Snapshot with Percy
MIT License
3 stars 0 forks source link

Percy can't complete `Error: Failed to launch chrome!` #1

Closed jpvalery closed 5 years ago

jpvalery commented 5 years ago
image
Run jpvalery/yarn-percy-ci@master
/usr/bin/docker run --name bb819dc1ea51feae4d449f5122474204bd4f_52f5e7 --label 04bb81 --workdir /github/workspace --rm -e PERCY_TOKEN -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/montrealphotoclub.en/montrealphotoclub.en":"/github/workspace" 04bb81:9dc1ea51feae4d449f5122474204bd4f
✅ Percy Token specified. Continuing...
✅ Environment ready. Continuing...
✅ Build ready. Continuing...
📷 Snapshotting with Percy...
yarn run v1.12.3
$ /github/workspace/node_modules/.bin/percy snapshot
[percy] created build #2: https://percy.io/MontrealPhotoClub/website.en/builds/2779997
Error: Failed to launch chrome! spawn /github/workspace/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
    at onClose (/github/workspace/node_modules/puppeteer/lib/Launcher.js:348:14)
    at ChildProcess.helper.addEventListener.error (/github/workspace/node_modules/puppeteer/lib/Launcher.js:339:64)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
##[error]Docker run failed with exit code 1

Error links to https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker since it's a docker file for GH actions, I linked to the direct section

Unless it's https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-on-alpine as the Dockerfile specifies FROM node:10.14.1-alpine

jpvalery commented 5 years ago

🤔 Maybe I can reuse what's been built here https://github.com/ianwalter/puppeteer?

@ianwalter hi! hope you're alright. I saw you ran into a similar issue with puppeteer and built an action that works around. Do you think your solution could apply here? Thanks in advance for your help :)

jpvalery commented 5 years ago

Reply from Percy: image

Hi Jp!

Percy uses a Puppeteer browser for asset-discovery while uploading your snapshots. For CI systems, you'll need to use a container with Chrome installed, or install Chrome using some script. I think with GitHub actions, you can specify a docker image to use. You could use an image with pre-built browsers like this:

uses: docker://circleci/node:lts-browsers

Will try this

jpvalery commented 5 years ago

MVP Wil :) This fixed the issue!

Although I’m running into another error now… 😩

2019-10-09T15:35:23.4408115Z 📷 Snapshotting with Percy...
2019-10-09T15:35:28.4865982Z yarn run v1.17.3
2019-10-09T15:35:28.5183179Z warning Skipping preferred cache folder "/github/home/.cache/yarn" because it is not writable.
2019-10-09T15:35:28.5187844Z warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-3434".
2019-10-09T15:35:28.5295651Z $ /github/workspace/node_modules/.bin/percy snapshot
2019-10-09T15:35:28.6026082Z warning Cannot find a suitable global folder. Tried these: "/usr/local, /github/home/.yarn"
2019-10-09T15:35:31.1692925Z [percy] created build #3: https://percy.io/MontrealPhotoClub/website.en/builds/2780707
2019-10-09T15:35:34.2478456Z [percy] percy has started.
2019-10-09T15:35:34.2511135Z [percy] serving static site at http://localhost:5339/
2019-10-09T15:35:38.2625524Z [percy] Failed to navigate to http://localhost:5339/public/404.html, skipping. Error: Error: Protocol error (Page.navigate): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2644424Z [percy] Failed to inject agent JS: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2651519Z [percy] Failed to navigate to http://localhost:5339/public/index.html, skipping. Error: Error: Protocol error (Page.navigate): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2661716Z [percy] Failed to inject agent JS: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2664930Z [percy] Failed to navigate to http://localhost:5339/node_modules/eol/index.html, skipping. Error: Error: Protocol error (Page.navigate): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2672897Z [percy] Failed to inject agent JS: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2679315Z [percy] Failed to navigate to http://localhost:5339/node_modules/gatsby-graphiql-explorer/index.html, skipping. Error: Error: Protocol error (Page.navigate): Session closed. Most likely the page has been closed.
2019-10-09T15:35:38.2687462Z [percy] Failed to inject agent JS: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.

(Then it’s just a repeat through all node_modules)

The full workflow and logs are here https://github.com/MontrealPhotoClub/montrealphotoclub.en/pull/57/checks?check_run_id=253808696

Basically my workflow is to run yarn install > yarn build > my docker action which checks for percy_token, if percy is there, if the site has been built, and then run percy snapshot

Since everything else works great, I’m guessing I’m messing up somewhere and not running yarn percy snapshot in the correct folder?

jpvalery commented 5 years ago

Reply from Percy

The percy snapshot command defaults to the current directory. You'll probably want to use percy snapshot ./public so that only the build directory is snapshotted.

Although I'm not quite sure how that relates to that Protocol error that causes the Puppeteer session to close. If specifying that ./public directory doesn't help, I'll have to dig into the code to see what might be causing that. 🤔

Currently playing with the main.yml workflow in my test repo to see but will try this out right after