-
Notifications
You must be signed in to change notification settings - Fork 10
467 lines (432 loc) · 20.4 KB
/
zxc-code-analysis.yaml
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
##
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
name: "ZXC: Code Analysis"
# The purpose of this reusable workflow is to perform static code analysis and code coverage reporting.
# This reusable component is called by the following workflows:
# - .github/workflows/flow-pull-request-checks.yaml
# - .github/workflows/flow-build-application.yaml
#
# This workflow is only run if the pull request is coming from the original repository and not a fork.
on:
workflow_call:
inputs:
enable-codecov-analysis:
description: "CodeCov Analysis Enabled"
type: boolean
required: false
default: false
enable-codacy-coverage:
description: "Codacy Coverage Enabled"
type: boolean
required: false
default: false
enable-e2e-coverage-report:
description: "E2E Coverage Report Enabled"
type: boolean
required: false
default: false
enable-snyk-scan:
description: "Snyk Scan Enabled"
type: boolean
required: false
default: false
node-version:
description: "NodeJS Version:"
type: string
required: false
default: "20"
custom-job-label:
description: "Custom Job Label:"
type: string
required: false
default: "Analyze"
e2e-integration-test-subdir:
description: "E2E Integration Test Subdirectory:"
type: string
required: false
default: "e2e-integration"
e2e-standard-test-subdir:
description: "E2E Standard Test Subdirectory:"
type: string
required: false
default: "e2e-standard"
e2e-mirror-node-test-subdir:
description: "E2E Mirror Node Test Subdirectory:"
type: string
required: false
default: "e2e-mirror-node"
e2e-node-pem-stop-test-subdir:
description: "E2E Node PEM Stop Test Subdirectory:"
type: string
required: false
default: "e2e-node-pem-stop"
e2e-node-pem-kill-test-subdir:
description: "E2E Node PEM Kill Test Subdirectory:"
type: string
required: false
default: "e2e-node-pem-kill"
e2e-node-local-hedera-test-subdir:
description: "E2E Node Local Hedera Test Subdirectory:"
type: string
required: false
default: "e2e-node-local-hedera"
e2e-node-local-ptt-test-subdir:
description: "E2E Node Local PTT Test Subdirectory:"
type: string
required: false
default: "e2e-node-local-ptt"
e2e-node-add-test-subdir:
description: "E2E Node Add Test Subdirectory:"
type: string
required: false
default: "e2e-node-add"
e2e-node-add-local-test-subdir:
description: "E2E Node Add Local Test Subdirectory:"
type: string
required: false
default: "e2e-node-add-local"
e2e-node-add-separate-commands-test-subdir:
description: "E2E Node Add - Separate commands Test Subdirectory:"
type: string
required: false
default: "e2e-node-add-separate-commands"
e2e-node-update-test-subdir:
description: "E2E Node Update Test Subdirectory:"
type: string
required: false
default: "e2e-node-update"
e2e-node-update-separate-commands-test-subdir:
description: "E2E Node Update - Separate commands Test Subdirectory:"
type: string
required: false
default: "e2e-node-update-separate-commands"
e2e-node-delete-test-subdir:
description: "E2E Node Delete Test Subdirectory:"
type: string
required: false
default: "e2e-node-delete"
e2e-node-delete-separate-commands-test-subdir:
description: "E2E Node Delete - Separate commands Test Subdirectory:"
type: string
required: false
default: "e2e-node-delete-separate-commands"
e2e-node-upgrade-test-subdir:
description: "E2E Node Upgrade Test Subdirectory:"
type: string
required: false
default: "e2e-node-upgrade"
e2e-relay-test-subdir:
description: "E2E Relay Test Subdirectory:"
type: string
required: false
default: "e2e-relay"
e2e-integration-coverage-report:
description: "E2E Integration Coverage Report:"
type: string
required: false
default: "E2E Integration Tests Coverage Report"
e2e-standard-coverage-report:
description: "E2E Standard Coverage Report:"
type: string
required: false
default: "E2E Standard Tests Coverage Report"
e2e-mirror-node-coverage-report:
description: "E2E Mirror Node Coverage Report:"
type: string
required: false
default: "E2E Mirror Node Tests Coverage Report"
e2e-node-pem-stop-coverage-report:
description: "E2E Node PEM Stop Coverage Report:"
type: string
required: false
default: "E2E Node PEM Stop Tests Coverage Report"
e2e-node-pem-kill-coverage-report:
description: "E2E Node PEM Kill Coverage Report:"
type: string
required: false
default: "E2E Node PEM Kill Tests Coverage Report"
e2e-node-local-hedera-coverage-report:
description: "E2E Node Local Hedera Coverage Report:"
type: string
required: false
default: "E2E Node Local Hedera Tests Coverage Report"
e2e-node-local-ptt-coverage-report:
description: "E2E Node Local PTT Coverage Report:"
type: string
required: false
default: "E2E Node Local PTT Tests Coverage Report"
e2e-node-add-coverage-report:
description: "E2E Node Add Coverage Report:"
type: string
required: false
default: "E2E Node Add Tests Coverage Report"
e2e-node-add-local-coverage-report:
description: "E2E Node Add Local Coverage Report:"
type: string
required: false
default: "E2E Node Add Local Tests Coverage Report"
e2e-node-add-separate-commands-coverage-report:
description: "E2E Node Add - Separate commands Coverage Report:"
type: string
required: false
default: "E2E Node Add - Separate commands Tests Coverage Report"
e2e-node-update-coverage-report:
description: "E2E Node Update Coverage Report:"
type: string
required: false
default: "E2E Node Update Tests Coverage Report"
e2e-node-update-separate-commands-coverage-report:
description: "E2E Node Update - Separate commands Coverage Report:"
type: string
required: false
default: "E2E Node Update - Separate commands Tests Coverage Report"
e2e-node-delete-coverage-report:
description: "E2E Node Delete Coverage Report:"
type: string
required: false
default: "E2E Node Delete Tests Coverage Report"
e2e-node-delete-separate-commands-coverage-report:
description: "E2E Node Delete - Separate commands Coverage Report:"
type: string
required: false
default: "E2E Node Delete - Separate commands Tests Coverage Report"
e2e-node-upgrade-coverage-report:
description: "E2E Node Upgrade Coverage Report:"
type: string
required: false
default: "E2E Node Upgrade Tests Coverage Report"
e2e-relay-coverage-report:
description: "E2E Relay Coverage Report:"
type: string
required: false
default: "E2E Relay Tests Coverage Report"
secrets:
snyk-token:
description: "The Snyk access token is used by Snyk to analyze the code for vulnerabilities "
required: false
codecov-token:
description: "The CodeCov access token is used by CodeCov.io to analyze the code coverage "
required: false
codacy-project-token:
description: "The Codacy project token used to report code coverage."
required: false
defaults:
run:
shell: bash
permissions:
contents: read
actions: read
pull-requests: write
checks: write
statuses: write
jobs:
analyze:
name: ${{ inputs.custom-job-label || 'Analyze' }}
runs-on: solo-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: ${{ inputs.enable-sonar-analysis && '0' || '' }}
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ inputs.node-version }}
- name: Download Unit Test Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && !cancelled() && !failure() }}
with:
name: Unit Test Coverage Report
path: 'coverage/unit'
- name: Download E2E Integration Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-integration-coverage-report }}
path: 'coverage/${{ inputs.e2e-integration-test-subdir }}'
- name: Download E2E Standard Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-standard-coverage-report }}
path: 'coverage/${{ inputs.e2e-standard-test-subdir }}'
- name: Download E2E Mirror Node Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-mirror-node-coverage-report }}
path: 'coverage/${{ inputs.e2e-mirror-node-test-subdir }}'
- name: Download E2E Node PEM Stop Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-pem-stop-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-pem-stop-test-subdir }}'
- name: Download E2E Node PEM Kill Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-pem-kill-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-pem-kill-test-subdir }}'
- name: Download E2E Node Local Hedera Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-local-hedera-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-local-hedera-test-subdir }}'
- name: Download E2E Node Local PTT Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-local-ptt-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-local-ptt-test-subdir }}'
- name: Download E2E Node Add Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-add-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-add-test-subdir }}'
- name: Download E2E Node Add Local Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-add-local-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-add-local-test-subdir }}'
- name: Download E2E Node Add - Separate commands Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-add-separate-commands-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-add-separate-commands-test-subdir }}'
- name: Download E2E Node Update Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-update-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-update-test-subdir }}'
- name: Download E2E Node Update - Separate commands Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-update-separate-commands-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-update-separate-commands-test-subdir }}'
- name: Download E2E Node Delete Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-delete-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-delete-test-subdir }}'
- name: Download E2E Node Delete - Separate commands Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-delete-separate-commands-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-delete-separate-commands-test-subdir }}'
- name: Download E2E Node Upgrade Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-node-upgrade-coverage-report }}
path: 'coverage/${{ inputs.e2e-node-upgrade-test-subdir }}'
- name: Download E2E Relay Coverage Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
name: ${{ inputs.e2e-relay-coverage-report }}
path: 'coverage/${{ inputs.e2e-relay-test-subdir }}'
- name: Download E2E Test Report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
pattern: "e2e_test_report_*"
path: "e2e_test_report"
- name: Publish E2E Test Report
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }}
with:
check_name: "E2E Test Report"
files: "e2e_test_report/**/*.xml"
- name: Publish To Codecov
uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
if: ${{ inputs.enable-codecov-analysis && !cancelled() && !failure() }}
env:
CODECOV_TOKEN: ${{ secrets.codecov-token }}
with:
verbose: true
directory: 'coverage'
- name: Publish to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.codacy-project-token }}
if: ${{ inputs.enable-codacy-coverage && !cancelled() && !failure() }}
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Javascript $(find . -name 'lcov.info' -printf '-r %p ')
- name: Setup Snyk
env:
SNYK_TOKEN: ${{ secrets.snyk-token }}
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
run: npm install -g snyk snyk-to-html @wcj/html-to-markdown-cli
- name: Snyk Scan
id: snyk
env:
SNYK_TOKEN: ${{ secrets.snyk-token }}
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
run: snyk test --org=release-engineering-N6EoZVZn3jw4qNuVkiG5Qs --all-projects --severity-threshold=high --json-file-output=snyk-test.json
- name: Snyk Code
id: snyk-code
env:
SNYK_TOKEN: ${{ secrets.snyk-token }}
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
run: snyk code test --org=release-engineering-N6EoZVZn3jw4qNuVkiG5Qs --severity-threshold=high --json-file-output=snyk-code.json
- name: Publish Snyk Results
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
run: |
if [[ -f "snyk-test.json" && -n "$(cat snyk-test.json | tr -d '[:space:]')" ]]; then
snyk-to-html -i snyk-test.json -o snyk-test.html --summary
html-to-markdown snyk-test.html -o snyk
cat snyk/snyk-test.html.md >> $GITHUB_STEP_SUMMARY
fi
- name: Publish Snyk Code Results
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
run: |
if [[ -f "snyk-code.json" && -n "$(cat snyk-code.json | tr -d '[:space:]')" ]]; then
snyk-to-html -i snyk-code.json -o snyk-code.html --summary
html-to-markdown snyk-code.html -o snyk
cat snyk/snyk-code.html.md >> $GITHUB_STEP_SUMMARY
fi
- name: Check Snyk Files
if: ${{ always() }}
run: |
echo "::group::Snyk File List"
ls -lah snyk* || true
echo "::endgroup::"
echo "::group::Snyk Test Contents"
cat snyk-test.json || true
echo "::endgroup::"
echo "::group::Snyk Code Contents"
cat snyk-code.json || true
echo "::endgroup::"
- name: Publish Snyk Reports
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }}
with:
name: Snyk Reports
path: |
snyk-*.html
snyk-*.json