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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
php-version: '7.4'
coverage: none
tools: composer:v1, cs2pr
tools: cs2pr
- name: composer install
run: composer install
- name: PHPCS check
Expand Down
75 changes: 59 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Test
name: PHPUnit Tests

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- develop
Expand All @@ -16,23 +14,68 @@ permissions:

jobs:
phpunit:
name: Test PHP ${{ matrix.php }} WP ${{ matrix.wp }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.4', '8.3', '8.2', '8.1', '8.0', '7.4' ]
wp: [ latest, trunk ]
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }}

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV"
echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV"

- uses: getong/mariadb-action@d6d2ec41fd5588f369be4c9398ce77ee725ca9ea # v1.11
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set PHP version
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
with:
php-version: '7.4'
coverage: none
tools: composer:v1
##
# This allows Composer dependencies to be installed using a single step.
#
# Since the tests are currently run within the Docker containers where the PHP version varies,
# the same PHP version needs to be configured for the action runner machine so that the correct
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
with:
php-version: '${{ matrix.php }}'
coverage: none

- name: Install dependencies
run: composer install
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1

- name: PHPUnit
run: './vendor/bin/phpunit'
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Install NPM dependencies
run: npm ci

- name: Start the Docker testing environment
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 10
max_attempts: 3
command: |
npm run env:start

- name: Log versions
run: |
npm run env -- run cli php -- -v
npm run env -- run cli wp core version

- name: Run PHPUnit tests
id: phpunit
run: |
npm run test:php
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ Thumbs.db
Desktop.ini

*.cache
/tests/_output/*
!/tests/_output/.gitkeep
/tests/.phpunit.result.cache
22 changes: 21 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [".", "./tests/test-plugin"]
"plugins": [".", "./tests/test-plugin"],
"env": {
"development": {
"config": {
"WP_DEVELOPMENT_MODE": "plugin",
"WP_ENVIRONMENT_TYPE": "development",
"WP_DEBUG": true,
"WP_DEBUG_LOG": "/var/www/html/wp-content/plugins/Ad-Refresh-Control/tests/_output/debug.log"
}
},
"tests": {
"config": {
"WP_DEBUG": true,
"FS_METHOD": "direct"
},
"mappings": {
"wp-cli.yml": "./tests/bin/wp-cli.yml"
}
}
}
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
}
},
"require-dev": {
"phpunit/phpunit": "^8.2",
"10up/wp_mock": "0.4.2",
"10up/phpcs-composer": "dev-master"
"10up/phpcs-composer": "dev-master",
"wp-phpunit/wp-phpunit": "^6.9",
"yoast/phpunit-polyfills": "^4.0"
},
"scripts": {
"lint": "phpcs .",
Expand Down
Loading
Loading