{"id":15381965,"url":"https://github.com/justinribeiro/lighthouse-action","last_synced_at":"2025-02-28T08:30:37.275Z","repository":{"id":35773400,"uuid":"219085260","full_name":"justinribeiro/lighthouse-action","owner":"justinribeiro","description":"Audit deployed web sites with my artisanal blend of WPT Network Emulation Profiles, Puppeteer, Chrome headless, Lighthouse, and Github Actions.","archived":false,"fork":false,"pushed_at":"2023-07-18T18:23:27.000Z","size":30164,"stargazers_count":57,"open_issues_count":4,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-05T09:58:23.434Z","etag":null,"topics":["chrome-headless","github-actions","lighthouse","puppeteer","webperf"],"latest_commit_sha":null,"homepage":"https://justinribeiro.com/chronicle/2019/11/02/web-performance-audits-with-lighthouse-for-github-actions-released/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinribeiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["justinribeiro"]}},"created_at":"2019-11-02T01:01:10.000Z","updated_at":"2023-11-22T07:39:24.000Z","dependencies_parsed_at":"2024-06-19T12:13:05.364Z","dependency_job_id":"46293a06-bc47-4871-a115-68f1fcef0702","html_url":"https://github.com/justinribeiro/lighthouse-action","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.34615384615384615","last_synced_commit":"0a026a700f50b8517b17d1d598d4ae6283d8ab73"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinribeiro%2Flighthouse-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinribeiro","download_url":"https://codeload.github.com/justinribeiro/lighthouse-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219871344,"owners_count":16560650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-headless","github-actions","lighthouse","puppeteer","webperf"],"created_at":"2024-10-01T14:29:26.411Z","updated_at":"2024-10-16T19:04:17.763Z","avatar_url":"https://github.com/justinribeiro.png","language":"JavaScript","funding_links":["https://github.com/sponsors/justinribeiro"],"categories":[],"sub_categories":[],"readme":"# Lighthouse with WPT Network Emulation Profiles, Github Action Edition\n\n\u003e Audit deployed web sites with my artisanal blend of WPT Network Emulation Profiles, Puppeteer, Chrome headless, Lighthouse, and Github Actions.\n\n## Features\n\n- Uses [Puppeteer](https://github.com/GoogleChrome/puppeteer) to start up Chrome with [network emulation settings defined by WebPageTest](https://github.com/WPO-Foundation/webpagetest/blob/master/www/settings/connectivity.ini.sample).\n- Supports saving of artifacts to the Github Action run.\n- Supports custom Lighthouse configuration via JavaScript file.\n- Supports Lighthouse budget.json for failing PRs.\n- Supports Lighthouse-based data model scores.js for failing PRs based on _any_ audit score or category.\n- Posts results of audit run as a comment on your PR.\n  ![image](https://user-images.githubusercontent.com/643503/68270529-5729f400-0012-11ea-8fa9-e3eaeb2ee6f5.png)\n\n## General Disclaimer\n\nWhile I love automated web performance testing, you should always keep in mind that:\n\n1. That this tool is the first line of testing and is at best a guidepost given the emulation layer.\n2. Verify your web performance on actual hardware and devices that your users are using (and you can even run lighthouse reports on those devices too).\n3. When in doubt, run a trace in DevTools.\n\nNow let's have some fun and automate a web perf workflow!\n\n## Basic Usage\n\nThis is best run against `on: [pull_request]`, so you'll get the report comment, but you technically do not have to use it this way.\n\n```yml\nname: Audit Web Performance\non: [pull_request]\njobs:\n  perf:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v1\n      - name: Generate Lighthouse Report\n        uses: justinribeiro/lighthouse-action@master\n        with:\n          secret: ${{ secrets.GITHUB_TOKEN }}\n          url: https://${{ github.sha }}-dot-${{ secrets.GAE_PID }}.appspot.com\n          wptConnectionSpeed: threegfast\n      - name: Saving Lighthouse Audit Artifacts\n        uses: actions/upload-artifact@master\n        with:\n          name: lighthouse-artifacts\n          path: './results'\n```\n\nIf you don't want the PR comment, the secret is optional.\n\n## Advanced Usage\n\nIf you don't want to use the WPT profiles or you want to customize your Lighthouse configuration with headers or custom runs, or you just want to use your existing lighthouse budget.json, this is available via the `lighthouseConfiguration` and `lighthouseBudget` options:\n\n```yml\nname: Audit Web Performance\non: [pull_request]\njobs:\n  perf:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v1\n      - name: Generate Lighthouse Report\n        uses: justinribeiro/lighthouse-action@master\n        with:\n        with:\n          secret: ${{ secrets.GITHUB_TOKEN }}\n          url: https://justinribeiro.com/\n          lighthouseBudget: .github/test/budget.json\n          lighthouseScoringBudget: .github/test/scores.js\n          lighthouseConfiguration: .github/test/custom-config.js\n      - name: Saving Lighthouse Audit Artifacts\n        uses: actions/upload-artifact@master\n        with:\n          name: lighthouse-artifacts\n          path: './results'\n```\n\nFor full details on how to define a lighthouse configuration file, see [Lighthouse Configuration](https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md) for more information.\n\nFor full details on how to define a lighthouse budget.json file, see [Performance Budgets (Keep Request Counts Low And File Sizes Small)](https://developers.google.com/web/tools/lighthouse/audits/budgets) for more information.\n\n## Using scores.js to increase your audit power\n\n`scores.js` is based on the Lighthouse JSON output data model and maps one-to-one with the existing keys and definitions within lighthouse. This allows an easy to use, vastly configurable file to test any audit score or raw numeric value that you find important. No having to wait for me to add special parameters. :-)\n\nLet's look at an example `scores.js` file:\n\n```\nmodule.exports = {\n  audits: {\n    'service-worker': {\n      score: 1,\n    },\n    'first-contentful-paint': {\n      score: 1,\n      numericValue: 100,\n    },\n    'first-meaningful-paint': {\n      score: 1,\n      numericValue: 100,\n    },\n  },\n  categories: {\n    performance: {\n      score: 0.95,\n    },\n    accessibility: {\n      score: 0.95,\n    },\n  },\n};\n```\n\nIn this case we can test for either one or two specific keys:\n\n1. `score`: decimal ranging from 0 to 1. If you wanted to verify that your performance is above 95, you'd enter 0.95 like above.\n2. `numericValue`: decimal starting at zero. Commonly holds the value out of the trace in milliseconds, good for testing if you want those raw performance numbers.\n\nFor a full view of available audits and categories, output a JSON file from the lighthouse cli to get started:\n\n```\n$ lighthouse --output json --output-path=./sample.json --chrome-flags=\"--headless\" https://YOUR_URL_HERE.com\n\n```\n\n## Inputs\n\n### `url`\n\n**Required** The URL you'd like Lighthouse to audit.\n\n### `secret`\n\n_Optional_ This is the default secret for your repo as generated by Github Actions. Use the `${{ secrets.GITHUB_TOKEN }}` for this to allow commenting on your PRs.\n\n### `wptConnectionSpeed`\n\n_Optional_ Profiles based on [WebPageTest project connectivity samples](https://github.com/WPO-Foundation/webpagetest/blob/master/www/settings/connectivity.ini.sample), defined in [chrome.js](https://github.com/justinribeiro/lighthouse-action/blob/master/src/chrome.js).\n\nDefaults to `threegfast`. Can be any of the following: `twog`, `threegslow`, `threeg`, `threegfast`, `fourg`, `lte`.\n\n### `lighthouseConfiguration`\n\n_Optional_ File path to custom lighthouse configuration JavaScript file. See [Lighthouse Configuration](https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md) for more information.\n\n### `lighthouseBudget`\n\n_Optional_ File path to custom budget.json file; will fail PRs based on budget result. See [Performance Budgets (Keep Request Counts Low And File Sizes Small)](https://developers.google.com/web/tools/lighthouse/audits/budgets) for more information.\n\n### `lighthouseScoringBudget`\n\n_Optional_ File path to custom scores.js file; will fail PRs based on scoring result. See the above section in this README \"Using scores.js to increase your audit power\" for more information.\n\n## Outputs\n\n### `resultsPath`\n\nPath to the folder with Lighthouse audit results.\n\n## Live example\n\nFor a live example of this action in practice, see [my blog-pwa repo workflow](https://github.com/justinribeiro/blog-pwa/blob/master/.github/workflows/main.yml).\n\n## Why I built this\n\n1. I wanted a simpler, cleaner example anyone could jump into, fork, and make their own.\n2. None of the other offerings post on a PR the audit result.\n3. I wanted to explore harsher network conditioning, which I already do in things like my [lighthouse-jest-example](https://github.com/justinribeiro/lighthouse-jest-example) fairly successfully.\n\n## The future\n\n1. Add fail case configuration\n2. Add server warming flags (which I've found skews scores on a lot of deployments)\n3. Add multi-url auditing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinribeiro%2Flighthouse-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinribeiro%2Flighthouse-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinribeiro%2Flighthouse-action/lists"}