Skip to content

feat: Add Client factory methods (from_env) and simplify examples (#1… #80

feat: Add Client factory methods (from_env) and simplify examples (#1…

feat: Add Client factory methods (from_env) and simplify examples (#1… #80

name: Run Examples
permissions:
contents: read
on:
push:
branches:
- "**"
pull_request:
workflow_dispatch:
jobs:
run-examples:
runs-on: ubuntu-latest
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
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867
- name: Install dependencies
run: uv sync
- 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: Run Examples
env:
OPERATOR_ID: ${{ steps.solo.outputs.accountId }}
OPERATOR_KEY: ${{ steps.solo.outputs.privateKey }}
CHAIN_ID: 012A
NETWORK: solo
shell: bash
run: |
set -euo pipefail
export PYTHONPATH="$PWD"
files=$(find examples -name "*.py" -type f ! -name "__init__.py")
for file in $files; do
echo -e "\n************ ${file} ************"
# Convert path to module name
module=$(realpath --relative-to="$PWD" "$file" | sed 's|/|.|g' | sed 's|.py$||')
if ! output=$(uv run -m "$module" 2>&1); then
echo -e "\n❌ Example failed: ${file}"
echo "************ Error Output ************"
echo "$output"
echo "**************************************"
exit 1
fi
echo "$output"
echo "✅ Completed ${file} successfully."
done