Skip to content

Commit 9206763

Browse files
committed
Updated README
1 parent e5bf483 commit 9206763

File tree

4 files changed

+147
-2
lines changed

4 files changed

+147
-2
lines changed

README.md

Lines changed: 147 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,152 @@
11
<p align="center"><img src="https://docs.webpagetest.org/img/wpt-navy-logo.png" alt="WebPageTest Logo" /></p>
2-
<h1 align="center">WebPageTest GitHub Action</h1>
2+
3+
# WebPageTest GitHub Action
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE)
35

46
WebPageTest's GitHub Action lets you automatically run tests against WebPageTest on code changes. You can set and enforce performance budgets, and have performance data automatically added to your pull requets to move the performance conversation directly into your existing development workflow.
57

8+
**Features:**
9+
- Automatically run WebPageTest against code changes
10+
- Set and enforce budgets for any metric WebPageTest can surface (spoiler alert: there are a lot)
11+
- Complete control over WebPageTest test settings (authentication, custom metrics, scripting, etc)
12+
- Automatically create comments on new pull requests with key metrics, waterfall and more.
13+
14+
## Using the Action
15+
16+
1. Get a WebPageTest API Key and store it [as a secret in your repository's settings](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository).
17+
18+
![WPT_API_KEY Secret in repo settings](/images/wpt-action-api-secret.png)
19+
20+
2. Create a `.github/workflows/webpagetest-action.yml` file in your repository with the following settings:
21+
22+
```yml
23+
on: [pull_request]
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
name: WebPageTest Action
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
33+
- name: WebPageTest
34+
uses: WPO-Foundation/webpagetest-github-action@main
35+
with:
36+
apiKey: ${{ secrets.WPT_API_KEY }}
37+
urls: |
38+
https://example.com/
39+
https://example.com/about
40+
label: 'GitHub Action Test'
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
```
43+
44+
3. Open a Pull Request. WebPageTest's GitHub Action will run in the background and post a comment on your PR.
45+
46+
![Sample pull request comment](/images/wpt-action-sample-comment.png)
47+
48+
## Configuration
49+
By default, WebPageTest's GitHub Action will run tests whenever the event (pull_request, push, etc) you specify in your workflow is triggered. (We recommend `pull_request`).
50+
51+
The tests will be run with the following WebPageTest settings:
52+
53+
- Location: Dulles, VA
54+
- Browser: Chrome on a Motorola G4
55+
- Connection Type: 3G connection
56+
- Number of test run per URL: 3
57+
- First view only (no repeat views tested)
58+
- The test results will be checked every **5** seconds, up to a limit of **240s**. If no results are returned by then, the test will timeout and fail.
59+
- Each test will be labeled with the label you provide via the `label` input.
60+
61+
However, WebPageTest is capable of going _very_ deep, and the GitHub Action provides a number of configuration settings to help fine-tune your tests and even fail a pull request if performance budgets aren't met.
62+
63+
### Setting performance budgets
64+
WebPageTest's GitHub Action uses the [WebPageTest API Wrapper for NodeJS](https://github.com/marcelduran/webpagetest-api) under the hood. The wrapper provides [test specs](https://github.com/marcelduran/webpagetest-api/wiki/Test-Specs) functionality that lets you set budgets on any of the metrics returned by the WebPageTest API.
65+
66+
The GitHub Action lets you provide a path to a specs JSON file using the `budget` input. If a specs file is included, WebPageTest's GitHub Action will test the results against the budgets you've defined. If any budget isn't met, the tests will fail and you'll be provided with links to dig into the full WebPageTest results to see what was slowing things down.
67+
68+
For example, given the following configuration:
69+
70+
```yml
71+
on: [pull_request]
72+
73+
jobs:
74+
build:
75+
runs-on: ubuntu-latest
76+
name: WebPageTest Action
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v2
80+
81+
- name: WebPageTest
82+
uses: WPO-Foundation/webpagetest-github-action@main
83+
with:
84+
apiKey: ${{ secrets.WPT_API_KEY }}
85+
urls: |
86+
https://example.com/
87+
https://example.com/about
88+
label: 'GitHub Action Test'
89+
budget: 'wpt-budget.json'
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
```
92+
93+
And a `wpt-budget.json` file containing:
94+
95+
```json
96+
{
97+
"median": {
98+
"firstView": {
99+
"firstContentfulPaint": 1000
100+
}
101+
}
102+
}
103+
```
104+
105+
WebPageTest would test each run's First Contentful Paint. If the First Contentful Paint fires in less than 1 second, the test passes; if not, the test would fail.
106+
107+
![Example of a WPT action failing the PR if a budget is exceeded](/images/wpt-action-fail-pr.png)
108+
109+
The specs format provides tremendous flexiblity in which metrics you want to budget against. For more information, check out [the official documentation](https://github.com/marcelduran/webpagetest-api/wiki/Test-Specs).
110+
### Customizing your WebPageTest tests
111+
There are a _lot_ of [options available in WebPageTest](https://github.com/marcelduran/webpagetest-api#test-works-for-runtest-method-only) to customize your test results, record custom metrics, or do advanced scripting and multi-page flows.
112+
113+
To give you the ability to customize you tests, the WebPageTest GitHub Action let's you provide the path to a JSON object with your test options, using the `wptOptions` input.
114+
115+
For example, given the following configuration:
116+
117+
```yml
118+
on: [pull_request]
119+
120+
jobs:
121+
build:
122+
runs-on: ubuntu-latest
123+
name: WebPageTest Action
124+
steps:
125+
- name: Checkout
126+
uses: actions/checkout@v2
127+
128+
- name: WebPageTest
129+
uses: WPO-Foundation/webpagetest-github-action@main
130+
with:
131+
apiKey: ${{ secrets.WPT_API_KEY }}
132+
urls: |
133+
https://example.com/
134+
https://example.com/about
135+
label: 'GitHub Action Test'
136+
budget: 'wpt-budget.json'
137+
wptOptions: 'wpt-options.json'
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
```
140+
141+
And a `wpt-options.json` file containing:
142+
143+
```json
144+
{
145+
"runs": 1,
146+
"location": "Dulles:Chrome",
147+
"connectivity": "Cable",
148+
"blockAds": true
149+
}
150+
```
6151

7-
152+
The defaults values for the number of runs, location, and connectivity type would all be overwritten by the settings specified here. In addition, any ads defined by https://adblockplus.org/ would be automatically blocked.

images/wpt-action-api-secret.png

39.7 KB
Loading

images/wpt-action-fail-pr.png

45.7 KB
Loading
269 KB
Loading

0 commit comments

Comments
 (0)