forked from hiero-ledger/hiero-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (142 loc) · 5.43 KB
/
pr-check-test.yml
File metadata and controls
168 lines (142 loc) · 5.43 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
name: Hiero Solo Integration & Unit Tests
on:
push:
branches:
- "**"
pull_request: {}
workflow_dispatch: {}
permissions:
contents: read
actions: write
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
- name: Install setuptools wheel
run: pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Generate Proto Files
run: uv run python generate_proto.py
- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@fbca3e7a99ce9aa8a250563a81187abe115e0dad # v0.15.0
with:
installMirrorNode: true
- name: Set environment variables
run: |
echo "OPERATOR_ID=${{ steps.solo.outputs.accountId }}"
echo "OPERATOR_KEY=${{ steps.solo.outputs.privateKey }}"
echo "ADMIN_KEY=${{ steps.solo.outputs.privateKey }}"
echo "PUBLIC_KEY=${{ steps.solo.outputs.publicKey }}"
- name: Install your package
run: pip install -e .
##############################################
# INTEGRATION TESTS
##############################################
- name: Run all 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..."
uv run pytest tests/integration -v --disable-warnings --continue-on-collection-errors 2>&1 | tee result_integration.log
pytest_exit=${PIPESTATUS[0]}
echo "integration_failed=$pytest_exit" >> $GITHUB_OUTPUT
cat result_integration.log
if [ $pytest_exit -ne 0 ]; then
echo "❌ Some integration tests failed"
echo "Failed tests:"
grep -E 'FAILED ' result_integration.log || true
else
echo "✅ All integration tests passed"
fi
##############################################
# UNIT TESTS
##############################################
- name: Run all unit tests
id: unit
continue-on-error: true
shell: bash
run: |
set -o pipefail
echo "🚀 Running unit tests..."
uv run pytest tests/unit -v --disable-warnings --continue-on-collection-errors 2>&1 | tee result_unit.log
pytest_exit=${PIPESTATUS[0]}
echo "unit_failed=$pytest_exit" >> $GITHUB_OUTPUT
cat result_unit.log
if [ $pytest_exit -ne 0 ]; then
echo "❌ Some unit tests failed"
echo "Failed tests:"
grep -E 'FAILED ' result_unit.log || true
else
echo "✅ All unit tests passed"
fi
##############################################
# SUMMARY & FAIL CONDITIONS
##############################################
- name: Fail workflow if any tests failed
shell: bash
run: |
integration_failed="${{ steps.integration.outputs.integration_failed }}"
unit_failed="${{ steps.unit.outputs.unit_failed }}"
echo ""
echo "==================== TEST SUMMARY ===================="
any_failed=false
if [ "$integration_failed" != "0" ]; then
echo "❌ Integration tests FAILED"
echo " → Check the integration test logs above for details."
if [ -f result_integration.log ]; then
grep -E 'FAILED ' result_integration.log || echo " (No FAILED lines found)"
else
echo " (Integration log not found)"
fi
any_failed=true
else
echo "✅ Integration tests passed"
fi
if [ "$unit_failed" != "0" ]; then
echo "❌ Unit tests FAILED"
echo " → Check the unit test logs above for details."
if [ -f result_unit.log ]; then
grep -E 'FAILED ' result_unit.log || echo " (No FAILED lines found)"
else
echo " (Unit log not found)"
fi
any_failed=true
else
echo "✅ Unit tests passed"
fi
echo "======================================================"
echo ""
# Final outcome
if [ "$any_failed" = true ]; then
echo "❌ Some tests failed. Failing workflow."
exit 1
else
echo "✅ All tests passed!"
fi