Refactor/improve readability #31
Workflow file for this run
This file contains hidden or 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: Tests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - '*.x' | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| php: ['7.4', '8.2', '8.4'] | |
| node: ['20'] | |
| name: ${{ matrix.os }} node-${{ matrix.node }} php-${{ matrix.php }} | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| extensions: curl, dom, libxml, mbstring, pcntl, pdo, pdo_sqlite, sqlite, xdebug, zip | |
| key: cache-v1 | |
| GITHUB_ACTIONS: true | |
| PHPUNIT_PROJECT: src/PHPUnit/__tests__/fixtures/phpunit-stub | |
| PEST_PROJECT: src/PHPUnit/__tests__/fixtures/pest-stub | |
| # Minimum PHP version per stub (used to skip incompatible installs) | |
| PHPUNIT_MIN_PHP: v9=7.3 v10=8.1 v11=8.2 v12=8.3 | |
| PEST_MIN_PHP: v2=8.2 v3=8.2 v4=8.3 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup cache environment | |
| id: extcache | |
| uses: shivammathur/cache-extensions@v1 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: ${{ env.extensions }} | |
| key: ${{ env.key }} | |
| - name: Cache extensions | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.extcache.outputs.dir }} | |
| key: ${{ steps.extcache.outputs.key }} | |
| restore-keys: ${{ steps.extcache.outputs.key }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: ${{ env.extensions }} | |
| tools: composer:v2 | |
| coverage: xdebug | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: npm | |
| - name: Install Composer dependencies (PHPUnit stubs) | |
| run: | | |
| lookup="${{ env.PHPUNIT_MIN_PHP }}" | |
| for dir in $(ls -d ${{ env.PHPUNIT_PROJECT }}/v*/ | sort -V); do | |
| stub=$(basename "$dir") | |
| min=$(echo "$lookup" | tr ' ' '\n' | grep "^${stub}=" | cut -d= -f2) | |
| min=${min:-99} | |
| if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then | |
| echo "::group::Installing $stub (PHP >= $min)" | |
| (cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true | |
| echo "::endgroup::" | |
| else | |
| echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})" | |
| fi | |
| done | |
| - name: Install Composer dependencies (Pest stubs) | |
| run: | | |
| lookup="${{ env.PEST_MIN_PHP }}" | |
| for dir in $(ls -d ${{ env.PEST_PROJECT }}/v*/ | sort -V); do | |
| stub=$(basename "$dir") | |
| min=$(echo "$lookup" | tr ' ' '\n' | grep "^${stub}=" | cut -d= -f2) | |
| min=${min:-99} | |
| if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then | |
| echo "::group::Installing $stub (PHP >= $min)" | |
| (cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true | |
| echo "::endgroup::" | |
| else | |
| echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})" | |
| fi | |
| done | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Run the tests | |
| run: npm run vitest | |
| - name: Send to codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: unittests |