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 : 5.1.x-dev
11+ PHP_VERSION : 8.4
812
913permissions :
1014 contents : read
1115
12- env :
13- COMPOSER_ROOT_VERSION : " 5.1.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 : Type Checker
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 :
4672 php-version : 8.3
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,35 +83,121 @@ 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.1"
65- - " 8.2"
66- - " 8.3"
67- - " 8.4"
68- - " 8.5"
92+ - 8.1
93+ - 8.2
94+ - 8.3
95+ - 8.4
96+ - 8.5
97+ - 8.6
6998
7099 steps :
71- - name : " Checkout"
72- uses : " actions/checkout@v4"
100+ - name : Checkout
101+ uses : actions/checkout@v5
102+ with :
103+ fetch-depth : 1
104+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
105+
106+ - name : Use local branch
107+ shell : bash
108+ run : |
109+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
110+ git branch -D $BRANCH 2>/dev/null || true
111+ git branch $BRANCH HEAD
112+ git checkout $BRANCH
113+
114+ - name : Install PHP with extensions
115+ uses : shivammathur/setup-php@v2
116+ with :
117+ php-version : ${{ matrix.php-version }}
118+ coverage : none
119+ tools : none
120+
121+ - name : Get Composer cache directory
122+ id : composer-cache
123+ shell : bash
124+ run : |
125+ echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
73126
74- - name : " Install PHP with extensions "
75- uses : " shivammathur/setup-php@v2 "
127+ - name : Cache Composer cache directory
128+ uses : actions/cache@v4
76129 with :
77- php-version : " ${{ matrix.php-version }}"
78- coverage : " xdebug"
79- ini-values : memory_limit=-1
130+ path : ${{ steps.composer-cache.outputs.dir }}
131+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
132+ restore-keys : ${{ runner.os }}-composer-
133+
134+ - name : Install dependencies with Composer
135+ run : ./tools/composer update --no-ansi --no-interaction --no-progress
80136
81- - name : " Install dependencies with Composer "
82- run : " ./tools/composer update --no-ansi --no-interaction --no-progress "
137+ - name : Run tests with PHPUnit
138+ run : vendor/bin/phpunit
83139
84- - name : " Run tests with PHPUnit "
85- run : " vendor/bin/phpunit --coverage-clover=coverage.xml "
140+ code-coverage :
141+ name : Code Coverage
86142
87- - name : " Send code coverage report to Codecov.io"
88- env :
89- CODECOV_TOKEN : " ${{ secrets.CODECOV_TOKEN }}"
90- run : " bash <(curl -s https://codecov.io/bash) || true"
143+ needs :
144+ - tests
145+
146+ runs-on : ubuntu-latest
147+ timeout-minutes : 5
148+
149+ steps :
150+ - name : Checkout
151+ uses : actions/checkout@v5
152+ with :
153+ fetch-depth : 1
154+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
155+
156+ - name : Use local branch
157+ shell : bash
158+ run : |
159+ BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
160+ git branch -D $BRANCH 2>/dev/null || true
161+ git branch $BRANCH HEAD
162+ git checkout $BRANCH
163+
164+ - name : Install PHP with extensions
165+ uses : shivammathur/setup-php@v2
166+ with :
167+ php-version : ${{ matrix.php-version }}
168+ coverage : xdebug
169+ tools : none
170+
171+ - name : Get Composer cache directory
172+ id : composer-cache
173+ shell : bash
174+ run : |
175+ echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
176+
177+ - name : Cache Composer cache directory
178+ uses : actions/cache@v4
179+ with :
180+ path : ${{ steps.composer-cache.outputs.dir }}
181+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
182+ restore-keys : ${{ runner.os }}-composer-
183+
184+ - name : Install dependencies with Composer
185+ run : ./tools/composer update --no-ansi --no-interaction --no-progress
186+
187+ - name : Collect code coverage with PHPUnit
188+ run : vendor/bin/phpunit --log-junit test-results.xml --coverage-clover=code-coverage.xml
189+
190+ - name : Upload test results to Codecov.io
191+ if : ${{ !cancelled() }}
192+ uses : codecov/test-results-action@v1
193+ with :
194+ token : ${{ secrets.CODECOV_TOKEN }}
195+ disable_search : true
196+ files : ./test-results.xml
197+
198+ - name : Upload code coverage data to Codecov.io
199+ uses : codecov/codecov-action@v4
200+ with :
201+ token : ${{ secrets.CODECOV_TOKEN }}
202+ disable_search : true
203+ files : ./code-coverage.xml
0 commit comments