-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create README
- Loading branch information
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Lighthouse Report Tracker | ||
|
||
Lighthouse Report Tracker is a simple but effective tool that **stores** and **analyzes** lighthouse reports generated by <a href="https://github.com/GoogleChrome/lighthouse-ci" target="_blank">Lighthouse CI</a>. | ||
|
||
<br> | ||
|
||
## Features | ||
|
||
- **Automated Report Comparison** : Generate a comparison table between pull requests to spot and prevent performance regressions in `Performance`, `Best Practices`, `Accessibility`, `SEO` and `PWA` metrics. | ||
|
||
- **No External Server/Storage Required** : Preserve and manage Lighthouse CI reports within your repository via GitHub Issues. Lighthouse report data will always be available for future purposes. | ||
|
||
<br> | ||
|
||
<div> | ||
|
||
<img width="47%" height="360px" alt="performance-table" src="https://github.com/moonkorea00/action/assets/78708082/2ac6c9ab-55dc-4e3b-8943-25db10f89bfe"> | ||
<img width="47%" height="360px" alt="Screen Shot 2024-04-23 at 2 45 52 PM" src="https://github.com/moonkorea00/action/assets/78708082/0f8cf6d4-8d50-4673-98ae-b0a0a4c9ddea"> | ||
<img width="94%" alt="tracker-issue" src="https://github.com/moonkorea00/action/assets/78708082/1d295607-ba50-4e94-801f-41a15509fb1d"> | ||
|
||
</div> | ||
|
||
<br> | ||
|
||
## Usage | ||
|
||
To run Lighthouse and generate performance tables on pull requests, create a `lighthouse.yml` file under the `.github/workflows` directory. | ||
|
||
If you have not yet set up Lighthouse CI, check out the details below. | ||
|
||
<details><summary><i>See minimum configuration</i></summary> | ||
|
||
> Below is a minimum required configuration to set up Lighthouse CI in your project. See the <a href="https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md" target="_blank">Lighthouse CI docs</a> for detailed configuration. | ||
- Create a **lighthouserc.js** file in the root directory | ||
|
||
```js | ||
// lighthouserc.js | ||
|
||
module.exports = { | ||
ci: { | ||
collect: { | ||
url: [ | ||
'https://your-project-url-to-audit.com', | ||
// ex) 'http://localhost:3000' | ||
// add additional urls to audit | ||
], | ||
numberOfRuns: 1, | ||
}, | ||
upload: { | ||
target: 'filesystem', | ||
outputDir: './lhci', | ||
reportFilenamePattern: '%%DATETIME%%.%%EXTENSION%%', | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
</details> | ||
|
||
```yml | ||
# lighthouse.yml | ||
|
||
name: Lighthouse CI | ||
on: | ||
pull_request: | ||
branches-ignore: | ||
- 'dependabot/**' # pull requests by dependabots are good to ignore | ||
jobs: | ||
lighthouse: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
|
||
- name: npm install, build # update the step depending on your package manager | ||
run: | | ||
npm install | ||
npm run build | ||
- name: run Lighthouse CI # runs Lighthouse CI | ||
run: | | ||
npm install -g @lhci/[email protected] | ||
lhci autorun | ||
- name: Run Lighthouse Report Tracker | ||
uses: moonkorea00/[email protected] | ||
with: | ||
secret: ${{ secrets.GITHUB_TOKEN }} # by default GitHub will create your token | ||
outputDir: 'path/to/lighthouse/reports' # directory configured in your lighthouserc.js. defaults to './lhci' | ||
``` | ||
- In your repository's `Settings - Actions - General`, update the **Workflow permissions** to **Read and write permissions** in order to generate report tables in your pull request. | ||
|
||
<p align="center"> | ||
<img width="600" alt="workflow-permission" src="https://github.com/moonkorea00/action/assets/78708082/3eab10a2-d976-45b8-a73c-a08e98be5f6d"> | ||
</p> | ||
|
||
<br> | ||
|
||
## Inputs | ||
|
||
| Input | Description | Required | Defaults to | | ||
| :-------: | ------------------------------------------------------------------------------------------------------------------------------------ | :------: | :-----------: | | ||
| secret | The GitHub token required for API requests to create comments in pull requests. Use `${{ secrets.GITHUB_TOKEN }}` as the value. | **Yes** | | | ||
| outputDir | The directory configured in your lighthouserc.js. Depending on how you run `lhci autorun`, reports will be stored in this directory. | No | './lhci' | |