-
Notifications
You must be signed in to change notification settings - Fork 2
276 lines (247 loc) · 11.7 KB
/
zxc-compile-code.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
##
# Copyright (C) 2023 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: Compile Code"
# The purpose of this reusable workflow is to compile the code and run the unit tests on every PR and commit.
# This reusable component is called by the following workflows:
# - .github/workflows/flow-pull-request-checks.yaml
# - .github/workflows/flow-build-application.yaml
on:
workflow_call:
inputs:
enable-unit-tests:
description: "Unit Testing Enabled"
type: boolean
required: false
default: false
enable-nodejs-tests:
description: "NodeJS Testing Enabled"
type: boolean
required: false
default: false
enable-spotless-check:
description: "Spotless Check Enabled"
type: boolean
required: false
default: false
java-distribution:
description: "Java JDK Distribution:"
type: string
required: false
default: "temurin"
java-version:
description: "Java JDK Version:"
type: string
required: false
default: "17.0.7"
gradle-version:
description: "Gradle Version:"
type: string
required: false
default: "wrapper"
node-version:
description: "NodeJS Version:"
type: string
required: false
default: "16"
custom-job-label:
description: "Custom Job Label:"
type: string
required: false
default: "Compiles"
defaults:
run:
shell: bash
permissions:
id-token: write
contents: read
actions: read
pull-requests: write
checks: write
statuses: write
jobs:
compile:
name: ${{ inputs.custom-job-label || 'Compiles' }}
runs-on: [self-hosted, Linux, medium, ephemeral]
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# the fetch depth defaults to only the commit that triggered the workflow unless the spotless check was enabled
fetch-depth: ${{ inputs.enable-spotless-check && '0' || '' }}
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
with:
gradle-version: ${{ inputs.gradle-version }}
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: ${{ inputs.node-version }}
- name: Setup Kind
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
config: dev/dev-cluster.yaml
version: v0.19.0
verbosity: 3
wait: 120s
- name: Setup Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
version: "v3.12.3" # helm version
run: |
helm repo add haproxytech https://haproxytech.github.io/helm-charts
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
# Technically, this step is not required for the unit tests to run, but it is useful for debugging setup issues.
- name: Kubernetes Cluster Info
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
run: |
kubectl config get-contexts
kubectl get crd
kubectl get node --show-labels
# This step is currently required because the Hedera Services artifacts are not publicly accessible.
# May be removed once the artifacts are publicly accessible.
- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
token_format: 'access_token'
workload_identity_provider: "projects/101730247931/locations/global/workloadIdentityPools/hedera-registry-pool/providers/hedera-registry-gh-actions"
service_account: "[email protected]"
# This step is currently required because the Hedera Services artifacts are not publicly accessible.
# May be removed once the artifacts are publicly accessible.
- name: Setup Google Cloud SDK
if: ${{ inputs.enable-unit-tests && !cancelled() }}
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: NodeJS CLI Tests
id: nodejs-test
working-directory: fullstack-network-manager
if: ${{ inputs.enable-nodejs-tests && !cancelled() && !failure() }}
run: |
npm i
npm test
# npm run test-e2e # tracked by #https://github.com/hashgraph/full-stack-testing/issues/501
# This step tests the Helm chart direct mode of operation which uses the ubi8-init-java17 image.
- name: Helm Chart Test (Direct Install)
working-directory: dev
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
run: make ci-test SCRIPT_NAME=direct-install.sh
# This step tests the Helm chart NMT mode of operation which uses the ubi8-init-dind image.
- name: Helm Chart Test (NMT Install)
working-directory: dev
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
run: make ci-test SCRIPT_NAME=nmt-install.sh
- name: Compile
id: gradle-build
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan
- name: Examples Compile
id: gradle-build-examples
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan
build-root-directory: fullstack-examples
- name: Gradle Plugin Compile
id: gradle-build-gradle-plugin
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan
build-root-directory: fullstack-gradle-plugin
- name: Spotless Check
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-spotless-check && steps.gradle-build.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: spotlessCheck --scan
- name: Examples Spotless Check
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-spotless-check && steps.gradle-build-examples.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: spotlessCheck --scan
build-root-directory: fullstack-examples
- name: Gradle Plugin Spotless Check
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-spotless-check && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: spotlessCheck --scan
build-root-directory: fullstack-gradle-plugin
- name: Unit Tests
id: gradle-test
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan
- name: Examples Unit Tests
id: gradle-test-examples
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build-examples.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan
build-root-directory: fullstack-examples
- name: Gradle Plugin Unit Tests
id: gradle-test-gradle-plugin
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan
build-root-directory: fullstack-gradle-plugin
- name: Publish Unit Test Report
uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
with:
check_name: 'Unit Test Results'
check_run_disabled: false
json_thousands_separator: ','
junit_files: "**/build/test-results/test/TEST-*.xml"
# Technically, this step is not required since the Gradle check task implicitly includes it but is executed again
# here to prevent failures if future modules are not wired properly.
- name: Jacoco Coverage Report
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: jacocoTestReport --scan
- name: Publish Jacoco Coverage Report
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: ${{ inputs.enable-unit-tests && !cancelled() }}
with:
name: Coverage Reports
path: '**/jacocoTestReport.xml'
- name: Publish Test Reports
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
with:
name: Test Reports
path: "**/build/reports/tests/**"