-
-
Notifications
You must be signed in to change notification settings - Fork 38
237 lines (206 loc) · 7.56 KB
/
tests.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: Laravel WebAuthn workflow
on:
push:
branches:
- main
- next
- next-major
- beta
- alpha
pull_request:
types: [opened, synchronize, reopened]
release:
types:
- created
workflow_dispatch:
env:
default-php-version: '8.3'
default-laravel-version: '11.0'
semantic-node-version: 20
concurrency:
group: Tests ${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
name: PHP ${{ matrix.php-version }} | Laravel ${{ matrix.laravel-version }} (${{ matrix.psr7 }})
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3']
laravel-version: ['9.0', '10.0', '11.0']
psr7: ['guzzle']
include:
- php-version: '8.1'
laravel-version: '9.0'
psr7: 'nyholm'
- php-version: '8.1'
laravel-version: '9.0'
psr7: 'discovery'
- php-version: '8.2'
laravel-version: '10.0'
psr7: 'nyholm'
- php-version: '8.2'
laravel-version: '10.0'
psr7: 'discovery'
- php-version: '8.2'
laravel-version: '11.0'
psr7: 'nyholm'
- php-version: '8.2'
laravel-version: '11.0'
psr7: 'discovery'
- php-version: '8.3'
laravel-version: '11.0'
psr7: 'nyholm'
- php-version: '8.3'
laravel-version: '11.0'
psr7: 'discovery'
exclude:
- php-version: '8.1'
laravel-version: '11.0'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: sqlite3, gmp
ini-values: pcov.directory=., pcov.exclude="~vendor~"
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Validate composer.json
run: composer validate
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}-${{ matrix.laravel-version }}
restore-keys: |
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}-${{ matrix.laravel-version }}
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}-${{ matrix.php-version }}
${{ runner.os }}-composer-v4-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-v4-
- name: Update dependencies with Laravel ${{ matrix.laravel-version }}
run: |
export COMPOSER_ROOT_VERSION=dev-main
composer require "illuminate/support:^${{ matrix.laravel-version }}" --no-update
- name: Use psr7 variant (nyholm)
if: matrix.psr7 == 'nyholm'
run: |
composer remove psr/http-factory-implementation --no-update
composer remove --dev guzzlehttp/psr7 --no-update
composer require --dev symfony/psr-http-message-bridge nyholm/psr7 --no-update
- name: Use psr7 variant (with php-http/discovery)
if: matrix.psr7 == 'discovery'
run: |
composer remove psr/http-factory-implementation --no-update
composer remove --dev guzzlehttp/psr7 --no-update
composer require --dev symfony/psr-http-message-bridge php-http/discovery laminas/laminas-diactoros php-http/curl-client --no-update
- name: Install dependencies
run: |
composer update --no-interaction --no-progress --prefer-dist
- name: Set results artifact name
id: artifact
run: echo "name=${{ matrix.php-version }}_${{ matrix.laravel-version }}${{ matrix.psr7 }}" | sed -e "s/*//g" >> $GITHUB_OUTPUT
- name: Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run test suite
run: vendor/bin/phpunit -c phpunit.xml --log-junit ./results/results_${{ matrix.psr7 }}.xml --coverage-clover ./results/coverage_${{ matrix.psr7 }}.xml
- name: Fix results files
if: success() || failure()
run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" *.xml
working-directory: results
- name: Store results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: results_${{ steps.artifact.outputs.name }}
path: results
####################
# Sonarcloud
####################
reporting:
needs: tests
runs-on: ubuntu-latest
if: success() || failure()
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download results
uses: actions/download-artifact@v4
with:
pattern: ${{ format('results_{0}_{1}*', env.default-php-version, env.default-laravel-version) }}
path: results
merge-multiple: true
- name: Merge junit files
run: |
mkdir -p $RUNNER_TEMP/junit-merge
cd $RUNNER_TEMP/junit-merge
npm init -y
yarn set version berry
yarn dlx junit-merge --recursive --dir $GITHUB_WORKSPACE/results --out $GITHUB_WORKSPACE/results/results.xml
- name: Set coverage list
id: coverage
run: |
SONAR_COVERAGE=$(ls -m --format=comma results/coverage*.xml | sed -e ':a;N;$!ba;s/\n//g; s/ //g;')
echo "list=$SONAR_COVERAGE" >> $GITHUB_OUTPUT
- name: SonarCloud Scan
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarcloud-github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: |
-Dsonar.php.tests.reportPath=./results/results.xml
-Dsonar.php.coverage.reportPaths=${{ steps.coverage.outputs.list }}
####################
# Semantic release
####################
semantic-release:
needs: tests
runs-on: ubuntu-latest
name: Semantic release
if: github.event_name != 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all tags
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.semantic-node-version }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_RELEASE: ${{ secrets.GH_TOKEN_RELEASE }}
with:
semantic_version: 19
extra_plugins: |
@semantic-release/changelog@6
- name: New release published
if: steps.semantic.outputs.new_release_published == 'true'
run: echo ${{ steps.semantic.outputs.new_release_version }}
- name: Store changelog file
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md