Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseykulikov committed Nov 11, 2019
1 parent cb943e0 commit fec6e5a
Showing 1 changed file with 47 additions and 34 deletions.
81 changes: 47 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ and monitor performance with [Lighthouse CI](https://github.com/GoogleChrome/lig
- 💾 Upload data to LHCI server
- 🚀 Fast action initialization

## Usage
## Example

> Use Case: Run Lighthouse on each push to the repo and save the results in action artifacts.
> Use Case: Run Lighthouse on each push to the repo and upload results to public storage for debugging.
Create `.github/workflows/main.yml` with the list of URLs to audit using lighthouse.
The results will be stored as a build artifact.
The results will be stored as on a [temporary-public-storage](https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/cli.md#upload).

#### main.yml

Expand All @@ -47,13 +47,6 @@ jobs:
> out in the action, or download the `json` files from the artifacts and open
> them with the [Lighthouse Viewer App](https://googlechrome.github.io/lighthouse/viewer/)

Link to `temporary-public-storage`:
<img align="center" width="998" alt="Lighthouse CI Action" src="https://user-images.githubusercontent.com/6392995/68536792-76c06580-030d-11ea-8e19-c467e374434e.png">

> Note: By default this action will store `json` results to `.lighthouseci`,
> setting `temporaryPublicStorage` will upload the LHRs to Lighthouse-ci's
> `temporary-public-storage`.

## Inputs

#### `urls`
Expand All @@ -68,17 +61,17 @@ urls: |
https://example.com/pricing
```

#### `temporaryPublicStorage`
#### `temporaryPublicStorage` (default: false)

This will opt-in to upload reports to LHCI's `temporary-public-storage`. You can find out more about `temporary-public-storage` in the [LHCI repo](https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/cli.md#upload).

```yml
temporaryPublicStorage: true
```

#### `runs`
#### `runs` (default: `1`)

Specify the number of runs to do on each URL. Default: `1`.
Specify the number of runs to do on each URL.

> Note: Asserting against a single run can lead to flaky performance assetions.
> Use `1` only to ensure static audits like Lighthouse scores or page size.
Expand Down Expand Up @@ -110,25 +103,55 @@ configPath: ./lighthouserc.json
#### `upload`

Upload Lighthouse results to a private [LHCI server](https://github.com/GoogleChrome/lighthouse-ci) by specifying both `upload.serverBaseUrl` and `upload.token`.
This will replace uploading to `temporary-public-storage`.

> Note: Use [Github secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets#creating-encrypted-secrets) to keep your server address hidden!

> Note: This will replace uploading to `temporary-public-storage`.

```yml
upload.serverBaseUrl: ${{ secrets.LHCI_SERVER }}
upload.token: ${{ secrets.LHCI_TOKEN }}
```

Specify an API token for the LHCI server. ([How to generate a token](https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/getting-started.md#historical-reports--diffing-lighthouse-ci-server))
Specify an API token for the LHCI server. [Learn how to generate a token](https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/getting-started.md#historical-reports--diffing-lighthouse-ci-server).

## Recipes

https://github.com/treosh/lighthouse-ci-action/tree/master/.github/workflows
Have an unlisted example? Please, submit a PR.
Explore possible workflows in the [public examples](./.github/workflows) or submit a PR with a new one.

<details>
<summary>Use case: run Lighthouse on each push to the repo and save the results in action artifacts</summary><br>

Create `.github/workflows/main.yml` with the list of URLs to audit using lighthouse.
The results will be stored as a build artifact.

#### main.yml

```yml
name: Lighthouse
on: push
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v1
with:
urls: 'https://example.com/'
# Note: Lighthouse-ci-actions overwrite .lighthouseci/ each run, therefore
# artifacts need to be saved after each run if using gh-actions artifacts.
- name: Save results
uses: actions/upload-artifact@v1
with:
name: lighthouse-results
# This will save the Lighthouse results as .json files
path: '.lighthouseci'
```

</details>

<details>
<summary>Use enviroment variable for URLs</summary>
<summary>Use case: write dynamic URLs using env variables</summary><br>

URLs support interpolation of process env vars, so you can write URLs like:

Expand All @@ -148,9 +171,7 @@ URLs support interpolation of process env vars, so you can write URLs like:
</details>

<details>
<summary>Asserting against performance budgets.json</summary>

> Use Case: Run Lighthouse and validate against a budget.
<summary>Use Case: Run Lighthouse and validate against a budget.</summary><br>

Create `.github/workflows/main.yml` with the list of URLs to audit
and identify a budget with `budgetPath`.
Expand Down Expand Up @@ -203,9 +224,7 @@ Make a `budget.json` file with [budgets syntax](https://web.dev/use-lighthouse-f
</details>

<details>
<summary>Asserting against LHCI lighthouserc</summary>

> Use Case: Run Lighthouse and validate against LHCI assertions.
<summary>Use Case: Run Lighthouse and validate against LHCI assertions.</summary><br>

Create `.github/workflows/main.yml` with the list of URLs to audit
and identify a `lighthouserc` file with `configPath`.
Expand Down Expand Up @@ -250,9 +269,7 @@ Make a `lighthouserc.json` file with [LHCI assertion syntax](https://github.com/
</details>

<details>
<summary>Uploading to a LHCI Server</summary>

> Use Case: Providing data to a hosted LHCI server.
<summary>Use Case: Providing data to a hosted LHCI server.</summary><br>

Create `.github/workflows/main.yml` with the list of URLs to audit using lighthouse,
and identify a `serverBaseUrl` to upload to and an `token` to use.
Expand Down Expand Up @@ -284,9 +301,7 @@ jobs:
</details>

<details>
<summary>Using custom config and Chrome flags</summary>

> Use Case: Running Lighthouse with highly custom Lighthouse runtime or custom Chrome flags.
<summary>Use Case: Running Lighthouse with highly custom Lighthouse runtime or custom Chrome flags.</summary><br>

Create `.github/workflows/main.yml` with the list of URLs to audit and
identify a `lighthouserc` file with `configPath`.
Expand Down Expand Up @@ -363,9 +378,7 @@ module.exports = {
</details>

<details>
<summary>Using a static dist dir</summary>

> Use Case: Testing a very basic static site without having to deploy it.
<summary>Use Case: Testing a very basic static site without having to deploy it.</summary><br>

Create `.github/workflows/main.yml` and identify a `lighthouserc` file with a
`staticDistDir` config.
Expand Down

0 comments on commit fec6e5a

Please sign in to comment.