-
-
Notifications
You must be signed in to change notification settings - Fork 6
684 lines (529 loc) · 20.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
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
name: 🚀 Test & Build
on:
push:
branches: [ "master" ]
jobs:
run-smoke-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
extensions: fileinfo
- uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: composer validate --strict --no-check-all
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
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 --stop-on-failure --log-junit report.xml
env:
ENV: testing
- name: Ping continuous integration server with test status
if: always() && github.event.repository.full_name == 'hydephp/develop'
run: |
bearerToken="${{ secrets.CI_SERVER_TOKEN }}"
commit="${{ github.sha }}"
url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [ ${{ steps.smoke-tests.outcome }} == "failure" ]; then
status=false
else
status=true
fi
curl -X POST --fail-with-body \
-H "Authorization: Bearer $bearerToken" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"commit":"'"$commit"'", "status":'$status', "url":"'"$url"'"}' \
https://ci.hydephp.com/api/test-run-reports
- 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 Smoke Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}
test-matrix:
needs: run-smoke-tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: [8.1, 8.2, 8.3]
runs-on: ${{ matrix.os }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, zip
- uses: actions/checkout@v4
- 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@v4
- 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@v4
- name: Setup Node.js
uses: actions/setup-node@v4
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@v4
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@v4
- name: Setup Node.js
uses: actions/setup-node@v4
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@v4
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
push: '--set-upstream origin compile-tailwindcss --force'
# 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@v2
with:
php-version: "8.1"
coverage: xdebug
extensions: fileinfo
- uses: actions/checkout@v4
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
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@v5
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@v4
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@v4
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@v4
- 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@v4
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@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
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: Copy configuration from configuration directory
run: cp -r monorepo/gh-pages/gh-pages-config-dev-docs/* .
- 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@v4
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@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
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: Copy configuration from the configuration directory
run: cp -r monorepo/gh-pages/gh-pages-config/* .
- 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@v4
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@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
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@v4
with:
name: 'test-fixture-docs'
path: '_site'
build-git-history-graph:
runs-on: ubuntu-latest
needs: run-smoke-tests
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all history to generate the graph
fetch-depth: 0
- name: Generate Git history graph
run: php monorepo/scripts/build-git-history-graph.php
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: 'git-history-graph'
path: 'monorepo/scripts/graphs'
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
- build-git-history-graph
steps:
- uses: actions/checkout@v4
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
rm -rf master/git && mkdir master/git
- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: html-coverage
path: master/coverage
- name: Download upcoming documentation artifact
uses: actions/download-artifact@v4
with:
name: dev-docs
path: master/dev-docs
- name: Download API documentation artifact
uses: actions/download-artifact@v4
with:
name: api-documentation
path: master/api-docs
- name: Download preview site artifact
uses: actions/download-artifact@v4
with:
name: site-preview
path: master/preview
- name: Download test fixture docs artifact
uses: actions/download-artifact@v4
with:
name: test-fixture-docs
path: master/test-fixtures/docs
- name: Download Git history graph artifact
uses: actions/download-artifact@v4
with:
name: git-history-graph
path: master/git
- name: Create README.md
run: echo '# CI/CD generated reports for [${{ github.sha }}](https://github.com/hydephp/develop/commit/${{ github.sha }})' > master/README.md
# Generate directory listing
- name: Download directory listing generator script
run: wget https://raw.githubusercontent.com/caendesilva/php-directory-listing/a741e74af1a3e5b8d8b730a437c1666945fbedab/directory-listing.php -O .build.php
- name: Check download integrity
run: |
hash=$(sha256sum .build.php | awk '{print $1}')
if [ $hash = "af021b1bef61e31f426dcbc80540aa192e5a7cecf0db4f6b946851ab3101627d" ] ; then echo "Checksum $hash matches"; else echo "Checksum $hash not matching!" && exit 1 ; fi
- name: Set path labels
run: |
echo "hydephp/develop" > .dl-pathlabel
echo "hydephp/develop/master" > master/.dl-pathlabel
- name: Compile static root directory listing
run: php .build.php
- name: Compile static master directory listing
run: cp .build.php master/.build.php && cd master && php .build.php
- name: Compile subdirectory listings
run: |
cd master
for dir in media test-fixtures git; do
cp .build.php $dir/.build.php
cd $dir
php .build.php
cd ..
done
# End directory listing
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
pull: 'origin gh-pages'
add: '["master", "index.html"]'
message: 'Upload live reports from test suite run ${{ github.sha }}'
check-coding-standards:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- uses: actions/checkout@v4
- name: Download static analysis tools
run: |
wget https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
- name: Check syntax (PHP Parallel Lint)
run: php parallel-lint.phar --colors app config packages tests --show-deprecated
- name: Check coding syntax/standards (PHP CodeSniffer)
run: php phpcs.phar --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@v2
with:
php-version: "8.1"
- uses: actions/checkout@v4
- 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 > psalmout.txt|| 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 ${{ github.run_id }}
run-static-analysis-phpstan:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- uses: actions/checkout@v4
- 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@v4
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
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@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
snyk-security:
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@v3
with:
sarif_file: snyk.sarif
hydefront-lint:
name: HydeFront Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run linter
run: php packages/hydefront/.github/scripts/post-build.php
test-monorepo-tools:
runs-on: ubuntu-latest
name: Test monorepo tools can run
steps:
- uses: actions/checkout@v4
- run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- run: php monorepo/CodeIntelligence/CodeIntelligence.php
- run: php monorepo/scripts/FileFormatter.php