Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ updates:
github-actions:
patterns:
- "*"

# Check for updates to Composer packages.
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
97 changes: 97 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Coding Standards

on:
push:
branches:
- master
pull_request:
branches:
- master
paths:
- '**.php'
- 'composer.*'
- 'phpcs.xml.dist'
- '.github/workflows/coding-standards.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

permissions: {}

jobs:
lint:
name: PHP Syntax Check
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: '8.2'
coverage: none

- name: Check PHP syntax
run: find . -name "*.php" -not -path "./.git/*" -not -path "./vendor/*" | xargs -n1 php -l

phpcs:
name: Coding Standards
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: '8.2'
coverage: none
tools: cs2pr

- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"

- name: Cache PHPCS scan cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}

- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
with:
custom-cache-suffix: ${{ steps.get-date.outputs.date }}

- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH"

- name: Run PHPCS
id: phpcs
run: |
mkdir -p .cache
phpcs -n --report-full --cache=./.cache/phpcs.json --report-checkstyle=./.cache/phpcs-report.xml

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-report.xml

- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
90 changes: 90 additions & 0 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: PHPUnit Tests

on:
push:
branches:
- master
pull_request:
branches:
- master
paths:
- '**.php'
- '.github/workflows/phpunit-tests.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

permissions: {}

jobs:
test:
name: PHP ${{ matrix.php }} / MySQL ${{ matrix.db-version }}
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read

strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.2' ]
db-version: [ '8.0' ]

services:
mysql:
image: mysql:${{ matrix.db-version }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
MYSQL_USER: wp_test
MYSQL_PASSWORD: wp_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3

env:
WPT_PREPARE_DIR: /tmp/wp-test-runner
WPT_TEST_DIR: /tmp/wp-test-runner
WPT_DB_NAME: wordpress_test
WPT_DB_USER: wp_test
WPT_DB_PASSWORD: wp_test
WPT_DB_HOST: 127.0.0.1
WPT_REPORT_API_KEY: ''

steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24

- name: Prepare environment
run: php prepare.php

- name: Run unit tests
run: php test.php
continue-on-error: true

- name: Report results
run: php report.php
continue-on-error: true

- name: Cleanup
run: php cleanup.php
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Install NodeJS
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 20
node-version: 24

- name: Prepare environment
run: php prepare.php
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.env*
vendor/
.cache/
package-lock.json
commit.json
ignore.json
Expand Down
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "wordpress/phpunit-test-runner",
"description": "A test runner for WordPress PHPUnit tests",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.4"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.10",
"wp-coding-standards/wpcs": "^3.1"
},
"scripts": {
"format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source",
"lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source",
"lint:errors": "@lint -n"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading
Loading