-
Notifications
You must be signed in to change notification settings - Fork 3
259 lines (240 loc) · 8.97 KB
/
CI.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: 'CI'
on: # Build any PRs and main branch changes
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
pull_request:
types:
- opened
- edited
- synchronize
push:
branches: [ master ]
schedule:
- cron: '0 0 1 * *' # Every month
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
env:
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader
CODACY_CACHE_PATH: ~/.cache/codacy
CODACY_BIN: ~/.cache/codacy/codacy.sh
jobs:
tests:
name: UTs & FTs - PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
env:
COVERAGE_TYPE: none
COVERAGE_ARTIFACT_NAME: coverage-php${{ matrix.php-version }}
strategy:
fail-fast: true
max-parallel: 4
matrix:
include:
# Bare minimum => Lowest versions allowed by composer config
- php-version: '8.0'
composer-flag: --prefer-lowest
# Up-to-date versions => Latest versions allowed by composer config
- php-version: '8.2'
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Enable coverage
if: ${{ matrix.php-version == '8.2' }}
run: |
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
update: true # Always use latest available patch for the version
fail-fast: true # step will fail if an extension or tool fails to set up
with:
php-version: '${{ matrix.php-version }}'
tools: composer
coverage: ${{ env.COVERAGE_TYPE }}
- name: Setup cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.composer
./vendor
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
- name: Build
run: |
make build
- name: Tests
run: make test-unit && make test-functional
- name: Upload coverage as artifact
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.COVERAGE_ARTIFACT_NAME }}
path: "build/coverage-*"
if-no-files-found: error
- name: Upload matrix output
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: cloudposse/github-action-matrix-outputs-write@v1
id: out
with:
matrix-step-name: php-version-and-artifact
matrix-key: ${{ strategy.job-index }}
outputs: |-
version: ${{ matrix.php-version }}
artifact: ${{ env.COVERAGE_ARTIFACT_NAME }}
data: '{"version": "${{ matrix.php-version }}", "artifact": "${{ env.COVERAGE_ARTIFACT_NAME }}"}'
debug-output:
name: DEBUG
runs-on: ubuntu-latest
needs: [ tests ]
outputs:
matrix: ${{ steps.fetch-data.outputs.result }}
steps:
- uses: cloudposse/github-action-matrix-outputs-read@v1
id: fetch-data
with:
matrix-step-name: php-version-and-artifact
debug-output2:
name: DEBUG2
runs-on: ubuntu-latest
needs: [ debug-output ]
strategy:
matrix:
data: ${{ fromJson(needs.debug-output.outputs.matrix).data.* }}
steps:
- name: matrix.data
run: echo "${{ matrix.data }}"
- name: fromJson(matrix.data)
run: echo "${{ fromJson(matrix.data) }}"
- name: fromJson(matrix.data).version
run: echo "${{ fromJson(matrix.data).version }}"
debug-output2-2:
name: DEBUG2-2
runs-on: ubuntu-latest
needs: [ debug-output ]
strategy:
matrix:
version: ${{ fromJson(needs.debug-output.outputs.matrix).data.version.* }}
artifact: ${{ fromJson(needs.debug-output.outputs.matrix).data.artifact.* }}
steps:
- name: matrix.data
run: echo "${{ matrix.data }}"
- name: fromJson(matrix.data)
run: echo "${{ fromJson(matrix.data) }}"
- name: fromJson(matrix.data).version
run: echo "${{ fromJson(matrix.data).version }}"
debug-output2-3:
name: DEBUG2-3
runs-on: ubuntu-latest
needs: [ debug-output ]
strategy:
matrix: ${{ fromJson(needs.debug-output.outputs.matrix) }}
steps:
- name: matrix.data
run: echo "${{ matrix.data }}"
- name: fromJson(matrix.data)
run: echo "${{ fromJson(matrix.data) }}"
- name: fromJson(matrix.data).version
run: echo "${{ fromJson(matrix.data).version }}"
debug-output3:
name: DEBUG3
runs-on: ubuntu-latest
needs: [ debug-output ]
steps:
- name: needs.debug-output.outputs
run: echo "${{ needs.debug-output.outputs }}"
- name: toJson(needs.debug-output.outputs)
run: echo "${{ toJson(needs.debug-output.outputs) }}"
- name: needs.debug-output.outputs.matrix
run: echo "${{ needs.debug-output.outputs.matrix }}"
- name: toJson(needs.debug-output.outputs.matrix)
run: echo "${{ toJson(needs.debug-output.outputs.matrix) }}"
- name: fromJson(needs.debug-output.outputs.matrix)
run: echo "${{ fromJson(needs.debug-output.outputs.matrix) }}"
- name: fromJson(needs.debug-output.outputs.matrix).data
run: echo "${{ fromJson(needs.debug-output.outputs.matrix) }}"
- name: fromJson(needs.debug-output.outputs.matrix).data.*
run: echo "${{ fromJson(needs.debug-output.outputs.matrix).* }}"
- name: toJson(needs.debug-output.outputs.matrix.*)
run: echo "${{ toJson(needs.debug-output.outputs.matrix.*) }}"
- name: toJson(needs.debug-output.outputs.matrix).*
run: echo "${{ toJson(needs.debug-output.outputs.matrix).* }}"
- name: needs.debug-output.outputs.matrix.data
run: echo "${{ needs.debug-output.outputs.matrix.data }}"
- name: toJson(needs.debug-output.outputs.matrix).data
run: echo "${{ toJson(needs.debug-output.outputs.matrix).data }}"
- name: toJson(needs.debug-output.outputs.matrix.data.*)
run: echo "${{ toJson(needs.debug-output.outputs.matrix.data.*) }}"
- name: toJson(needs.debug-output.outputs.matrix).data.*
run: echo "${{ toJson(needs.debug-output.outputs.matrix).data.* }}"
# - uses: actions/download-artifact@v4
# with:
# pattern: coverage-php*
# path: coverage-data
#
# - run: ls -ail coverage-data
# codecov-coverage-report:
# name: Codecov coverage report
# runs-on: ubuntu-latest
# environment: ci-codecov
# needs: [tests]
# strategy:
# fail-fast: true
# max-parallel: 4
# matrix:
# include: ${{ needs.tests.outputs.*.matrix }}
# steps:
# - name: Download PHP ${{ matrix.php-version }} coverage artifact
# uses: actions/download-artifact@v4
# with:
# name: ${{ matrix.artifact }}
# path: coverage-data
#
# - name: DEBUG
# run: ls -ail coverage-data
#
# # See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-server-sdk
# - name: Upload unit tests coverage to codecov
# uses: codecov/codecov-action@v3
# with:
# files: "coverage-data/coverage-phpunit/unit.clover"
# name: "unit-tests-${{ matrix.php-version }}"
# flags: "unit-tests,php-${{ matrix.php-version }}"
# fail_ci_if_error: true
# token: ${{ secrets.ENV_CODECOV_TOKEN }}
# verbose: ${{ runner.debug == '1' }}
#
# - name: Upload functional tests coverage to codecov
# if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
# uses: codecov/codecov-action@v4
# with:
# files: "coverage-data/coverage-behat/clover.xml,coverage-data/coverage-phpunit/functional.clover"
# name: "functional-tests-${{ matrix.php-version }}"
# flags: "functional-tests,php-${{ matrix.php-version }}"
# token: ${{ secrets.ENV_CODECOV_TOKEN }}
# verbose: ${{ runner.debug == '1' }}
# codacy-coverage-report:
# name: Codacy coverage report
# runs-on: ubuntu-latest
# environment: ci-codacy
# needs: [ tests ]
# steps:
# - name: Download all PHP coverage artifacts
# uses: actions/download-artifact@v4
# with:
# pattern: coverage-php*
# path: coverage-data
#
# - name: DEBUG
# run: ls -ail coverage-data
#
# - name: Find available files
# run: |
# ls -ail coverage-data/*/coverage-phpunit/unit.clover coverage-data/*/coverage-behat/clover.xml coverage-data/*/coverage-phpunit/functional.clover
#
# - name: Run codacy-coverage-reporter
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.ENV_CODACY_PROJECT_TOKEN }}
# coverage-reports: coverage-data/*/coverage-phpunit/unit.clover,coverage-data/*/coverage-behat/clover.xml,coverage-data/*/coverage-phpunit/functional.clover