treosh / lighthouse-ci-action

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

Possibility to combine staticDistDir and urls #123

Open shadovo opened 1 year ago

shadovo commented 1 year ago

Hello! I am trying to use both staticDistDir and urls in the Lighthouse CI Action, but I am having trouble getting them to work together. I would like to use staticDistDir to specify the directory where my static pages are located, and urls to specify a list of specific pages to test. This would allow me to only run Lighthouse on the pages that have changed and speed up my PR builds.

However, I am unsure how to configure the action to use both staticDistDir and urls. Here is an example of the action I am using:

name: Lighthouse
on:
  pull_request:
    branches: ['main']
jobs:
  static-dist-dir:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Lighthouse against a static dist dir
        uses: treosh/lighthouse-ci-action@v9
        with:
          configPath: './lighthouserc.json'
          urls: |
            ${{ list of changed URLs generated by other action }}
          # example of a url: http://localhost/my-changed-page/index.html

And here is my lighthouserc.json file:

{
  "ci": {
    "collect": {
      "staticDistDir": "./build"
    }
  },
  // additional lighthouse assert settings
}

I do get the correct list of changed URLs as input when I look at the build log under Action config > Input args > urls.

I believe that changing line 31 in the index.js file from else if to if would allow me to use both staticDistDir and urls. However, I am not certain if this would work based on the comment on the line below. Could someone please advise me on how to use both staticDistDir and urls together?

Thank you for your help!