Skip to content

Commit 9cc2256

Browse files
committed
ci: update run-tests.yml for improved PHP setup and caching
1 parent a2f2e0f commit 9cc2256

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

.github/workflows/run-tests.yml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,56 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212

13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
php: [8.2]
18+
stability: [prefer-stable]
19+
20+
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
21+
1322
steps:
1423
- name: Checkout code
15-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
1625
with:
1726
fetch-depth: 0
1827

1928
- name: Setup PHP
2029
uses: shivammathur/setup-php@v2
2130
with:
22-
php-version: 8.2
23-
coverage: pcov
24-
extensions: mbstring pdo sqlite3 pdo_sqlite intl json fileinfo pcntl dom xml openssl
31+
php-version: ${{ matrix.php }}
32+
coverage: xdebug
33+
extensions: mbstring pdo sqlite3 pdo_sqlite intl json fileinfo pcntl dom xml openssl zip xdebug
34+
tools: composer:v2
35+
36+
- name: Get composer cache directory
37+
id: composer-cache
38+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
39+
40+
- name: Cache dependencies
41+
uses: actions/cache@v4
42+
with:
43+
path: ${{ steps.composer-cache.outputs.dir }}
44+
key: ${{ runner.os }}-composer-${{ matrix.stability }}-${{ hashFiles('**/composer.json') }}
45+
restore-keys: ${{ runner.os }}-composer-
2546

2647
- name: Setup problem matchers
2748
run: |
2849
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
2950
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
3051
3152
- name: Install dependencies
32-
run: |
33-
composer install --no-interaction --prefer-dist --no-progress --no-suggest
53+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
3454

3555
- name: Check code formatting with PHP CS Fixer
36-
run: |
37-
vendor/bin/php-cs-fixer fix --dry-run --diff --ansi
56+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --ansi
3857

3958
- name: Analyze code statically with PHPStan
40-
run: |
41-
vendor/bin/phpstan
59+
run: vendor/bin/phpstan
4260

4361
- name: Execute tests
44-
run: |
45-
vendor/bin/phpunit
62+
run: vendor/bin/phpunit
4663

4764
- name: Prepare paths for SonarQube analysis
4865
run: |

0 commit comments

Comments
 (0)