Skip to content

docs: add guide for pinning github actions (#1215) #50

docs: add guide for pinning github actions (#1215)

docs: add guide for pinning github actions (#1215) #50

Workflow file for this run

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@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
- 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