-
-
Notifications
You must be signed in to change notification settings - Fork 6
599 lines (459 loc) · 17.4 KB
/
continuous-integration.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
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
name: 🚀 Test & Build
on:
push:
branches: [ "master" ]
jobs:
run-smoke-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
extensions: fileinfo
- uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Set environment to testing
run: echo "ENV=testing" > .env
- name: Output debug information
run: php hyde debug
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/pest
env:
ENV: testing
test-matrix:
needs: run-smoke-tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: [8.1]
runs-on: ${{ matrix.os }}
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, zip
- uses: actions/checkout@v3
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/pest --log-junit report.xml
- name: Ping statistics server with test results
run: |
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php
php ping.php "Monorepo CI Matrix" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
system-testing:
strategy:
fail-fast: false
matrix:
script: [ hyde-cli, project-styles ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run system tests (${{ matrix.script }})
run: php monorepo/scripts/tests/${{ matrix.script }}.php
build-hydefront-assets:
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: 'npm'
- name: Install Node.js dependencies
working-directory: 'packages/hydefront'
run: npm ci
- name: Build assets for production
working-directory: 'packages/hydefront'
run: npm run prod
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'hydefront'
path: 'packages/hydefront/dist'
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add: 'packages/hydefront/dist'
message: 'Compile HydeFront assets for production'
new_branch: compile-hydefront
build-tailwindcss:
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Update Tailwind content path
run: sed -i 's/\.\/vendor\/hyde\/framework\/resources\/views\/\*\*\/\*\.blade\.php/\.\/packages\/framework\/resources\/views\/\*\*\/\*\.blade\.php/' tailwind.config.js
- name: Build assets for production
run: npm run prod
- name: Copy compiled app.css file to HydeFront dist folder
run: cp _media/app.css packages/hydefront/dist/app.css
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: '_media'
path: '_media'
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add: '["_media/app.css", "packages/hydefront/dist/app.css"]'
message: 'Compile TailwindCSS for production'
new_branch: compile-tailwindcss
# Todo create PR or just push to master?
build-test-coverage:
environment:
name: live-coverage-report
url: https://hydephp.github.io/develop/master/coverage/
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
coverage: xdebug
extensions: fileinfo
- uses: actions/checkout@v3
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Set environment to testing
run: echo "ENV=testing" > .env
- name: Output debug information
run: php hyde debug
- name: Execute tests (Unit and Feature tests) via PHPUnit with coverage
run: vendor/bin/pest --coverage --coverage-text=build/coverage/report.txt --colors=always --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml --coverage-html build/coverage/html
env:
ENV: testing
- uses: codecov/codecov-action@v2
with:
files: ./build/coverage/clover.xml,./build/coverage/crap4j.xml,./build/coverage/report.txt,./build/junit.xml
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
- name: Ping statistics server with test results
run: |
cp build/junit.xml report.xml
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php
php ping.php "Monorepo PR Test" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
- name: Upload coverage artifacts
uses: actions/upload-artifact@v1
with:
name: "coverage"
path: "build/coverage"
- name: Copy Junit report
run: cp build/junit.xml build/coverage/html/junit.xml
- name: Upload HTML coverage artifact
uses: actions/upload-artifact@v1
with:
name: "html-coverage"
path: "build/coverage/html"
build-api-documentation:
environment:
name: internal-api-docs
url: https://hydephp.github.io/develop/master/api-docs/
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- name: Download phpDocumentor
run: |
wget https://phpdoc.org/phpDocumentor.phar
chmod +x phpDocumentor.phar
- name: Run phpDocumentor
run: php phpDocumentor.phar --directory="packages/framework/src" --target="build/api-documentation" --title="API Documentation"
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'api-documentation'
path: 'build/api-documentation'
build-upcoming-documentation:
environment:
name: dev-docs
url: https://hydephp.github.io/develop/master/dev-docs/
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Download configuration
run: wget https://api.github.com/repos/hydephp/develop/zipball/gh-pages-config-dev-docs -O config.zip
- name: Unzip configuration
run: unzip config.zip -d temp
- name: Copy configuration to root
run: cp -r temp/hydephp-develop-*/* .
- name: Move documentation files
run: rm -rf _docs && mv -f docs _docs
- name: Compile the static site
run: php hyde build
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'dev-docs'
path: '_site/dev-docs'
build-preview-site:
environment:
name: live-preview-site
url: https://hydephp.github.io/develop/master/preview
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Download configuration
run: wget https://api.github.com/repos/hydephp/develop/zipball/gh-pages-config -O config.zip
- name: Unzip configuration
run: unzip config.zip -d temp
- name: Copy configuration to root
run: cp -r temp/hydephp-develop-*/* .
- name: Output the origin reference to file
run: echo ${{ github.sha }} > origin-ref
- name: Publish the post feed homepage
run: php hyde publish:homepage posts -n
- name: Compile the static site
run: php hyde build
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'site-preview'
path: '_site'
build-test-fixture-docs:
# environment:
# name:
# url: https://hydephp.github.io/develop/master/test-fixtures/docs
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Download source files
run: wget https://github.com/caendesilva/hyde-example-documentation-site/archive/master.zip -O source.zip
- name: Unzip source
run: unzip source.zip -d temp
- name: Copy source to root
run: cp -r temp/hyde-example-documentation-site-master/* .
- name: Compile the static site
run: php hyde build
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'test-fixture-docs'
path: '_site'
upload-generated-reports:
environment:
name: live-reports
url: https://hydephp.github.io/develop/master/
runs-on: ubuntu-latest
needs:
- run-smoke-tests
- build-test-coverage
- build-api-documentation
- build-upcoming-documentation
- build-preview-site
- build-test-fixture-docs
steps:
- uses: actions/checkout@v3
with:
ref: 'gh-pages'
- name: Reset output directories
run: |
rm -rf master/coverage && mkdir master/coverage
rm -rf master/dev-docs && mkdir master/dev-docs
rm -rf master/api-docs && mkdir master/api-docs
rm -rf master/preview && mkdir master/preview
rm -rf master/test-fixtures && mkdir master/test-fixtures
- name: Download coverage report artifact
uses: actions/download-artifact@v3
with:
name: html-coverage
path: master/coverage
- name: Download upcoming documentation artifact
uses: actions/download-artifact@v3
with:
name: dev-docs
path: master/dev-docs
- name: Download API documentation artifact
uses: actions/download-artifact@v3
with:
name: api-documentation
path: master/api-docs
- name: Download preview site artifact
uses: actions/download-artifact@v3
with:
name: site-preview
path: master/preview
- name: Download test fixture docs artifact
uses: actions/download-artifact@v3
with:
name: test-fixture-docs
path: master/test-fixtures/docs
- name: Create README.md
run: echo '# CI/CD generated reports for [${{ github.sha }}](https://github.com/hydephp/develop/commit/${{ github.sha }})' > master/README.md
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
pull: 'origin gh-pages'
add: 'master'
message: 'Upload live reports from test suite run ${{ github.sha }}'
check-coding-standards:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- uses: actions/checkout@v3
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Check syntax (PHP Parallel Lint)
run: vendor/bin/parallel-lint --colors app config packages tests --show-deprecated
- name: Check coding syntax/standards (PHP CodeSniffer)
run: vendor/bin/phpcs --colors --cache=build/cache/phpcs.cache packages --standard=PSR2 --extensions="php" --ignore="*test.php,*.blade.php,ValidationService.php" || true
run-static-analysis-psalm:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- uses: actions/checkout@v3
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run static analysis (Psalm/Shepherd)
run: vendor/bin/psalm --shepherd || true
- name: Ping CI server with type coverage results
run: php monorepo/scripts/ping-ci-server-with-type-coverage.php ${{ secrets.CI_SERVER_TOKEN }} ${{ github.sha }} master
run-static-analysis-phpstan:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d
with:
php-version: "8.1"
- uses: actions/checkout@v3
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run static analysis (PHPStan)
run: vendor/bin/phpstan analyse --ansi --level 1 packages/framework/src || true
devskim-lint:
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: devskim-results.sarif
analyze:
name: Analyze
runs-on: ubuntu-latest
needs: run-smoke-tests
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
snyk-security:
if: false # Temporarily disabled due to unknown downstream error
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/php@master
continue-on-error: true # To make sure that SARIF upload gets called
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --sarif-file-output=snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif
hydefront-lint:
name: HydeFront Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run linter
run: php packages/hydefront/.github/scripts/post-build.php