Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 116 additions & 70 deletions .github/workflows/pr-check-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@ name: Hiero Solo Integration & Unit Tests
on:
push:
branches:
- "**"
- "main"
paths-ignore:
- "**/*.md"
Comment thread
adityagiri3600 marked this conversation as resolved.
- "docs/**"
Comment thread
adityagiri3600 marked this conversation as resolved.
- "examples/**"
- "tck/**"
- ".github/**"
- "!.github/workflows/pr-check-test.yml"
pull_request:
workflow_dispatch:
paths-ignore:
- "**/*.md"
- "docs/**"
- "examples/**"
- "tck/**"
- ".github/**"
- "!.github/workflows/pr-check-test.yml"
workflow_dispatch: {}

permissions:
contents: read

jobs:
build-and-test:
unit-tests:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 30

timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -27,40 +41,94 @@ jobs:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
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 }}
cache: "pip"

- name: Install uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
with:
enable-cache: true

Comment thread
adityagiri3600 marked this conversation as resolved.
- 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
Comment thread
exploreriii marked this conversation as resolved.

- 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: ubuntu-latest
timeout-minutes: 20
needs:
- unit-tests
if: needs.unit-tests.result == 'success'
strategy:
fail-fast: false
matrix:
Comment thread
exploreriii marked this conversation as resolved.
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@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.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 setuptools wheel
run: pip install --upgrade pip setuptools wheel
- name: Install uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
with:
Comment thread
adityagiri3600 marked this conversation as resolved.
enable-cache: true

- name: Install dependencies
run: uv sync --all-extras --dev

Comment thread
adityagiri3600 marked this conversation as resolved.
- name: Generate Proto Files
run: uv run python generate_proto.py
run: uv run generate_proto.py

- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@4d42a74e8e644a2753f3bb7a2afa429305375b14 # v0.15.0
with:
installMirrorNode: true

- name: Install your package
run: pip install -e .

##############################################
# INTEGRATION TESTS
##############################################

- name: Run all integration tests
- name: Run integration tests
id: integration
continue-on-error: true
shell: bash
Expand All @@ -73,86 +141,64 @@ jobs:
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
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]}
echo "integration_failed=$pytest_exit" >> $GITHUB_OUTPUT
cat result_integration.log
set -e
echo "exit_code=$pytest_exit" >> "$GITHUB_OUTPUT"
if [ $pytest_exit -ne 0 ]; then
echo "❌ Some integration tests failed"
echo "Failed tests:"
grep -E 'FAILED ' result_integration.log || true
grep -E 'FAILED |ERROR ' result_integration.log || true
else
echo "✅ All integration tests passed"
fi

##############################################
# UNIT TESTS
##############################################

- name: Run all unit tests
id: unit
continue-on-error: true
- name: Fail job if integration tests failed
if: steps.integration.outputs.exit_code != '0'
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
echo "❌ Integration tests failed. See logs above."
exit 1

##############################################
# SUMMARY & FAIL CONDITIONS
##############################################
test-summary:
name: Test Results Summary
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests
if: always()

- name: Fail workflow if any tests failed
steps:
- name: Print summary and fail when any test job failed
shell: bash
run: |
integration_failed="${{ steps.integration.outputs.integration_failed }}"
unit_failed="${{ steps.unit.outputs.unit_failed }}"
unit_result="${{ needs.unit-tests.result }}"
integration_result="${{ needs.integration-tests.result }}"

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
if [ "$unit_result" = "success" ]; then
echo "✅ Unit tests passed"
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
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 "✅ Unit tests passed"
echo "❌ Integration tests FAILED"
any_failed=true
fi

echo "======================================================"
echo ""

# Final outcome
if [ "$any_failed" = true ]; then
echo "❌ Some tests failed. Failing workflow."
exit 1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
- docs: Clarified AI usage in Good First Issues templates. (#1923)

### .github
- changed `pr-check-test` to run unit matrix first, run integration matrix only after unit success, skip docs/examples/.github-only changes, and parallelize integration tests with xdist (`#1878`)
- archived workflows relating to PR reminders
- chore: switch workflow runner from ubuntu-latest to hl-sdk-py-lin-md for bot-assignment-check.yml workflow
- chore: update concurrency group for GFI assignment workflow to prevent race conditions (`#1910`)
Expand Down