treosh / lighthouse-ci-action

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

`assertionResults` output is empty. #142

Closed b3nk3 closed 3 months ago

b3nk3 commented 3 months ago

I've got the following workflow (showing relevant bits only)

When I log out assertionResults they are empty. The artifact also has an empty array in the .json file.

      - name: Run Lighthouse on urls and validate with lighthouserc
        id: lighthouse_audit
        uses: treosh/lighthouse-ci-action@v12
        with:
          configPath: './lighthouserc.js'
          uploadArtifacts: true
          temporaryPublicStorage: true

      - name: Format lighthouse score
        if: always()
        id: format_lighthouse_score
        uses: actions/github-script@v6
        with:
          script: |
            const lighthouseCommentMaker = require('./.github/lighthouseCommentMaker.js');
            console.log(${{ steps.lighthouse_audit.outputs.assertionResults}})
            const lighthouseOutputs = {
              manifest: ${{ steps.lighthouse_audit.outputs.manifest }},
              links: ${{ steps.lighthouse_audit.outputs.links }}
            };

            const comment = lighthouseCommentMaker({ lighthouseOutputs });
            core.setOutput("comment", comment);

      - name: Add Lighthouse stats as comment
        if: always()
        id: comment_to_pr
        uses: marocchino/sticky-pull-request-comment@v2.0.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          number: ${{ github.event.pull_request.number }}
          header: lighthouse
          message: ${{ steps.format_lighthouse_score.outputs.comment }}

Worth noting, I am using the following assert matrix:

assert: {
      assertMatrix: [
        {
          matchingUrlPattern: `${PREVIEW_URL}/sitemap/`,
          assertions: {
            'categories:performance': ['error', { minScore: 0.5, aggregationMethod: 'median-run' }],
            'categories:accessibility': ['error', { minScore: 0.9, aggregationMethod: 'median-run' }],
            'categories:best-practices': ['error', { minScore: 0.9, aggregationMethod: 'median-run' }],
            'categories:seo': ['error', { minScore: 0.9, aggregationMethod: 'median-run' }],
          },
        },
    ]}
b3nk3 commented 3 months ago

TIL: assertionResults will be empty if you passed them.