GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.34k stars 635 forks source link

The examples for Github actions are missing chrome install #894

Open PGrad opened 1 year ago

PGrad commented 1 year ago

Describe the bug The Github action examples from the official Lighthouse CI documentation simply do not work because they are missing the extra step of installing chrome.

To Reproduce Install the Lighthouse Github app to your repo. Copy and paste the example Github action from here and try running it in pre-flight or with nektos/act.

It will fail because Chrome has not been installed:

| ✅  .lighthouseci/ directory writable
| ✅  Configuration file found
| ❌  Chrome installation not found
| ⚠️   GitHub token not set
| Healthcheck failed!

Expected behavior The github action will succeed and you'll see Lighthouse statuses in your pre-flight that look like this (based on the link above): github_pr_results

It is true that the Troubleshooting section describes how to fix the issue, but it seems like a bad user experience (and a source of a lot of unnecessary Github issues) if every person who runs the example will run into this problem and need to troubleshoot it anew. Why can't @lhci/cli be like puppeteer and install its own version of chrome?

Even in the your own CI tests, you have the additional step of setting CHROME_PATH which is not described in the example.

Environment (please complete the following information):

marty331 commented 1 year ago

@PGrad I'm seeing the same issue, did you find a solution?

wrighttimo commented 1 year ago

@PGrad I'm also experiencing the same issue, is there an available fix?

PGrad commented 1 year ago

@wrighttimo for my case doing CI on ubuntu, I pulled the chrome debian file and then installed it: https://github.com/waterthetrees/wtt_front/blob/main/.github/workflows/lighthouse-ci.yaml#L19

marty331 commented 1 year ago

I ended up solving this by adding the following to my github action script:

-uses: abhi1693/setup-browser@v0.3.4 with: browser: chrome version: latest

kriptonian1 commented 9 months ago

@PGrad I used your solve, but it's throwing error Unable to connect to Chrome here is the whole output

| Running Lighthouse 5 time(s) on http://localhost:3000
| Run #1...failed!
| Error: Lighthouse failed with exit code 1
|     at ChildProcess.<anonymous> (/opt/hostedtoolcache/node/16.20.2/x64/lib/node_modules/@lhci/cli/src/collect/node-runner.js:120:21)
|     at ChildProcess.emit (node:events:513:28)
|     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
| Sun, 15 Oct 2023 09:45:09 GMT LH:ChromeLauncher Waiting for browser.
| Sun, 15 Oct 2023 09:45:09 GMT LH:ChromeLauncher Waiting for browser...
| Sun, 15 Oct 2023 09:45:09 GMT LH:ChromeLauncher Waiting for browser.....
| Sun, 15 Oct 2023 09:45:10 GMT LH:ChromeLauncher Waiting for browser.......
| Sun, 15 Oct 2023 09:45:10 GMT LH:ChromeLauncher Waiting for browser.........
| Sun, 15 Oct 2023 09:45:11 GMT LH:ChromeLauncher Waiting for browser...........
| Sun, 15 Oct 2023 09:45:11 GMT LH:ChromeLauncher Waiting for browser.............
| Sun, 15 Oct 2023 09:45:12 GMT LH:ChromeLauncher Waiting for browser...............
| Sun, 15 Oct 2023 09:45:12 GMT LH:ChromeLauncher Waiting for browser.................
| Sun, 15 Oct 2023 09:45:13 GMT LH:ChromeLauncher Waiting for browser...................
| Sun, 15 Oct 2023 09:45:13 GMT LH:ChromeLauncher Waiting for browser.....................
| Sun, 15 Oct 2023 09:45:14 GMT LH:ChromeLauncher Waiting for browser.......................
| Sun, 15 Oct 2023 09:45:14 GMT LH:ChromeLauncher Waiting for browser.........................
| Sun, 15 Oct 2023 09:45:15 GMT LH:ChromeLauncher Waiting for browser...........................
| Sun, 15 Oct 2023 09:45:15 GMT LH:ChromeLauncher Waiting for browser.............................
| Sun, 15 Oct 2023 09:45:16 GMT LH:ChromeLauncher Waiting for browser...............................
| Sun, 15 Oct 2023 09:45:16 GMT LH:ChromeLauncher Waiting for browser.................................
| Sun, 15 Oct 2023 09:45:17 GMT LH:ChromeLauncher Waiting for browser...................................
| Sun, 15 Oct 2023 09:45:17 GMT LH:ChromeLauncher Waiting for browser.....................................
| Sun, 15 Oct 2023 09:45:18 GMT LH:ChromeLauncher Waiting for browser.......................................
| Sun, 15 Oct 2023 09:45:18 GMT LH:ChromeLauncher Waiting for browser.........................................
| Sun, 15 Oct 2023 09:45:19 GMT LH:ChromeLauncher Waiting for browser...........................................
| Sun, 15 Oct 2023 09:45:19 GMT LH:ChromeLauncher Waiting for browser.............................................
| Sun, 15 Oct 2023 09:45:20 GMT LH:ChromeLauncher Waiting for browser...............................................
| Sun, 15 Oct 2023 09:45:20 GMT LH:ChromeLauncher Waiting for browser.................................................
| Sun, 15 Oct 2023 09:45:21 GMT LH:ChromeLauncher Waiting for browser...................................................
| Sun, 15 Oct 2023 09:45:21 GMT LH:ChromeLauncher Waiting for browser.....................................................
| Sun, 15 Oct 2023 09:45:22 GMT LH:ChromeLauncher Waiting for browser.......................................................
| Sun, 15 Oct 2023 09:45:22 GMT LH:ChromeLauncher Waiting for browser.........................................................
| Sun, 15 Oct 2023 09:45:23 GMT LH:ChromeLauncher Waiting for browser...........................................................
| Sun, 15 Oct 2023 09:45:23 GMT LH:ChromeLauncher Waiting for browser.............................................................
| Sun, 15 Oct 2023 09:45:24 GMT LH:ChromeLauncher Waiting for browser...............................................................
| Sun, 15 Oct 2023 09:45:24 GMT LH:ChromeLauncher Waiting for browser.................................................................
| Sun, 15 Oct 2023 09:45:25 GMT LH:ChromeLauncher Waiting for browser...................................................................
| Sun, 15 Oct 2023 09:45:25 GMT LH:ChromeLauncher Waiting for browser.....................................................................
| Sun, 15 Oct 2023 09:45:26 GMT LH:ChromeLauncher Waiting for browser.......................................................................
| Sun, 15 Oct 2023 09:45:26 GMT LH:ChromeLauncher Waiting for browser.........................................................................
| Sun, 15 Oct 2023 09:45:27 GMT LH:ChromeLauncher Waiting for browser...........................................................................
| Sun, 15 Oct 2023 09:45:27 GMT LH:ChromeLauncher Waiting for browser.............................................................................
| Sun, 15 Oct 2023 09:45:28 GMT LH:ChromeLauncher Waiting for browser...............................................................................
| Sun, 15 Oct 2023 09:45:28 GMT LH:ChromeLauncher Waiting for browser.................................................................................
| Sun, 15 Oct 2023 09:45:29 GMT LH:ChromeLauncher Waiting for browser...................................................................................
| Sun, 15 Oct 2023 09:45:29 GMT LH:ChromeLauncher Waiting for browser.....................................................................................
| Sun, 15 Oct 2023 09:45:30 GMT LH:ChromeLauncher Waiting for browser.......................................................................................
| Sun, 15 Oct 2023 09:45:30 GMT LH:ChromeLauncher Waiting for browser.........................................................................................
| Sun, 15 Oct 2023 09:45:31 GMT LH:ChromeLauncher Waiting for browser...........................................................................................
| Sun, 15 Oct 2023 09:45:31 GMT LH:ChromeLauncher Waiting for browser.............................................................................................
| Sun, 15 Oct 2023 09:45:32 GMT LH:ChromeLauncher Waiting for browser...............................................................................................
| Sun, 15 Oct 2023 09:45:32 GMT LH:ChromeLauncher Waiting for browser.................................................................................................
| Sun, 15 Oct 2023 09:45:33 GMT LH:ChromeLauncher Waiting for browser...................................................................................................
| Sun, 15 Oct 2023 09:45:33 GMT LH:ChromeLauncher Waiting for browser.....................................................................................................
| Sun, 15 Oct 2023 09:45:34 GMT LH:ChromeLauncher Waiting for browser.......................................................................................................
| Sun, 15 Oct 2023 09:45:34 GMT LH:ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:37211
| Sun, 15 Oct 2023 09:45:34 GMT LH:ChromeLauncher:error Logging contents of /tmp/lighthouse.QnF89fc/chrome-err.log
| Sun, 15 Oct 2023 09:45:34 GMT LH:ChromeLauncher:error [1015/094509.228418:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
| 
| Unable to connect to Chrome
| 
[Build project and run Lighthouse CI/Lighthouse CI]   ❌  Failure - Main run Lighthouse CI
[Build project and run Lighthouse CI/Lighthouse CI] exitcode '1': failure
[Build project and run Lighthouse CI/Lighthouse CI] 🏁  Job failed
Error: Job 'Lighthouse CI' failed
rajatscerta commented 3 months ago

Hey guys facing this issue while running it on Github . I have tried all the above solutions but nothing works. Any idea on the solution?

Screenshot 2024-03-29 at 8 36 36 AM