-
Notifications
You must be signed in to change notification settings - Fork 123
304 lines (251 loc) · 9.45 KB
/
build.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
# SPDX-License-Identifier: Apache-2.0
name: PR Checks
on:
push:
branches:
- main
- develop
- release/*
pull_request:
branches:
- main
- develop
- release/*
defaults:
run:
shell: bash
permissions:
contents: read
packages: write
env:
LC_ALL: C.UTF-8
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
CG_EXEC: ionice -c 2 -n 2 nice -n 19
jobs:
build:
name: Build
runs-on: hiero-client-sdk-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: "0"
- name: Setup NodeJS
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 18
- name: Setup Java
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version: "17.0.13"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: false
- name: Build SDK & Javadoc
id: gradle-build
run: ./gradlew assemble
- name: Setup Snyk
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
if: >-
${{
steps.gradle-build.conclusion == 'success' &&
(
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name == 'push'
) &&
!cancelled()
}}
run: ${CG_EXEC} npm install -g snyk snyk-to-html @wcj/html-to-markdown-cli
- name: Snyk Scan
id: snyk
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
if: >-
${{
steps.gradle-build.conclusion == 'success' &&
(
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name == 'push'
) &&
!cancelled()
}}
run: ${CG_EXEC} snyk test --all-projects --severity-threshold=high --policy-path=.snyk --json-file-output=snyk-test.json --org=hiero-client-sdks
- name: Snyk Code
id: snyk-code
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
if: >-
${{
steps.gradle-build.conclusion == 'success' &&
(
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name == 'push'
) &&
!cancelled()
}}
run: ${CG_EXEC} snyk code test --severity-threshold=high --json-file-output=snyk-code.json --org=hiero-client-sdks --policy-path=.snyk
- name: Publish Snyk Results
if: >-
${{
steps.gradle-build.conclusion == 'success' &&
(
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name == 'push'
) &&
!cancelled()
}}
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
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::"
test:
name: Unit and Integration Tests
runs-on: hiero-client-sdk-linux-medium
needs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup NodeJS
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 18
- name: Setup Java
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version: "17.0.13"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
- name: Install Local Node
run: npm install @hashgraph/hedera-local
- name: Build SDK
run: ./gradlew assemble
- name: Code Quality Checks
run: ./gradlew qualityCheck :examples:qualityCheck --continue --rerun-tasks
- name: Start Local Node
run: npx @hashgraph/hedera-local start -d --network local --network-tag=0.57.0
- name: Run Unit and Integration Tests
env:
OPERATOR_KEY: "0xa608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4"
OPERATOR_ID: "0.0.1022"
HEDERA_NETWORK: "localhost"
run: |
./gradlew -POPERATOR_ID=$OPERATOR_ID -POPERATOR_KEY=$OPERATOR_KEY -PHEDERA_NETWORK=$HEDERA_NETWORK :aggregation:testCodeCoverageReport
- name: Upload coverage to Codecov
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
with:
files: gradle/aggregation/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
- name: Stop the local node
run: npx @hashgraph/hedera-local stop
run-examples:
name: Run Examples
runs-on: hiero-client-sdk-linux-medium
needs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup NodeJS
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 18
- name: Setup Java
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version: "17.0.13"
- name: Setup Android SDK
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
- name: Install Local Node
run: npm install @hashgraph/hedera-local
- name: Build SDK
run: ./gradlew assemble
- name: Build Android Example
run: ./gradlew -p example-android assemble
- name: Start the local node
run: npx @hashgraph/hedera-local start -d --network local --network-tag=0.57.0
- name: Prepare .env for Examples
run: |
echo "OPERATOR_KEY=0xa608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4" > examples/.env
echo "OPERATOR_ID=0.0.1022" >> examples/.env
echo "HEDERA_NETWORK=localhost" >> examples/.env
- name: Run Examples
run: ./gradlew :examples:runAllExamples
- name: Stop the local node
run: npx @hashgraph/hedera-local stop
test-tck:
name: TCK Tests
runs-on: hiero-client-sdk-linux-medium
needs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup NodeJS
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 18
- name: Setup Java
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version: "17.0.13"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
- name: Install Local Node
run: npm install @hashgraph/hedera-local
- name: Build TCK
run: ./gradlew assemble
- name: Start Local Node
run: npx @hashgraph/hedera-local start -d --network local
- name: Run TCK Unit Tests
run: ./gradlew :tck:test
- name: Stop the local node
run: npx @hashgraph/hedera-local stop