Skip to content

Commit 29495fe

Browse files
docs: document the GitHub action in the README
1 parent 934cfde commit 29495fe

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,55 @@ journalctl -u wordpressphpunittestrunner.timer
387387
journalctl -n 120 -u wordpressphpunittestrunner.service
388388
```
389389

390+
### Running using GitHub actions
391+
392+
You can also use the GitHub action in `.github/actions/wordpress-host-test` to automatically run this test suite on your host. Since this action will usually run on GitHub's infrastructure, the action presumes that the actual hosting environment will be reachable via SSH.
393+
394+
To run the GitHub action using a schedule, create a new GitHub repository with the following action:
395+
396+
```yaml
397+
name: Run WordPress Unit Tests
398+
on:
399+
schedule:
400+
- cron: 0 0 * * *
401+
workflow_dispatch:
402+
jobs:
403+
run-tests:
404+
name: Run Test Suite
405+
runs-on: ubuntu-latest
406+
steps:
407+
- uses: WordPress/phpunit-test-runner/.github/actions/wordpress-host-test@master
408+
with:
409+
report-api-key: '${{ secrets.REPORT_API_KEY }}'
410+
ssh-connect: '${{ secrets.SSH_CONNECT }}'
411+
ssh-private-key: '${{ secrets.SSH_PRIVATE_KEY }}'
412+
remote-test-dir: /files/wordpress-host-test
413+
database-host: ${{ secrets.DATABASE_HOST }}
414+
database-user: ${{ secrets.DATABASE_USER }}
415+
database-name: ${{ secrets.DATABASE_NAME }}
416+
database-password: ${{ secrets.DATABASE_PASSWORD }}
417+
```
418+
419+
The action also makes it easy to use matrix builds to run the same test suite across a whole matrix of different environments:
420+
421+
```yaml
422+
name: Run WordPress Unit Tests
423+
on: # [...]
424+
jobs:
425+
run-tests:
426+
strategy:
427+
matrix:
428+
ssh-target:
429+
- user@php-8.4-host.example
430+
- user@php-8.3-host.example
431+
- user@php-8.2-host.example
432+
steps:
433+
- uses: WordPress/phpunit-test-runner/.github/actions/wordpress-host-test@master
434+
with:
435+
ssh-connect: '${{ matrix.ssh-target }}'
436+
# ...
437+
```
438+
390439
## Contributing
391440

392441
If you have questions about the process or run into test failures along the way, please [open an issue in the project repository](https://github.com/WordPress/phpunit-test-runner/issues) and we’ll help diagnose/get the documentation updated. Alternatively, you can also pop into the `#hosting` channel on [WordPress.org Slack](https://make.wordpress.org/chat/) for help.

0 commit comments

Comments
 (0)