Add phpstan action #1086
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP Unit Tests | |
on: | |
push: | |
branches: | |
- 'master' | |
- 'release/**' | |
paths-ignore: | |
- '**.md' | |
- '**.txt' | |
pull_request: | |
branches: | |
- 'master' | |
env: | |
DB_DATABASE: wordpress_test | |
DB_USER: root | |
DB_PASSWORD: '' | |
jobs: | |
phpunit: | |
name: 'WP ${{ matrix.core.name }} on PHP ${{ matrix.php }}' | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
php: | |
- '7.4' | |
- '8.3' | |
core: | |
- { name: 'latest', version: 'latest' } | |
- { name: 'minimum', version: '5.9' } | |
- { name: 'trunk', version: 'trunk' } | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up MySQL | |
run: | | |
sudo /etc/init.d/mysql start | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: uopz | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies (PHP 7.4) | |
if: matrix.php == '7.4' | |
run: | | |
bash bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.core.version }} | |
composer install --prefer-dist --no-progress | |
- name: Install dependencies (other PHP versions) | |
if: matrix.php != '7.4' | |
run: | | |
bash bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.core.version }} | |
composer install --prefer-dist --no-progress --ignore-platform-reqs | |
- name: Run test suite | |
run: | | |
composer dump-autoload -o | |
php vendor/bin/phpunit | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./build/logs/clover.xml | |
rerun-on-failure: | |
needs: phpunit | |
if: failure() && fromJSON(github.run_attempt) < 3 | |
runs-on: ubuntu-latest | |
steps: | |
- env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
GH_DEBUG: api | |
run: gh workflow run rerun.yml -r ${{ github.head_ref || github.ref_name }} -F run_id=${{ github.run_id }} |