-
Notifications
You must be signed in to change notification settings - Fork 10
208 lines (186 loc) · 7.91 KB
/
zxc-e2e-test.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
##
# 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: E2E Test"
# The purpose of this reusable workflow is to run the e2e 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_dispatch:
workflow_call:
inputs:
node-version:
description: "NodeJS Version:"
type: string
required: false
default: "20"
custom-job-label:
description: "Custom Job Label:"
type: string
required: false
default: "E2E Test"
npm-test-script:
description: "NPM Test Run Script:"
type: string
required: false
default: "test-e2e-standard"
coverage-subdirectory:
description: "Coverage Report Subdirectory:"
type: string
required: false
default: "e2e"
coverage-report-name:
description: "Coverage Report Name:"
type: string
required: false
default: "E2E Tests Coverage Report"
defaults:
run:
shell: bash
permissions:
id-token: write
contents: read
actions: read
pull-requests: write
checks: write
statuses: write
env:
#CG_EXEC: export R_UID=$(id -u); CGROUP_LOGLEVEL=DEBUG cgexec -g cpu,memory:user.slice/user-${R_UID}.slice/user@${R_UID}.service/e2e-${{ github.run_id }} --sticky ionice -c 2 -n 2 nice -n 19
CG_EXEC: ""
jobs:
e2e-test:
name: ${{ inputs.custom-job-label || 'E2E Test' }}
runs-on: solo-linux-large
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
# - name: Setup Control Groups
# run: |
# echo "::group::Get System Configuration"
# USR_ID="$(id -un)"
# GRP_ID="$(id -gn)"
# E2E_MEM_LIMIT="30064771072"
# AGENT_MEM_LIMIT="2147483648"
# USER_SLICE="user.slice/user-$(id -u).slice"
# USER_SERVICE="${USER_SLICE}/user@$(id -u).service"
# E2E_GROUP_NAME="${USER_SERVICE}/e2e-${{ github.run_id }}"
# AGENT_GROUP_NAME="${USER_SERVICE}/agent-${{ github.run_id }}"
# echo "::endgroup::"
#
# echo "::group::Install Control Group Tools"
# if ! command -v cgcreate >/dev/null 2>&1; then
# sudo apt-get update
# sudo apt-get install -y cgroup-tools
# fi
# echo "::endgroup::"
#
# echo "::group::Create Control Groups"
# sudo cgcreate -g cpu,memory:${USER_SLICE} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID}
# sudo cgcreate -g cpu,memory:${USER_SERVICE} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID}
# sudo cgcreate -g cpu,memory:${E2E_GROUP_NAME} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID}
# sudo cgcreate -g cpu,memory:${AGENT_GROUP_NAME} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID}
# echo "::endgroup::"
#
# echo "::group::Set Control Group Limits"
# cgset -r cpu.weight=768 ${E2E_GROUP_NAME}
# cgset -r cpu.weight=500 ${AGENT_GROUP_NAME}
# cgset -r memory.max=${E2E_MEM_LIMIT} ${E2E_GROUP_NAME}
# cgset -r memory.max=${AGENT_MEM_LIMIT} ${AGENT_GROUP_NAME}
# cgset -r memory.swap.max=${E2E_MEM_LIMIT} ${E2E_GROUP_NAME}
# cgset -r memory.swap.max=${AGENT_MEM_LIMIT} ${AGENT_GROUP_NAME}
# echo "::endgroup::"
#
# echo "::group::Move Runner Processes to Control Groups"
# sudo cgclassify --sticky -g cpu,memory:${AGENT_GROUP_NAME} $(pgrep 'Runner.Listener' | tr '\n' ' ')
# sudo cgclassify -g cpu,memory:${AGENT_GROUP_NAME} $(pgrep 'Runner.Worker' | tr '\n' ' ')
# echo "::endgroup::"
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ inputs.node-version }}
- name: Install wget
run: |
sudo apt-get update
sudo apt-get install -y wget
- name: Setup Kind
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
with:
install_only: true
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
version: v0.21.0
kubectl_version: v1.28.6
verbosity: 3
wait: 120s
- name: Install Dependencies
id: npm-deps
run: npm ci
- name: Compile Project
run: npm run build
- name: Pull Kind Docker Image
run: docker image pull kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
- name: Setup Java
if: ${{ runner.os == 'linux' && (inputs.npm-test-script == 'test-e2e-node-local-hedera' || inputs.npm-test-script == 'test-e2e-node-local-ptt' || inputs.npm-test-script == 'test-e2e-node-add-local') && !cancelled() && !failure() }}
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: temurin
java-version: 21.0.1
- name: Setup Gradle
if: ${{ runner.os == 'linux' && (inputs.npm-test-script == 'test-e2e-node-local-hedera' || inputs.npm-test-script == 'test-e2e-node-local-ptt' || inputs.npm-test-script == 'test-e2e-node-add-local') && !cancelled() && !failure() }}
uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0
with:
cache-read-only: false
- name: Build Hedera code locally
if: ${{ runner.os == 'linux' && (inputs.npm-test-script == 'test-e2e-node-local-hedera' || inputs.npm-test-script == 'test-e2e-node-local-ptt' || inputs.npm-test-script == 'test-e2e-node-add-local') && !cancelled() && !failure() }}
run: |
cd ..
git clone https://github.com/hashgraph/hedera-services.git --depth 1 --branch v0.58.0
cd hedera-services
ls -ltr
${{ env.CG_EXEC }} ./gradlew assemble --stacktrace --info
cd ../solo
- name: Setup E2E Tests
run: |
npm link
${{ env.CG_EXEC }} ./test/e2e/setup-e2e.sh
- name: Run E2E Tests
run: |
${{ env.CG_EXEC }} npm run ${{ inputs.npm-test-script }}
- name: Upload E2E Logs to GitHub
if: ${{ !cancelled() }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: solo-${{ inputs.npm-test-script }}.log
path: ~/.solo/logs/*
overwrite: true
if-no-files-found: error
- name: Upload E2E Test Report
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: ${{ steps.npm-deps.conclusion == 'success' && !cancelled() }}
with:
name: e2e_test_report_${{ inputs.npm-test-script }}
path: "junit-${{ inputs.coverage-subdirectory }}.xml"
overwrite: true
if-no-files-found: error
- name: Publish E2E Coverage Report
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: ${{ !cancelled() }}
with:
name: ${{ inputs.coverage-report-name }}
path: 'coverage/${{ inputs.coverage-subdirectory }}'