-
-
Notifications
You must be signed in to change notification settings - Fork 452
340 lines (287 loc) · 11.5 KB
/
secure-tests.yml
File metadata and controls
340 lines (287 loc) · 11.5 KB
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: Secure Tests
on:
workflow_run:
workflows: ["CI"]
types: [completed]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: true
jobs:
dependency-validation:
name: Dependency Validation
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_repository.full_name == github.repository) }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
coverage: none
tools: composer
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer.json
run: composer validate --strict
- name: Ensure dependencies can be installed
run: composer install --no-interaction --no-progress --ansi --dry-run --ignore-platform-req=ext-grpc
integration-tests:
name: Integration Tests
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
env:
php-version: '8.5'
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php-version }}
tools: composer, pecl
coverage: xdebug
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run Integration Tests
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
TEST_FIREBASE_APP_ID: ${{secrets.TEST_FIREBASE_APP_ID}}
TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
TEST_FIREBASE_TENANT_ID: ${{secrets.TEST_FIREBASE_TENANT_ID}}
TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
XDEBUG_MODE: coverage
run: |
mkdir -p build
tools/phpunit --testsuite=integration --exclude-group grpc --coverage-clover=build/coverage.xml --log-junit=build/test-report.xml --testdox
- name: Upload integration test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration
report_type: test_results
files: ./build/test-report.xml
fail_ci_if_error: false
- name: Upload integration coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/coverage.xml
flags: integration
fail_ci_if_error: false
emulator-tests:
name: Emulator Tests
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
env:
php-version: '8.5'
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php-version }}
tools: composer, pecl
coverage: xdebug
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Get Composer cache directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Set Up Node
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Set Up Java
uses: actions/setup-java@v5.2.0
with:
distribution: 'temurin'
java-version: '21'
- name: Install Firebase Tools
run: npm install -g firebase-tools
- name: Run emulated Integration Tests
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
TEST_FIREBASE_APP_ID: ${{secrets.TEST_FIREBASE_APP_ID}}
TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
TEST_FIREBASE_TENANT_ID: ${{secrets.TEST_FIREBASE_TENANT_ID}}
TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
FIREBASE_DATABASE_EMULATOR_HOST: localhost:9100
FIREBASE_AUTH_EMULATOR_HOST: localhost:9099
XDEBUG_MODE: coverage
run: |
mkdir -p build
firebase emulators:exec --only auth,database --project beste-firebase 'XDEBUG_MODE=coverage tools/phpunit --group=emulator --exclude-group grpc --coverage-clover=build/coverage.xml --log-junit=build/test-report.xml'
- name: Upload emulator test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: emulator
report_type: test_results
files: ./build/test-report.xml
fail_ci_if_error: false
- name: Upload emulator coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/coverage.xml
flags: emulator
fail_ci_if_error: false
grpc-tests:
name: gRPC Tests (PHP 8.5)
needs:
- dependency-validation
runs-on: ubuntu-latest
timeout-minutes: 10
# Non-blocking while the gRPC extension is broken/unstable on PHP 8.5.
# See https://github.com/shivammathur/setup-php/issues/1041.
# Remove this once upstream releases a stable extension and tests pass.
continue-on-error: true
env:
key: cache-grpc
php-version: 8.5
extensions: grpc
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.php-version }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v5.0.3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php-version }}
extensions: ${{ env.extensions }}
ini-values: grpc.grpc_verbosity=error, grpc.grpc_trace=
tools: composer, pecl
coverage: xdebug
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Verify gRPC extension
id: grpc
run: php -m | grep -i '^grpc$'
- name: Get Composer cache directory
id: composer-cache
if: ${{ steps.grpc.outcome == 'success' }}
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer cache directory
if: ${{ steps.grpc.outcome == 'success' }}
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies with Composer
if: ${{ steps.grpc.outcome == 'success' }}
run: composer install --no-interaction --no-progress --ansi
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run gRPC Tests
id: grpc-tests
if: ${{ steps.grpc.outcome == 'success' }}
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
TEST_FIREBASE_APP_ID: ${{secrets.TEST_FIREBASE_APP_ID}}
TEST_FIREBASE_RTDB_URI: ${{secrets.TEST_FIREBASE_RTDB_URI}}
TEST_FIREBASE_TENANT_ID: ${{secrets.TEST_FIREBASE_TENANT_ID}}
TEST_REGISTRATION_TOKENS: ${{secrets.TEST_REGISTRATION_TOKENS}}
XDEBUG_MODE: coverage
run: |
mkdir -p build
tools/phpunit --testsuite=integration --group grpc --coverage-clover=build/coverage.xml --log-junit=build/test-report.xml --testdox
- name: Upload gRPC test results to Codecov
if: ${{ !cancelled() && steps.grpc.outcome == 'success' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: grpc
report_type: test_results
files: ./build/test-report.xml
fail_ci_if_error: false
- name: Upload gRPC coverage to Codecov
if: ${{ !cancelled() && steps.grpc.outcome == 'success' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/coverage.xml
flags: grpc
fail_ci_if_error: false
- name: Summarize gRPC failures
if: ${{ always() && (steps.grpc.outcome == 'failure' || steps.grpc-tests.outcome == 'failure') }}
run: |
echo "::notice::gRPC tests are non-blocking due to missing/broken gRPC on PHP 8.5."
{
echo "### gRPC tests are non-blocking"
echo
echo "gRPC extension was not available or gRPC tests failed (likely due to missing/broken gRPC on PHP 8.5)."
echo "See https://github.com/shivammathur/setup-php/issues/1041."
} >> "$GITHUB_STEP_SUMMARY"