Pin all floating version tags (@v1, @v2, @v3, @v4, @master) to full commit SHAs across all workflow files to eliminate supply chain security risk. Actions pinned: - actions/checkout@v3 -> f43a0e5 (v3.6.0) in release.yml, sync-wiki.yml - actions/checkout@v4 -> 34e1148 (v4) in tests.yml - shivammathur/setup-php@v2 -> accd612 (v2) in all workflows - actions/setup-node@v4 -> 49933ea (v4) in playground-tests*.yml, wordpress-tests.yml - actions/upload-artifact@v4 -> ea165f8 (v4) in playground-tests*.yml, wordpress-tests.yml - softprops/action-gh-release@v1 -> de2c0eb (v1) in release.yml - codacy/codacy-analysis-cli-action@v4 -> 562ee3e (v4) in code-quality.yml - github/codeql-action/upload-sarif@v3 -> 603b797 (v3) in code-quality.yml - swissspidy/wp-performance-action@v2.0.3 -> b7e3ffc (v2.0.3) in playground-tests.yml - SonarSource/sonarqube-scan-action@master -> 9598b8a in sonarcloud.yml Closes #89
71 lines
2.1 KiB
YAML
71 lines
2.1 KiB
YAML
name: PHPUnit Tests
|
|
|
|
on:
|
|
# Only run on push to main (not feature branches) to avoid duplicate runs.
|
|
# Feature branches get CI via pull_request trigger.
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
name: PHP ${{ matrix.php }} - WP ${{ matrix.wp }} - ${{ matrix.multisite && 'Multisite' || 'Single Site' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
php: [ '7.4', '8.0' ]
|
|
wp: [ 'latest' ]
|
|
multisite: [ false, true ]
|
|
|
|
services:
|
|
mysql:
|
|
image: mysql:5.7
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
MYSQL_DATABASE: wordpress_test
|
|
ports:
|
|
- 3306:3306
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv
|
|
coverage: none
|
|
|
|
- name: Install Composer dependencies
|
|
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
|
|
|
|
- name: Install WordPress test suite
|
|
run: |
|
|
set -e
|
|
echo "Installing WordPress test suite with multisite=${{ matrix.multisite }}"
|
|
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp }} false ${{ matrix.multisite && 'true' || 'false' }}
|
|
echo "WordPress test suite installed successfully"
|
|
|
|
- name: Run PHPUnit tests
|
|
env:
|
|
WP_PHPUNIT__DIR: /tmp/wordpress-tests-lib
|
|
WP_TESTS_DIR: /tmp/wordpress-tests-lib
|
|
run: |
|
|
if [ "${{ matrix.multisite }}" = "true" ]; then
|
|
WP_MULTISITE=1 composer test
|
|
else
|
|
composer test
|
|
fi
|