1
1
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2
2
3
3
on :
4
- - " pull_request"
5
- - " push"
4
+ - pull_request
5
+ - push
6
6
7
- name : " CI"
7
+ name : CI
8
+
9
+ env :
10
+ COMPOSER_ROOT_VERSION : 5.1.x-dev
11
+ PHP_VERSION : 8.4
8
12
9
13
permissions :
10
14
contents : read
11
15
12
- env :
13
- COMPOSER_ROOT_VERSION : " 5.1.x-dev"
14
-
15
16
jobs :
16
17
coding-guidelines :
17
18
name : Coding Guidelines
18
19
19
20
runs-on : ubuntu-latest
21
+ timeout-minutes : 5
20
22
21
23
steps :
22
24
- 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
24
37
25
38
- name : Install PHP
26
39
uses : shivammathur/setup-php@v2
27
40
with :
28
- php-version : 8.3
41
+ php-version : ${{ env.PHP_VERSION }}
29
42
coverage : none
43
+ tools : none
30
44
31
45
- name : Run PHP-CS-Fixer
32
46
run : ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose
@@ -35,16 +49,29 @@ jobs:
35
49
name : Type Checker
36
50
37
51
runs-on : ubuntu-latest
52
+ timeout-minutes : 5
38
53
39
54
steps :
40
55
- 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
42
68
43
69
- name : Install PHP
44
70
uses : shivammathur/setup-php@v2
45
71
with :
46
72
php-version : 8.3
47
73
coverage : none
74
+ tools : none
48
75
49
76
- name : Install dependencies with Composer
50
77
run : ./tools/composer update --no-interaction --no-ansi --no-progress
@@ -56,35 +83,121 @@ jobs:
56
83
name : Tests
57
84
58
85
runs-on : ubuntu-latest
86
+ timeout-minutes : 5
59
87
60
88
strategy :
61
89
fail-fast : false
62
90
matrix :
63
91
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
69
98
70
99
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"
73
126
74
- - name : " Install PHP with extensions "
75
- uses : " shivammathur/setup-php@v2 "
127
+ - name : Cache Composer cache directory
128
+ uses : actions/cache@v4
76
129
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
80
136
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
83
139
84
- - name : " Run tests with PHPUnit "
85
- run : " vendor/bin/phpunit --coverage-clover=coverage.xml "
140
+ code-coverage :
141
+ name : Code Coverage
86
142
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