treosh / lighthouse-ci-action

Audit URLs using Lighthouse and test performance with Lighthouse CI.
MIT License
1.16k stars 82 forks source link

Puppeteer support #37

Closed PaulKujawa closed 4 years ago

PaulKujawa commented 4 years ago

My workflow links a config file, that in return links a puppeteerScript. This works locally when running lhci with puppeteer globally installed, but I attempted to get it running with this Action in vain. I tried a regular npm dependency as well as the Action ianwalter/puppeteer@v2.0.0.

// workflow.yml
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps: 
      - uses: actions/checkout@v1
      - uses: treosh/lighthouse-ci-action@v2
        with:
          budgetPath: ./lighthouse-budget.json
          configPath: ./lighthouse.json
   //   ...
// lighthouse.json
{
  "ci": {
    "assert": {
      "preset": "lighthouse:recommended"
    },
    "collect": {
      "numberOfRuns": 3,
      "puppeteerScript": "./lighthouse-login.js"
    },
    "upload": {
      "target": "temporary-public-storage"
    }
  }
}
Run treosh/lighthouse-ci-action@v2
Action config
Collecting
  Error: Cannot find module 'puppeteer'
  Require stack:
  - /home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/collect/puppeteer-manager.js
  - /home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/collect/collect.js
  - /home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/cli.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
      at Function.Module._load (internal/modules/cjs/loader.js:690:27)
      at Module.require (internal/modules/cjs/loader.js:852:19)
      at require (internal/modules/cjs/helpers.js:74:18)
      at PuppeteerManager._getBrowser (/home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:27:23)
      at PuppeteerManager.invokePuppeteerScriptForUrl (/home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:58:32)
      at Object.runCommand (/home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/collect/collect.js:176:23)
  ##[error]LHCI 'collect' has encountered a problem.
  done in 1.17184977s
      at async run (/home/runner/work/_actions/treosh/lighthouse-ci-action/v2/node_modules/@lhci/cli/src/cli.js:84:7)
alekseykulikov commented 4 years ago

Hey! It seems you are missing npm install to install puppeteer dependency, before running the action:

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps: 
      - uses: actions/checkout@v1
      - run: npm install
      - uses: treosh/lighthouse-ci-action@v2
        with:
          budgetPath: ./lighthouse-budget.json
          configPath: ./lighthouse.json

Also, could you try the latest version of the action, that uses lhci v0.3.10, which adds some puppeteer fixes?

It would be great, to add a puppeteer recipe #20

PaulKujawa commented 4 years ago

Ah, right, silly me!