• Stars
    star
    198
  • Rank 196,290 (Top 4 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically test code changes in WebPageTest and enforce performance budgets

WebPageTest Logo

Learn about more WebPageTest API Integrations in our docs

WebPageTest GitHub Action

License

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.

Features:

  • Automatically run WebPageTest against code changes
  • Set and enforce budgets for any metric WebPageTest can surface (spoiler alert: there are a lot)
  • Complete control over WebPageTest test settings (authentication, custom metrics, scripting, etc)
  • Automatically create comments on new pull requests with key metrics, waterfall and more.

Using the Action

  1. Get a WebPageTest API Key and store it as a secret in your repository's settings.

WPT_API_KEY Secret in repo settings

  1. Create a .github/workflows/webpagetest-action.yml file in your repository with the following settings:
on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    name: WebPageTest Action
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        
      - name: WebPageTest
        uses: WPO-Foundation/webpagetest-github-action@main
        with:
          apiKey: ${{ secrets.WPT_API_KEY }}
          urls: |
            https://example.com/
            https://example.com/about
          label: 'GitHub Action Test'
  1. Open a Pull Request. WebPageTest's GitHub Action will run in the background and post a comment on your PR.

Sample pull request comment

Configuration

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).

The tests will be run with the following WebPageTest settings:

  • Location: Dulles, VA
  • Browser: Chrome on an emulated Moto G4
  • Connection Type: 4G connection
  • Number of test run per URL: 3
  • First view only (no repeat views tested)
  • 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.
  • Each test will be labeled with the label you provide via the label input.

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.

Setting performance budgets

WebPageTest's GitHub Action uses the WebPageTest API Wrapper for NodeJS under the hood. The wrapper provides test specs functionality that lets you set budgets on any of the metrics returned by the WebPageTest API.

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.

For example, given the following configuration:

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    name: WebPageTest Action
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        
      - name: WebPageTest
        uses: WPO-Foundation/webpagetest-github-action@main
        with:
          apiKey: ${{ secrets.WPT_API_KEY }}
          urls: |
            https://example.com/
            https://example.com/about
          label: 'GitHub Action Test'
          budget: 'wpt-budget.json'

And a wpt-budget.json file containing:

{
 "median": {
     "firstView": {
         "firstContentfulPaint": 1000
     }
 }   
}

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.

Example of a WPT action failing the PR if a budget is exceeded

The specs format provides tremendous flexiblity in which metrics you want to budget against. For more information, check out the official documentation.

Testing against a deployment URL

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.

As an example, if you happen to be using a service like Netlify, 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.

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    name: WebPageTest Action
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        
      - name: Wait for the Netlify Preview
        uses: jakepartusch/[email protected]
        id: netlify
        with:
          site_name: 'your-netlify-site-name'

      - name: WebPageTest
        uses: WPO-Foundation/webpagetest-github-action@main
        with:
          apiKey: ${{ secrets.WPT_API_KEY }}
          urls: |
            ${{ steps.netlify.outputs.url }}
            ${{ steps.netlify.outputs.url }}/about
          label: 'GitHub Action Test'
          budget: 'wpt-budget.json'
          wptOptions: 'wpt-options.json'

If you are testing against a Netlify deployment preview, it's important to note that the new collaborative features for their previews inject a full single-page application into your page, messing with any performance thresholds you might be trying to enforce. Add the following to your wptOptions JSON to make sure none of the extra code makes it into your test results

"block": "netlify-cdp-loader.netlify.app"

Customizing your WebPageTest tests

There are a lot of options available in WebPageTest to customize your test results, record custom metrics, or do advanced scripting and multi-page flows.

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.

For example, given the following configuration:

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    name: WebPageTest Action
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        
      - name: WebPageTest
        uses: WPO-Foundation/webpagetest-github-action@main
        with:
          apiKey: ${{ secrets.WPT_API_KEY }}
          urls: |
            https://example.com/
            https://example.com/about
          label: 'GitHub Action Test'
          budget: 'wpt-budget.json'
          wptOptions: 'wpt-options.json'

And a wpt-options.json file containing:

{
    "runs": 1,
    "location": "Dulles:Chrome",
    "connectivity": "Cable",
    "blockAds": true
}

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.


Learn about more WebPageTest API Integrations in our docs

More Repositories

1

WebPageTest

Official repository for WebPageTest
PHP
3,047
star
2

WebPageTest.api-nodejs

WebPageTest API wrapper for NodeJS
JavaScript
1,644
star
3

workflow-telemetry-action

Github action to collect metrics (CPU, memory, I/O, etc ...) from your workflows to help you debug and optimize your CI/CD pipeline
TypeScript
264
star
4

WebPageTest.bulk-tester

Google App Script for spreadsheet that uses the WPT API to bulk test URLs
JavaScript
259
star
5

WebPageTest.agent

Cross-platform WebPageTest agent
Python
210
star
6

WebPageTest.RUM-SpeedIndex

Calculate SpeedIndex measurements from the field
JavaScript
200
star
7

WebPageTest.docs

Documentation for WebPageTest
JavaScript
192
star
8

WebPageTest.visual-metrics

Calculate visual performance metrics from a video (Speed Index, Visual Complete, Incremental progress, etc)
Python
154
star
9

WebPageTest.win-shaper

Windows traffic-shaping packet filter
C++
126
star
10

WebPageTest.xrecord

Console app for capturing video on OS X (particularly from iOS devices)
Swift
122
star
11

WebPageTest.beacon-ml

Evaluate web beacon metrics for impact on business metrics
Python
75
star
12

WebPageTest.tsproxy

Traffic-shaping SOCKS5 proxy
Python
73
star
13

Pietrasanta-traceroute

C
39
star
14

Tracing.examples-kubernetes-java

Catchpoint Tracing examples for Java applications deploying to Kubernetes
Java
23
star
15

WebPageTest.slack

WebPageTest and Slack Integration
JavaScript
21
star
16

WebPageTest.api-recipes

A collection of useful recipes for the WebPageTest API
JavaScript
13
star
17

WebPageTest.agent-install

Automated scripts for installing dedicated wptagent instances
Shell
10
star
18

WebPageTest.iTether

Reverse-tether app for iOS
Python
9
star
19

WebPageTest.iWptBrowser

wkWebView browser shell for iOS WebPagetest agent (integrates with wptagent)
Swift
9
star
20

WebPageTest.server-install

Installation scripts for the WebPageTest server
Shell
9
star
21

WebPageTest.vscode-extension

JavaScript
7
star
22

foresight-test-kit-action

Action for optimizing your tests by listing test runs and with history
TypeScript
7
star
23

WebPageTest.recorder-chrome-extension

A Chrome extension for outputting user recording sessions as WebPageTest Custom Scripts
JavaScript
6
star
24

WebPageTest.pcap-parser

Parser to extract information from tcpdump pcap files for WebPageTest
Python
6
star
25

WebPageTest.recorder-to-script

Script to convert Chrome user flow recordings to WPT Custom Scripts
TypeScript
6
star
26

WebPageTest.trace-parser

Parser to extract information from Chrome Traces for WebPageTest
Python
6
star
27

foresight-issues

This is the place where the Foresight issues are put in the table
5
star
28

Integrations.SIP

Shell
5
star
29

foresight-workflow-kit-action

TypeScript
5
star
30

WebPageTest.extension-chrome

Chrome helper extension to launch WebPageTest for current URL
JavaScript
5
star
31

WebPageTest.adbwatch

Python app that monitors and kills the Android Debug Bridge when it stops working.
C++
4
star
32

WebPageTest.devtools-parser

Parse a remote dev tools event log and produce page-level and request information json files
Python
3
star
33

WebPageTest.healthcheck

HTTP Healthcheck responder for WebPageTest agents (wptagent)
Python
3
star
34

WebPageTest.etw

Windows ETW watcher for wptagent
C#
3
star
35

WebPageTest.browser-install

Automatically install and keep browsers up to date with the latest releases (on Windows)
Python
2
star
36

Community-Scripts

Repository for custom scripts.
Python
2
star
37

WebPageTest.chromehooks

Windows command-line utility to find the function offsets for SSL/TLS functions in Chrome using the public symbols
Python
2
star
38

WebPageTest.microsoft-teams-bot

JavaScript
2
star
39

Integrations.GoogleCloudMonitoring

JavaScript
2
star
40

WebPageTest.extension-firefox

Extension for Firefox to launch WebPageTest for current URL
JavaScript
2
star
41

Integrations.splunk

Python
1
star
42

Integrations.SumoLogic

1
star
43

WebPageTest.crawler

JavaScript
1
star
44

WebPageTest.battery-time

Browser-based battery life test suite. Used for measuring how long a device can run on a single charge.
1
star
45

terraform-provider-catchpoint

Go
1
star
46

foresight-client-sdk

Foresight API client SDK
Java
1
star
47

Integrations.NewRelic

New Relic Integrations uses catchpoint Test Data Webhook to send data to New Relic Platform, this is accomplished by using New Relic’s Metrics API. To complete this integration, we will rely on third party cloud function to accept the data from Catchpoint API, process it in the desired format and then push it to New Relic. With this integration we are enabling DevOps team to visualise Catchpoints digital experience data with New Relic’s Application Performance Monitoring (APM) data together.
JavaScript
1
star
48

WebPageTest.winres

Set the Windows desktop to the maximum supported by the monitor/video card. This is primarily used in a headless environment like EC2 to maximize the desktop for visual testing.
C++
1
star
49

WebPageTest.tcpdump

Windows tcpdump console app for wptagent (requires WinPCap)
C
1
star
50

Tracing.examples-kubernetes-go

Catchpoint Tracing examples for Go applications deploying to Kubernetes
Go
1
star
51

webpage-visually-complete

Visually Complete is calculated by reporting the time until roughly 80% of elements in the viewport have loaded. It references img, iframe, css, script, and subdocument elements in the Resource Timing API to determine the time from navigation to the page appearing loaded to an end user.
1
star