Skip to content

Commit

Permalink
Refactor GitHub Actions workflow for PHP tests
Browse files Browse the repository at this point in the history
Simplified and streamlined the CI workflow, merging jobs and renaming the workflow file to `test.yml`. Improved test matrix to include multiple OS and PHP versions with dependency variations. Added caching for Composer dependencies to enhance performance.
  • Loading branch information
renfordt committed Jan 18, 2025
1 parent fc2cc32 commit ca4033c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 142 deletions.
142 changes: 0 additions & 142 deletions .github/workflows/php.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on: ['push', 'pull_request']

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['8.2', '8.3', '8.4']
dependency-version: [prefer-lowest, prefer-stable]

name: Tests PHP${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: xdebug

- name: Get Composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }}
restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-

- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist

- name: Integration Tests
run: php ./vendor/phpunit/phpunit/phpunit --testsuite default

0 comments on commit ca4033c

Please # to comment.