Skip to content
Merged
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
53 changes: 15 additions & 38 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,34 @@ jobs:

strategy:
matrix:
php: [ '7.4', '8.2' ]
php: [ '7.4', '8.3' ]
wordpress: [ '6.4', '6.8' ]
allowed_failure: [false]
coverage: [false]
include:
# Check upcoming WP.
- php: '8.2'
wordpress: 'trunk'
- php: '8.3'
wordpress: 'master'
allowed_failure: true
coverage: false
# Check upcoming PHP.
- php: '8.3'
wordpress: 'latest'
- php: '8.5'
wordpress: '6.8'
allowed_failure: true
coverage: false
# Code coverage on latest PHP and WP.
- php: '8.2'
wordpress: 'latest'
allowed_failure: false
coverage: true
fail-fast: false
continue-on-error: ${{ matrix.allowed_failure }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install wordpress environment
run: npm install -g @wordpress/env

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
coverage: none
tools: composer

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
Expand All @@ -69,29 +65,10 @@ jobs:
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Start MySQL Service
run: sudo systemctl start mysql.service

- name: Setting mysql_native_password for PHP <= 7.3
if: ${{ matrix.php <= 7.3 }}
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"

- name: Prepare environment for integration tests
run: composer prepare-ci --no-interaction
- name: Setup wp-env
run: wp-env start
env:
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress }}

- name: Run integration tests
if: ${{ matrix.coverage == false }}
run: composer test --no-interaction

- name: Run integration tests with code coverage
if: ${{ matrix.coverage == true }}
run: composer coverage-ci --no-interaction

- name: Send coverage report to Codecov
if: ${{ success() && matrix.coverage == true }}
uses: codecov/codecov-action@v5
with:
files: ./clover.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
run: composer test-integration --no-interaction
181 changes: 0 additions & 181 deletions bin/install-wp-tests.sh

This file was deleted.

23 changes: 6 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
"coverage": [
"@php ./vendor/bin/phpunit --coverage-html ./.phpunit.cache/coverage-html"
],
"coverage-ci": [
"@php ./vendor/bin/phpunit"
],
"coverage-ci": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit",
"cs": [
"@php ./vendor/bin/phpcs -q"
],
Expand All @@ -51,27 +49,18 @@
"lint-ci": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle"
],
"prepare-ci": [
"bash bin/install-wp-tests.sh wordpress_test root root localhost"
],
"test": [
"@php ./vendor/bin/phpunit --no-coverage --order-by=random"
],
"test-ms": [
"@putenv WP_MULTISITE=1",
"@composer test"
]
"test-integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit --no-coverage --order-by=random",
"test-integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit --no-coverage --order-by=random'"
},
"scripts-descriptions": {
"coverage": "Run tests with code coverage reporting",
"coverage-ci": "Run tests with code coverage reporting and send results to stdout",
"coverage-ci": "Run integration tests with code coverage reporting in wp-env",
"cs": "Run PHP Code Sniffer",
"cs-fix": "Run PHP Code Sniffer and fix violations",
"i18n": "Generate a POT file for translation",
"lint": "Run PHP linting",
"lint-ci": "Run PHP linting and send results to stdout",
"prepare-ci": "Prepare the environment for integration tests",
"test": "Run all tests for the Ad Code Manager plugin",
"test-ms": "Run integration tests for the Ad Code Manager plugin in multisite mode"
"test-integration": "Run integration tests in wp-env",
"test-integration-ms": "Run integration tests in multisite mode in wp-env"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</include>
<report>
<text outputFile="php://stdout"/>
<clover outputFile="clover.xml"/>
<clover outputFile=".phpunit.cache/coverage/clover.xml"/>
</report>
</coverage>
</phpunit>