treosh / lighthouse-ci-action

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

Access more detailed metrics #132

Open maecapozzi opened 1 year ago

maecapozzi commented 1 year ago

Hey! Thanks for this Github action. It's been a great way to programmatically check our scores.

I know the lighthouse node module allows us to access more detailed metrics, like TTI and FCP. While I'm able to access the summary from the manifest, I'd like more than just the top level scores like "performance" and "best practices".

This is what I'm doing right now:

 - name: Display Lighthouse Audit Results
        uses: actions/github-script@v6
        id: set-result
        env:
          MANIFEST: ${{ steps.lighthouse.outputs.manifest }}
        with:
          script: |
            const script = require('./lighthouse-audits/results.js');
            script();
          result-encoding: string

Then I'm accessing the manifest in ./lighthouse-audits/results.js like this:

  const { MANIFEST } = process.env;
   const manifest = JSON.parse(MANIFEST);

Can we expose more detailed metrics in the manifest?

Nierdhaza commented 9 months ago

I would also like to see more metrics as FCP, LCP, TTI, TBT etc.

maecapozzi commented 9 months ago

I was able to capture more detailed metrics, but it was relatively challenging. Here's a snippet of what I did, which will hopefully help other people!

 - name: Download result of lighthouse-audit
        uses: actions/download-artifact@v3
        id: download
        with:
          name: lighthouse-results
          path: ${{ github.workspace }}/lighthouse-results

      - name: Display Lighthouse Audit Results
        uses: actions/github-script@v6
        id: set-result
        env:
          WORKSPACE: ${{ steps.download.outputs.download-path }}
        with:
          script: |
            const script = require('./lighthouse-audits/results.js');

            script();
          result-encoding: string