auto re-run failed GH workflows #908
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.2' | |
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: Run test suite | |
run: | | |
composer dump-autoload -o | |
curl -ksSfL -o ~/phpunit-9.phar https://phar.phpunit.de/phpunit-9.phar | |
php ~/phpunit-9.phar | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
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 }} |