11# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
22
33on :
4- - " pull_request"
5- - " push"
4+ - pull_request
5+ - push
66
7- name : " CI"
7+ name : CI
8+
9+ env :
10+ COMPOSER_ROOT_VERSION : 6.0.x-dev
11+ PHP_VERSION : 8.4
812
913permissions :
1014 contents : read
1115
12- env :
13- COMPOSER_ROOT_VERSION : " 6.0.x-dev"
14-
1516jobs :
1617 coding-guidelines :
1718 name : Coding Guidelines
1819
1920 runs-on : ubuntu-latest
21+ timeout-minutes : 5
2022
2123 steps :
2224 - name : Checkout
23- uses : actions/checkout@v4
25+ uses : actions/checkout@v5
26+ with :
27+ fetch-depth : 1
28+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
29+
30+ - name : Use local branch
31+ shell : bash
32+ run : |
33+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
34+ git branch -D $BRANCH 2>/dev/null || true
35+ git branch $BRANCH HEAD
36+ git checkout $BRANCH
2437
2538 - name : Install PHP
2639 uses : shivammathur/setup-php@v2
2740 with :
28- php-version : 8.3
41+ php-version : ${{ env.PHP_VERSION }}
2942 coverage : none
43+ tools : none
3044
3145 - name : Run PHP-CS-Fixer
3246 run : ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose
@@ -35,16 +49,29 @@ jobs:
3549 name : Static Analysis
3650
3751 runs-on : ubuntu-latest
52+ timeout-minutes : 5
3853
3954 steps :
4055 - name : Checkout
41- uses : actions/checkout@v4
56+ uses : actions/checkout@v5
57+ with :
58+ fetch-depth : 1
59+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
60+
61+ - name : Use local branch
62+ shell : bash
63+ run : |
64+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
65+ git branch -D $BRANCH 2>/dev/null || true
66+ git branch $BRANCH HEAD
67+ git checkout $BRANCH
4268
4369 - name : Install PHP
4470 uses : shivammathur/setup-php@v2
4571 with :
46- php-version : 8.3
72+ php-version : ${{ env.PHP_VERSION }}
4773 coverage : none
74+ tools : none
4875
4976 - name : Install dependencies with Composer
5077 run : ./tools/composer update --no-interaction --no-ansi --no-progress
@@ -56,40 +83,120 @@ jobs:
5683 name : Tests
5784
5885 runs-on : ubuntu-latest
86+ timeout-minutes : 5
5987
6088 strategy :
6189 fail-fast : false
6290 matrix :
6391 php-version :
64- - " 8.2"
65- - " 8.3"
66- - " 8.4"
67- - " 8.5"
92+ - 8.2
93+ - 8.3
94+ - 8.4
95+ - 8.5
96+ - 8.6
6897
6998 steps :
70- - name : " Checkout"
71- uses : " actions/checkout@v4"
99+ - name : Checkout
100+ uses : actions/checkout@v5
101+ with :
102+ fetch-depth : 1
103+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
104+
105+ - name : Use local branch
106+ shell : bash
107+ run : |
108+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
109+ git branch -D $BRANCH 2>/dev/null || true
110+ git branch $BRANCH HEAD
111+ git checkout $BRANCH
112+
113+ - name : Install PHP with extensions
114+ uses : shivammathur/setup-php@v2
115+ with :
116+ php-version : ${{ matrix.php-version }}
117+ coverage : none
118+ tools : none
119+
120+ - name : Get Composer cache directory
121+ id : composer-cache
122+ shell : bash
123+ run : |
124+ echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
72125
73- - name : " Install PHP with extensions "
74- uses : " shivammathur/setup-php@v2 "
126+ - name : Cache Composer cache directory
127+ uses : actions/cache@v4
75128 with :
76- php-version : " ${{ matrix.php-version }}"
77- coverage : " xdebug "
78- ini-values : memory_limit=-1
129+ path : ${{ steps.composer-cache.outputs.dir }}
130+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
131+ restore-keys : ${{ runner.os }}-composer-
79132
80- - name : " Install dependencies with Composer"
81- run : " ./tools/composer update --no-ansi --no-interaction --no-progress"
133+ - name : Install dependencies with Composer
134+ run : ./tools/composer update --no-ansi --no-interaction --no-progress
135+
136+ - name : Run tests with PHPUnit
137+ run : vendor/bin/phpunit
138+
139+ code-coverage :
140+ name : Code Coverage
141+
142+ needs :
143+ - tests
144+
145+ runs-on : ubuntu-latest
146+ timeout-minutes : 5
147+
148+ steps :
149+ - name : Checkout
150+ uses : actions/checkout@v5
151+ with :
152+ fetch-depth : 1
153+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
154+
155+ - name : Use local branch
156+ shell : bash
157+ run : |
158+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
159+ git branch -D $BRANCH 2>/dev/null || true
160+ git branch $BRANCH HEAD
161+ git checkout $BRANCH
162+
163+ - name : Install PHP with extensions
164+ uses : shivammathur/setup-php@v2
165+ with :
166+ php-version : ${{ matrix.php-version }}
167+ coverage : xdebug
168+ tools : none
169+
170+ - name : Get Composer cache directory
171+ id : composer-cache
172+ shell : bash
173+ run : |
174+ echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
175+
176+ - name : Cache Composer cache directory
177+ uses : actions/cache@v4
178+ with :
179+ path : ${{ steps.composer-cache.outputs.dir }}
180+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181+ restore-keys : ${{ runner.os }}-composer-
182+
183+ - name : Install dependencies with Composer
184+ run : ./tools/composer update --no-ansi --no-interaction --no-progress
82185
83- - name : " Run tests with PHPUnit"
84- run : " vendor/bin/phpunit --log-junit junit .xml --coverage-clover=coverage.xml"
186+ - name : Collect code coverage with PHPUnit
187+ run : vendor/bin/phpunit --log-junit test-results .xml --coverage-clover=code- coverage.xml
85188
86189 - name : Upload test results to Codecov.io
87190 if : ${{ !cancelled() }}
88191 uses : codecov/test-results-action@v1
89192 with :
90193 token : ${{ secrets.CODECOV_TOKEN }}
194+ disable_search : true
195+ files : ./test-results.xml
91196
92197 - name : Upload code coverage data to Codecov.io
93198 uses : codecov/codecov-action@v4
94199 with :
95200 token : ${{ secrets.CODECOV_TOKEN }}
201+ disable_search : true
202+ files : ./code-coverage.xml
0 commit comments