Skip to content

Commit

Permalink
docs(getting-started): add Cloudbuild example (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
annez authored Nov 30, 2020
1 parent 8b3fde9 commit 6e8872d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
54 changes: 53 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = {
**.gitlab-ci.yml**

```yaml
image: cypress/browsers:node10.16.0-chrome77
image: cypress/browsers:node14.15.0-chrome86-ff82
lhci:
script:
- npm install
Expand Down Expand Up @@ -221,6 +221,58 @@ lhci autorun

</details>

<details>
<summary>Google Cloudbuild</summary>
<br />

**NOTE:** Learn more about the [security tradeoffs](./recipes/docker-client/README.md#--no-sandbox-container-tradeoffs) behind use of the `--no-sandbox` Chrome option before proceeding.

**.lighthouserc.js**

```js
module.exports = {
ci: {
collect: {
settings: {chromeFlags: '--no-sandbox'},
},
upload: {
target: 'temporary-public-storage',
},
},
};
```

**Notes**
* `LHCI_BUILD_CONTEXT__CURRENT_BRANCH` doesn't pick up the right variables in cloudbuild so passing through `$BRANCH_NAME` will fix this.
* `machineType` defines the machine you can pick. The bigger the machine the more stable the performance results will be (see [Lighthouse variability documentation](https://github.com/GoogleChrome/lighthouse/blob/master/docs/variability.md)). WARNING: Look through the [Cloudbuild machine pricing](https://cloud.google.com/cloud-build/pricing) before deciding on a machine type.

**cloudbuild.yml**

```yaml
steps:
- id: 'install'
args: ['npm', 'ci']
name: node:14-alpine
- id: 'build'
waitFor: ['install']
name: node:14-alpine
args: ['npm', 'run', 'build']
- id: 'lighthouse'
waitFor: ['build']
name: cypress/browsers:node14.15.0-chrome86-ff82
entrypoint: '/bin/sh'
args: ['-c', 'npm install -g @lhci/[email protected] && lhci autorun --failOnUploadFailure']
env:
- 'LHCI_BUILD_CONTEXT__CURRENT_BRANCH=$BRANCH_NAME'
options:
machineType: 'N1_HIGHCPU_8'
```

</details>

That's it! With this in place, you'll have Lighthouse reports collected and uploaded with links to each report on every push.

Temporary public storage provides access to individual reports, but not historical data, report diffing, or build failures. Read on to find out how to [add assertions](#add-assertions), configure the [Lighthouse CI server](#the-lighthouse-ci-server) for report diffs and timeseries charts, and enable [GitHub status checks](#github-status-checks).
Expand Down
1 change: 1 addition & 0 deletions docs/introduction-to-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ There are many CI providers out there to choose from. Lighthouse CI works with a
- [GitLab CI](https://docs.gitlab.com/ee/ci/quick_start/)
- [Travis CI](https://docs.travis-ci.com/user/tutorial/)
- [Circle CI](https://circleci.com/docs/2.0/getting-started/)
- [Google Cloudbuild](https://cloud.google.com/cloud-build/docs/quickstart-build)

0 comments on commit 6e8872d

Please sign in to comment.