From bd2e3c64d9fbdca57add9d314a5b6f5a3cef21b3 Mon Sep 17 00:00:00 2001 From: Marcin Kuthan Date: Thu, 24 Nov 2022 07:28:43 +0100 Subject: [PATCH] Dedicated lighthouse GH action (#959) --- .github/workflows/ci.yml | 9 +--- .github/workflows/lighthouse-report.yml | 55 ------------------------- .github/workflows/reports.yml | 52 +++++++++++++++++++++++ .github/workflows/size-report.yml | 21 ---------- 4 files changed, 54 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/lighthouse-report.yml create mode 100644 .github/workflows/reports.yml delete mode 100644 .github/workflows/size-report.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2df60d1b2..4fa6a4043 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,12 +61,7 @@ jobs: uses: ./.github/workflows/deploy.yml secrets: inherit - lighthouse-report: + reports: needs: required-checks - uses: ./.github/workflows/lighthouse-report.yml - secrets: inherit - - size-report: - needs: required-checks - uses: ./.github/workflows/size-report.yml + uses: ./.github/workflows/reports.yml secrets: inherit diff --git a/.github/workflows/lighthouse-report.yml b/.github/workflows/lighthouse-report.yml deleted file mode 100644 index 731f6f6a4..000000000 --- a/.github/workflows/lighthouse-report.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Lighthouse Report - -on: - workflow_call: ~ - workflow_dispatch: ~ - -jobs: - lighthouse-report: - runs-on: ubuntu-latest - - if: github.event_name == 'pull_request' - - # add permission to comment PR created by dependantbot - permissions: - issues: write - pull-requests: write - - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - run: npm run build - - - name: Run Lighthouse CI - run: | - npm install -g @lhci/cli@0.9.x - lhci autorun - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - - - name: Get app URL - id: report-url - run: | - echo ::set-output name=report_url::$(cat ./.lighthouseci/links.json | jq -r '."http://localhost:9090/"') - - - name: Print report URL - uses: actions/github-script@v6 - env: - REPORT_URL: ${{ steps.report-url.outputs.report_url }} - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: ':stopwatch: Lighthouse report: ' + process.env.REPORT_URL - }) - - - name: Copy bundle analysis report - run: cp build/report-*.{html,json} ./.lighthouseci - - - uses: actions/upload-artifact@v2 - with: - name: lighthouse-report - path: | - ./.lighthouseci/ diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml new file mode 100644 index 000000000..5b85c9119 --- /dev/null +++ b/.github/workflows/reports.yml @@ -0,0 +1,52 @@ +name: Reports + +on: + workflow_call: ~ + workflow_dispatch: ~ + +jobs: + size: + runs-on: ubuntu-latest + + if: github.event_name == 'pull_request' + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + build_script: build:client + skip_step: install + + lighthouse: + runs-on: ubuntu-latest + + if: github.event_name == 'pull_request' + + # add permission to comment PR created by dependabot + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + - run: npm run build + - uses: treosh/lighthouse-ci-action@v9 + id: lighthouse + with: + uploadArtifacts: true + temporaryPublicStorage: true + - uses: actions/github-script@v6 + with: + script: | + const lighthouse_links = ${{ steps.lighthouse.outputs.links }} + const lighthouse_link = Object.values(lighthouse_links)[0] + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: ':stopwatch: Lighthouse [report](' + lighthouse_link + ')' + }) diff --git a/.github/workflows/size-report.yml b/.github/workflows/size-report.yml deleted file mode 100644 index 9a3b3b0b0..000000000 --- a/.github/workflows/size-report.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Size report - -on: - workflow_call: ~ - workflow_dispatch: ~ - -jobs: - size-report: - runs-on: ubuntu-latest - - if: github.event_name == 'pull_request' - - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - build_script: build:client - skip_step: install