-
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (85 loc) · 3.11 KB
/
php.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: PHP Composer
on:
push:
branches:
- develop
- v*
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
experimental: [false]
env:
code-coverage-version: '8.3' # Most recent stable PHP version.
name: PHP ${{ matrix.php-versions }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php-versions }} without code coverage
if: matrix.php-versions != env.code-coverage-version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
tools: cs2pr
- name: Setup PHP ${{ matrix.php-versions }} with code coverage
if: matrix.php-versions == env.code-coverage-version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
tools: cs2pr
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-${{ matrix.php-versions }}-
composer-
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install PHP dependencies
if: matrix.experimental == false
run: composer update --prefer-dist --no-progress
# Ignore platform requirements for experimental branches.
- name: Install PHP experimental dependencies
if: matrix.experimental
run: composer update --ignore-platform-reqs --prefer-dist --no-progress
- name: Run PHPUnit tests
run: composer run-script phpunit
- name: Run PHPStan
if: matrix.php-versions == env.code-coverage-version
run: composer run-script phpstan -- --no-progress
- name: Check code style
if: matrix.php-versions == env.code-coverage-version
run: composer run-script phpcs -- --report=checkstyle | cs2pr
# Ensure the next test run fetches the latest test ruleset.
- name: Cleanup composer cache
if: steps.cache.outputs.cache-hit != 'true'
run: rm -rf $(composer config cache-files-dir)/httpwg
- name: Upload code coverage report
if: matrix.php-versions == env.code-coverage-version
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: tmp/code-coverage
- name: Upload code coverage to codecov
if: matrix.php-versions == env.code-coverage-version
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tmp/code-coverage/clover.xml
flags: phpunit