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

Fix Action unit testing #624

Merged
merged 51 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
aabc430
Use composer within the cli container.
dd32 Jul 11, 2024
a559553
Update wp-env.
dd32 Jul 11, 2024
d5e063f
Update the node requirement to 18.
dd32 Jul 11, 2024
47ec21f
Update composer
dd32 Jul 11, 2024
ecd9700
Update wp-env, again.
dd32 Jul 11, 2024
021d4ad
Try running phpunit via the container.
dd32 Jul 11, 2024
39f6787
Try running phpunit via the container.
dd32 Jul 11, 2024
5b93961
PHP 7.2
dd32 Aug 20, 2024
49708b1
rm local wordpress checkout.
dd32 Aug 20, 2024
cb7bff9
rm wordpress
dd32 Aug 20, 2024
efeceaa
update composer
dd32 Aug 20, 2024
4ca7561
Import tests_add_filter() via the same method as Gutenberg: https://g…
dd32 Aug 20, 2024
a35efa5
update composer
dd32 Aug 20, 2024
50860b8
update
dd32 Aug 20, 2024
3c6dd03
update packages
dd32 Aug 20, 2024
f0c8a62
Split test into multiple jobs
dd32 Aug 20, 2024
f747f9f
Drop PHP 7.2 test for now, wp-env doesn't seem to install the proper …
dd32 Aug 20, 2024
bf98ce5
disable wp_redirect()
dd32 Aug 20, 2024
04a9562
Fix email sending.
dd32 Aug 20, 2024
ccea551
Don't need to override wp_redirect, the PHP warnings don't cause a fa…
dd32 Aug 20, 2024
3369165
Updates
dd32 Aug 20, 2024
d2c69cf
Restore PHP 7.2
dd32 Aug 20, 2024
70fc5ba
Add PHP 8.3
dd32 Aug 20, 2024
c349634
Don't need to be compatible with PHP 5.6
dd32 Aug 20, 2024
cb4042f
add trunk, include versions.
dd32 Aug 20, 2024
51591d6
PHP 7.2+ for compat
dd32 Aug 20, 2024
0e9c133
Reverse order of PHP's
dd32 Aug 20, 2024
9c5d059
Fix Build
dd32 Aug 20, 2024
939b4eb
Revert the parse-gitignore package back to 0.5.1, v1 and v2 don't wor…
dd32 Aug 20, 2024
c913c1c
Restore the phpunit-watcher
dd32 Aug 20, 2024
4a9feba
Remove the old wp_deploy code.
dd32 Aug 20, 2024
9287c24
Gruntfile: Remove isTruthy.
dd32 Aug 20, 2024
1aa4fb3
Run tests on the tests container, such as not to affect the WordPress…
dd32 Aug 20, 2024
ff6636c
qrcode-generator doesn't need to be listed as a devDependency
dd32 Aug 20, 2024
b1a872e
Try adding a WP 4.6 / PHP 5.6-7.1 job due to the plugin claiming to s…
dd32 Aug 20, 2024
3b5da31
Try a more recent older WP version.
dd32 Aug 20, 2024
a6becd6
Drop PHP <7.2 tests, not possible with wp-env due to core support.
dd32 Aug 20, 2024
71e9fe8
Remove reference to /wordpress/
dd32 Aug 20, 2024
13087d6
Retry the wp-env bootup for unit testing, as this appears to fail spo…
dd32 Aug 21, 2024
3191fcb
Update composer versions to >=7.2.24 rather than 5.6, per #625
dd32 Aug 21, 2024
50701cb
Update github actions to newer node20 versions.
dd32 Aug 21, 2024
bd51db5
Ensure that the environment is started with xdebug coverage support f…
dd32 Aug 21, 2024
d4515d2
Lock to PHPUnit 9.6, this requires claiming a PHP 7.4 platform.
dd32 Aug 21, 2024
841e2fe
Remove grunt deploy
dd32 Aug 21, 2024
603dc5c
Don't need coverage support in Actions.
dd32 Aug 21, 2024
4a4d392
Take {PHP_INT_MAX}.
dd32 Aug 21, 2024
d7f04b5
Correct the wp-env command for phpunit.
dd32 Aug 21, 2024
a2dcc9a
set wp-env tests constants for the test environment, to ensure that e…
dd32 Aug 22, 2024
99504ae
Run tests with WP_DEBUG enabled, such as not to need to include unit-…
dd32 Aug 22, 2024
73948a7
Merge branch 'master' into fix/build
dd32 Aug 22, 2024
15117aa
Merge branch 'master' into fix/build
dd32 Aug 22, 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
1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/node_modules/
/tests/
/vendor/
/wordpress/

# Files
.*
Expand Down
159 changes: 127 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,142 @@ name: Test

on: [push, pull_request]

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
lint-js-css:
name: Lint JS & CSS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Install NPM dependencies
run: npm install

- name: Lint JS
run: npm run lint:js

- name: Lint CSS
run: npm run lint:css

lint-php-and-compatibility:
name: Lint PHP & PHP Compatibility checks.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP and Composer
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Setup Node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Install NPM dependencies
run: npm install

- name: Lint PHP
run: npm run lint:php || true # Ignore for now.

- name: Lint PHP Compatibility
run: composer lint-compat

test-php:
name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }}
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
- '7.3'
- '7.2'
wp:
- latest
- trunk
- '6.3'
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@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

lint:
name: Lint and Test
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: 'npm'
node-version-file: '.nvmrc'
- name: Install NPM dependencies
run: npm install

- name: Setup PHP and Composer
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
- name: Start the Docker testing environment
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: npm run env start

- name: Install NPM dependencies
run: npm install
- name: Composer install
run: |
rm composer.lock || true # We need to install fresh.
npm run composer install

- name: Lint JS
run: npm run lint:js
- name: Versions
run: |
npm run env run cli php -- -v
npm run env run cli wp core version

- name: Lint CSS
run: npm run lint:css
- name: Test
run: npm run test

- name: Lint PHP
run: npm run lint:php || true # Ignore for now.
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lint PHP Compatibility
run: composer lint-compat
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Start the Docker testing environment
run: npm run env start --xdebug=coverage
- name: Setup Node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Test
run: npm run test
- name: Install NPM dependencies
run: npm install

- name: Build
run: npm run build
- name: Build
run: npm run build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
/vendor/
/dist/
/tests/logs/
/wordpress/
.phpunit.result.cache
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
14 changes: 12 additions & 2 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"core": "./wordpress",
"phpVersion": "7.4",
"plugins": [ "." ]
"plugins": [ "." ],
"env": {
"tests": {
"config": {
"WP_DEBUG": true,
"WP_TESTS_EMAIL": "admin@example.org",
"WP_TESTS_DOMAIN": "example.org",
"WP_SITEURL": "https://example.org",
"WP_HOME": "https://example.org"
}
}
}
}
1 change: 0 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ module.exports = function( grunt ) {
'copy',
]
);

};
17 changes: 5 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
"config": {
"sort-packages": true,
"platform": {
"php": "7.4"
"php": "7.2.24"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"roots/wordpress-core-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"wordpress-install-dir": "wordpress"
},
"minimum-stability": "dev",
"prefer-stable" : true,
"require": {
Expand All @@ -33,18 +29,15 @@
"php-coveralls/php-coveralls": "^2.5",
"phpcompatibility/php-compatibility": "10.x-dev as 9.99.99",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^9.5",
"roots/wordpress-core-installer": "^1.100",
"roots/wordpress-full": "~6.0",
"phpunit/phpunit": "^8.5|^9.6",
"spatie/phpunit-watcher": "^1.23",
"wp-coding-standards/wpcs": "^3.1",
"wp-phpunit/wp-phpunit": "~6.0",
"yoast/phpunit-polyfills": "^2.0"
},
"scripts": {
"lint": "phpcs",
"lint-compat": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 7.2- --extensions=php --ignore='tests/,dist/,includes/Yubico/,vendor/,wordpress/,node_modules/' .",
"test": "phpunit",
"lint-compat": "phpcs -p --standard=PHPCompatibilityWP --runtime-set testVersion 7.2- --extensions=php --ignore='tests/,dist/,includes/Yubico/,vendor/,node_modules/' .",
"test": "vendor/bin/phpunit",
"test:watch": [
"Composer\\Config::disableProcessTimeout",
"phpunit-watcher watch --no-coverage"
Expand Down
Loading