forked from hiero-ledger/hiero-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr-check-secondary-unit-integration-test.yml
More file actions
220 lines (190 loc) · 7.23 KB
/
Copy pathpr-check-secondary-unit-integration-test.yml
File metadata and controls
220 lines (190 loc) · 7.23 KB
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
name: Secondary PR Check - Hiero Solo Integration & Unit Tests
on:
push:
branches:
- "main"
paths-ignore:
- "**/*.md"
- "docs/**"
- "examples/**"
- "tck/**"
- "tests/fuzz/**"
- ".github/**"
- "!.github/workflows/pr-check-secondary-unit-integration-test.yml"
pull_request:
paths-ignore:
- "**/*.md"
- "docs/**"
- "examples/**"
- "tck/**"
- "tests/fuzz/**"
- ".github/**"
- "!.github/workflows/pr-check-secondary-unit-integration-test.yml"
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: pr-check-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
unit-tests:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ${{ (github.repository_owner != 'hiero-ledger' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)) && 'ubuntu-latest' || 'hl-sdk-py-lin-md' }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Generate Proto Files
run: uv run generate_proto.py
- name: Run unit tests
id: unit
continue-on-error: true
shell: bash
run: |
set -o pipefail
echo "🚀 Running unit tests..."
set +e
uv run pytest tests/unit -v --disable-warnings --continue-on-collection-errors 2>&1 | tee result_unit.log
pytest_exit=${PIPESTATUS[0]}
set -e
echo "exit_code=$pytest_exit" >> "$GITHUB_OUTPUT"
if [ $pytest_exit -ne 0 ]; then
echo "❌ Some unit tests failed"
grep -E 'FAILED |ERROR ' result_unit.log || true
else
echo "✅ All unit tests passed"
fi
- name: Fail job if unit tests failed
if: steps.unit.outputs.exit_code != '0'
shell: bash
run: |
echo "❌ Unit tests failed. See logs above."
exit 1
integration-tests:
name: Integration Tests (Python ${{ matrix.python-version }})
runs-on: ${{ (github.repository_owner != 'hiero-ledger' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)) && 'ubuntu-latest' || 'hl-sdk-py-lin-md' }}
timeout-minutes: 20
needs:
- unit-tests
if: needs.unit-tests.result == 'success'
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Generate Proto Files
run: uv run generate_proto.py
- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 # v0.19.0
with:
installMirrorNode: true
soloVersion: v0.65.0
mirrorNodeVersion: v0.153.0
hieroVersion: v0.73.0
- name: Run integration tests
id: integration
continue-on-error: true
shell: bash
env:
OPERATOR_ID: ${{ steps.solo.outputs.accountId }}
OPERATOR_KEY: ${{ steps.solo.outputs.privateKey }}
ADMIN_KEY: ${{ steps.solo.outputs.privateKey }}
PUBLIC_KEY: ${{ steps.solo.outputs.publicKey }}
NETWORK: solo
run: |
set -o pipefail
echo "🚀 Running integration tests..."
set +e
uv run --with pytest-xdist pytest -n 2 --dist=loadfile tests/integration -v --disable-warnings --continue-on-collection-errors 2>&1 | tee result_integration.log
pytest_exit=${PIPESTATUS[0]}
set -e
echo "exit_code=$pytest_exit" >> "$GITHUB_OUTPUT"
if [ $pytest_exit -ne 0 ]; then
echo "❌ Some integration tests failed"
grep -E 'FAILED |ERROR ' result_integration.log || true
else
echo "✅ All integration tests passed"
fi
- name: Fail job if integration tests failed
if: steps.integration.outputs.exit_code != '0'
shell: bash
run: |
echo "❌ Integration tests failed. See logs above."
exit 1
test-summary:
name: Test Results Summary
runs-on: ${{ (github.repository_owner != 'hiero-ledger' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)) && 'ubuntu-latest' || 'hl-sdk-py-lin-md' }}
needs:
- unit-tests
- integration-tests
if: always()
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
with:
egress-policy: audit
- name: Print summary and fail when any test job failed
shell: bash
run: |
unit_result="${{ needs.unit-tests.result }}"
integration_result="${{ needs.integration-tests.result }}"
echo ""
echo "==================== TEST SUMMARY ===================="
any_failed=false
if [ "$unit_result" = "success" ]; then
echo "✅ Unit tests passed"
else
echo "❌ Unit tests FAILED"
any_failed=true
fi
if [ "$integration_result" = "success" ]; then
echo "✅ Integration tests passed"
elif [ "$integration_result" = "skipped" ] && [ "$unit_result" != "success" ]; then
echo "⏭️ Integration tests skipped (unit tests failed first)"
else
echo "❌ Integration tests FAILED"
any_failed=true
fi
echo "======================================================"
echo ""
if [ "$any_failed" = true ]; then
echo "❌ Some tests failed. Failing workflow."
exit 1
else
echo "✅ All tests passed!"
fi