Skip to content

Commit 0282b5f

Browse files
committed
adding note about testing against deploy previews for budgeting, as well as a Netlify example
1 parent 9206763 commit 0282b5f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,40 @@ WebPageTest would test each run's First Contentful Paint. If the First Contentfu
107107
![Example of a WPT action failing the PR if a budget is exceeded](/images/wpt-action-fail-pr.png)
108108

109109
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+
111+
### Testing against a deployment URL
112+
If you are going to set and enforce performance budgets, **make sure to pass a preview URL** to test against to make sure that you're testing against the latest changes, not against a prior version of your site.
113+
114+
As an example, if you happen to be using a service like [Netlify](https://www.netlify.com/), they'll generate deploy previews for each PR. Here's an example of how you could run the WebPageTest action against the latest deploy preview using the [Wait for Netlify Action](https://github.com/JakePartusch/wait-for-netlify-action).
115+
116+
```yml
117+
on: [pull_request]
118+
119+
jobs:
120+
build:
121+
runs-on: ubuntu-latest
122+
name: WebPageTest Action
123+
steps:
124+
- name: Checkout
125+
uses: actions/checkout@v2
126+
- name: Wait for the Netlify Preview
127+
uses: jakepartusch/[email protected]
128+
id: netlify
129+
with:
130+
site_name: 'your-netlify-site-name'
131+
- name: WebPageTest
132+
uses: WPO-Foundation/webpagetest-github-action@main
133+
with:
134+
apiKey: ${{ secrets.WPT_API_KEY }}
135+
urls: |
136+
${{ steps.netlify.outputs.url }}
137+
${{ steps.netlify.outputs.url }}/about
138+
label: 'GitHub Action Test'
139+
budget: 'wpt-budget.json'
140+
wptOptions: 'wpt-options.json'
141+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142+
```
143+
110144
### Customizing your WebPageTest tests
111145
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.
112146

0 commit comments

Comments
 (0)