Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WordPress Playground #173

Merged
merged 40 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f401712
Remove now obsolete mu-plugin
swissspidy Jul 19, 2024
da90b66
Try using WordPress Playground
swissspidy Jul 19, 2024
f0ecc85
Add env var
swissspidy Jul 19, 2024
90e1ab4
Fix option name
swissspidy Jul 19, 2024
d9473d4
Update workflow names
swissspidy Jul 19, 2024
c21c509
Run server process in background
swissspidy Jul 19, 2024
b00e028
Remove now obsolete config file
swissspidy Jul 22, 2024
1c41dbc
Fix args
swissspidy Jul 22, 2024
f7fc013
Pass php version arg
swissspidy Jul 22, 2024
b2c8034
Cleanup
swissspidy Jul 22, 2024
debbd10
Explicitly disable networking
swissspidy Jul 22, 2024
cb2a02b
Use shorthands
swissspidy Jul 22, 2024
84658a3
Blueprints, group output
swissspidy Jul 22, 2024
f86127c
Merge branch 'main' into try/wp-playground
swissspidy Jul 22, 2024
8e72b20
Add names
swissspidy Jul 22, 2024
d1fe6d5
Fix arrays
swissspidy Jul 22, 2024
c24915d
Use `github.workspace`
swissspidy Jul 22, 2024
d100021
Fix jq
swissspidy Jul 22, 2024
3c78821
Fix shard args
swissspidy Jul 22, 2024
9100c36
Swap yoast with akismet
swissspidy Jul 22, 2024
4079370
Actually activate the plugin
swissspidy Jul 22, 2024
1ce7056
Cleanup, update deps
swissspidy Jul 22, 2024
35333bf
FIx path
swissspidy Jul 22, 2024
8702285
Merge branch 'main' into try/wp-playground
swissspidy Aug 14, 2024
e49c63d
Merge branch 'main' into try/wp-playground
swissspidy Sep 24, 2024
39cbc29
Update docs
swissspidy Sep 25, 2024
2f0aa32
Update docs
swissspidy Sep 25, 2024
3826383
Add missing env vars
swissspidy Sep 25, 2024
32994ff
Test with previous-results
swissspidy Sep 25, 2024
089fad3
kill-port
swissspidy Sep 25, 2024
8652c37
Try again
swissspidy Sep 25, 2024
ad19436
Move condition
swissspidy Sep 25, 2024
8694c6f
Add another test case
swissspidy Sep 25, 2024
7b704d2
Rename results file
swissspidy Sep 25, 2024
6242c73
Use `runner.temp`
swissspidy Sep 25, 2024
51d8535
Use `RUNNER_TEMP` directly
swissspidy Sep 25, 2024
87345af
Always pass path
swissspidy Sep 25, 2024
ee21889
Round percentages
swissspidy Sep 25, 2024
ddd50a8
Fix formatting
swissspidy Sep 25, 2024
2016a80
Update readme
swissspidy Sep 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test-basic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'build-test'
name: 'Basic Tests'
on: # rebuild any PRs and main branch changes
pull_request:
push:
Expand All @@ -8,6 +8,7 @@ on: # rebuild any PRs and main branch changes

jobs:
basic:
name: 'Run tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/test-comparison.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: 'Test with comparison'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
comparison-same:
name: 'Run tests with same version'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run performance tests (before)
id: before
uses: ./
with:
urls: |
/
/sample-page/
plugins: |
./tests/dummy-plugin
blueprint: './tests/blueprint-complex.json'
iterations: 5
repetitions: 1
wp-version: 'latest'
print-results: false
upload-artifacts: false

- name: Run performance tests (after)
id: after
uses: ./
with:
urls: |
/
/sample-page/
plugins: |
./tests/dummy-plugin
blueprint: './tests/blueprint-complex.json'
iterations: 5
repetitions: 1
wp-version: 'latest'
previous-results: ${{ steps.before.outputs.results }}
print-results: true
upload-artifacts: false
comparison-different:
name: 'Run tests with different versions'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run performance tests (before)
id: before
uses: ./
with:
urls: |
/
/sample-page/
plugins: |
./tests/dummy-plugin
blueprint: './tests/blueprint-complex.json'
iterations: 5
repetitions: 1
wp-version: '6.5'
print-results: false
upload-artifacts: false

- name: Run performance tests (after)
id: after
uses: ./
with:
urls: |
/
/sample-page/
plugins: |
./tests/dummy-plugin
blueprint: './tests/blueprint-complex.json'
iterations: 5
repetitions: 1
wp-version: '6.6'
previous-results: ${{ steps.before.outputs.results }}
print-results: true
upload-artifacts: false
8 changes: 4 additions & 4 deletions .github/workflows/test-complex.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'build-test'
name: 'Complex Tests'
on: # rebuild any PRs and main branch changes
pull_request:
push:
Expand All @@ -8,6 +8,7 @@ on: # rebuild any PRs and main branch changes

jobs:
complex:
name: 'Run tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -20,9 +21,8 @@ jobs:
/
/sample-page/
plugins: |
./dummy-plugin
https://downloads.wordpress.org/plugin/performant-translations.zip
https://downloads.wordpress.org/plugin/wordpress-seo.zip
./tests/dummy-plugin
blueprint: './tests/blueprint-complex.json'
iterations: 5
repetitions: 1
wp-version: 'trunk'
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'build-test'
name: 'Matrix Tests'
on: # rebuild any PRs and main branch changes
pull_request:
push:
Expand All @@ -8,6 +8,7 @@ on: # rebuild any PRs and main branch changes

jobs:
matrix:
name: 'Run tests'
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
Expand All @@ -25,10 +26,11 @@ jobs:
/
/sample-page/
plugins: |
./dummy-plugin
./tests/dummy-plugin
shard: ${{ matrix.shard }}

merge-reports:
name: 'Merge reports'
# Merge reports after playwright-tests, even if some shards have failed
if: always()
needs: [matrix]
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'test-pr-comment'
name: 'Test with PR comment'
on: # rebuild any PRs and main branch changes
pull_request:
push:
Expand All @@ -8,6 +8,7 @@ on: # rebuild any PRs and main branch changes

jobs:
basic:
name: 'Run tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -21,3 +22,4 @@ jobs:
/sample-page/
create-comment: true
github-token: ${{ secrets.PR_COMMENT_TOKEN }}
repetitions: 5
92 changes: 71 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ A GitHub action to measure performance metrics of WordPress sites.

Results are posted as comments to pull requests and as [GitHub Action job summaries](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/).

It collects data from the `Server-Timing` header and runs Lighthouse on a given set of URLs.
It collects data from the `Server-Timing` header and runs Lighthouse on a given set of URLs.

**Note:** Tests are run using [WordPress Playground](https://wordpress.org/playground/), which means you can use [blueprints](https://wordpress.github.io/wordpress-playground/blueprints) to prepare the test environment suitable to your needs.

## Example

<img width="1154" alt="Screenshot of a GitHub Action job summary output by this action" src="https://github.com/swissspidy/wp-performance-action/assets/841956/bb543ba2-a142-49d5-bb45-77d11f121824">

Expand All @@ -24,59 +28,78 @@ See [action.yml](action.yml)
github-token: ''

# Whether to create PR comments with performance results.
#
# Might require a custom `github-token` to be set.
#
# Default: false
create-comment: ''

# Whether to add results to the workflow summary.
#
# Default: true
print-results: ''

# Whether to upload any artifacts.
#
# Default: true
upload-artifacts: ''

# Whether to log additional debugging information
#
# Default: ${{ runner.debug == '1' }}
debug: ''

# List of URLs on the WordPress site to test.
#
# Each URL should be separated with new lines.
#
# Default: ''
urls: ''

# List of plugins to install.
# List of plugin directories to mount.
#
# Each plugin should be separated with new lines.
# Supports paths to local directories or ZIP URLs.
# Performance Lab (performance-lab) is always installed.
# Needs to be a path to a local directory.
# For installing plugins from the plugin directory
# or a ZIP file, use a blueprint.
#
# Default: ''
plugins: ''

# List of themes to install.
# List of theme directories to mount.
#
# Each theme should be separated with new lines.
# Supports paths to local directories or ZIP URLs.
# Twenty Twenty-One (twentytwentyone) and Twenty Twenty-Three (twentytwentythree)
# are always installed.
# Needs to be a path to a local directory.
# For installing themes from the theme directory
# or a ZIP file, use a blueprint.
#
# Default: ''
themes: ''

# Theme to activate on the site.
# Theme needs to be already installed.
# Blueprint to use for setting up the environment.
#
# Use this to install or activate additional plugins, defining constants,
# and much more.
#
# Default: 'twentytwentyone'
active-theme: ''
# See https://wordpress.github.io/wordpress-playground/blueprints for more information.
#
# Default: ''
blueprint: ''

# WordPress version to use.
# Supports aliases such as latest, nightly, or trunk.
# Also supports ZIP URLs or a Git reference from https://github.com/WordPress/wordpress
# to install a specific version.
#
# Loads the specified WordPress version.
# Accepts the last four major WordPress versions.
# You can also use the generic values 'latest', 'nightly', or 'beta'.
#
# Default: 'latest'
wp-version: ''

# PHP version to use.
# Defaults to whatever version is the default
# in the Docker-maintained WordPress image
# (currently 8.0 as of November 2023)
#
# Default: 'auto'
# Accepts 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3.
#
# Default: 'latest'
php-version: ''

# Number of times the tests should be repeated.
Expand Down Expand Up @@ -133,6 +156,8 @@ steps:

### Advanced

Add a workflow (`.github/workflows/build-test.yml`):

```yaml
steps:
- name: Checkout
Expand All @@ -146,12 +171,37 @@ steps:
/sample-page/
plugins: |
./my-awesome-plugin
https://downloads.wordpress.org/plugin/performant-translations.zip
https://downloads.wordpress.org/plugin/wordpress-seo.zip
blueprint: ./my-custom-blueprint.json
iterations: 5
repetitions: 1
```

Add a blueprint (`my-custom-blueprint.json`):

```json
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"plugins": [
"performant-translations",
"akismet"
],
"steps": [
{
"step": "defineWpConfigConsts",
"consts": {
"WP_DEBUG": true
}
},
{
"step": "activatePlugin",
"pluginName": "My Awesome Plugin",
"pluginPath": "/wordpress/wp-content/plugins/my-awesome-plugin"
}
]
}

```

### Running tests in parallel (sharding)

```yaml
Expand Down
Loading