Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document or integrate with github deployments/pull requests #44

Open
NateRadebaugh opened this issue Apr 7, 2020 · 8 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@NateRadebaugh
Copy link

I'd like to see my lighthouse scores for each of my deployments. I use nextjs with now for my site so I have deployments for each push, so it should be possible to test against the latest deployment in the PR and show the results inline. Is that possible?

@alekseykulikov
Copy link
Member

I think, it should be possible.
You can use env variables to generate PR URLs dynamically, like:

name: Lighthouse CI
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Run Lighthouse and test budgets
        uses: treosh/lighthouse-ci-action@v2
        with:
          urls: |
            https://pr-$PR_NUMBER.staging-example.com/
            https://pr-$PR_NUMBER.staging-example.com/blog
          budgetPath: ./budgets.json
          temporaryPublicStorage: true
        env:
          PR_NUMBER: ${{ github.event.pull_request.number }}

show the results inline

Do you mean as a PR status for each URL? In this case, you will need to create separate jobs for each URL to get a new status badge #40.
We also consider optional debug annotations to show scores as a part of the action UI #43.

Let us know, how you see the ideal workflow.

@NateRadebaugh
Copy link
Author

NateRadebaugh commented Apr 7, 2020

Thanks @alekseykulikov this is getting closer. How can I get the deployment URL, instead of the pull request number? Eg, for use with "Vercel" I have a deployment per commit:

@alekseykulikov alekseykulikov added the documentation Improvements or additions to documentation label May 25, 2020
@mikenikles
Copy link

Hey @NateRadebaugh,

The following workflow works for me:

name: services/website

on:
  pull_request:
    paths:
    - 'services/website/**'

jobs:
  test:
    name: Test the services/website
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Wait for Vercel preview deployment to be ready
        uses: patrickedqvist/wait-for-vercel-preview@master
        id: waitForVercelPreviewDeployment
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          max_timeout: 60
      - name: Audit Vercel preview URL using Lighthouse
        uses: treosh/lighthouse-ci-action@v3
        with:
          urls: |
            ${{ steps.waitForVercelPreviewDeployment.outputs.url }}
          budgetPath: ./services/website/budget.json
          uploadArtifacts: true
          temporaryPublicStorage: true 

@NateRadebaugh
Copy link
Author

Thanks @mikenikles this looks promising and is working for me, so thanks!! Note: this only works on pull_request and will error out if it's configured for on push.

Building on this solution:

What would really be great now is to have the action/bot add an inline comment with the run summary/links to avoid needing to dig into the action manually to get the scores.

This is how the (now deprecated) lighthousebot is documented to have looked like:
image

@kamranayub
Copy link

kamranayub commented Aug 1, 2020

I was looking around for this too and was sad to see the lighthouseci bot discontinued; I think we'd need a new bot to do this.

I did see that you can get the status checks added as part of the PR with ahci:

But I don't know if this is compatible with this action yet.

edit: Just tried but doesn't appear it does.

jobs:
  audit:
    steps:
     - name: Audit URLs using Lighthouse
        uses: treosh/lighthouse-ci-action@v3
        with:
          ...
        env:
          LHCI_GITHUB_APP_TOKEN: ${{secrets.LHCI_GITHUB_APP_TOKEN}}

@OskarAhl
Copy link

I wrote a Github Action (with Vercel) - that adds the below comment to your PRs - you can find it here https://github.com/OskarAhl/Lighthouse-github-action-comment

Alt Text

@ismay
Copy link

ismay commented Aug 6, 2021

If you're looking for a workflow that works on push, this is the workflow I use for that. It waits for the deployment to be complete on each push, and then runs lighthouse on the generated url.

It uses two separate actions, one to generate the preview url, and one to wait for the deploy to be done.

@danielo515
Copy link

I wrote a Github Action (with Vercel) - that adds the below comment to your PRs - you can find it here https://github.com/OskarAhl/Lighthouse-github-action-comment

Alt Text

Will be awesome to have something like this as part of this action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

7 participants