diff --git a/.github/workflows/pr-check-naming-test.yml b/.github/workflows/pr-check-naming-test.yml new file mode 100644 index 000000000..48f2f791b --- /dev/null +++ b/.github/workflows/pr-check-naming-test.yml @@ -0,0 +1,56 @@ +name: 'Test Naming Check' + +on: + pull_request: + paths: + - "tests/**" + - ".github/workflows/pr-check-naming-test.yml" + +permissions: + contents: read + +jobs: + test-name-check: + name: Validate Test File Naming + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@8ade135a368bb9860e15bcafd2cf940ba6f36c4c + + + - name: Check Unit Test Naming (must start with test_*.py) + run: | + echo "Checking unit tests naming…" + + invalid_unit=$(find tests/unit -type f -name "*.py" \ + ! -name "test_*.py" \ + ! -name "__init__.py" \ + ! -name "conftest.py" \ + ! -name "mock_server.py" \ + ! -name "utils_for_test.py" \ + || true) + + if [ -n "$invalid_unit" ]; then + echo "❌ Invalid Unit Test Filenames:" + echo "$invalid_unit" + exit 1 + fi + echo "✔️ Unit test names are valid." + + - name: Check Integration Test Naming (must end with _test.py) + run: | + echo "Checking integration test naming…" + + invalid_integration=$(find tests/integration -type f -name "*.py" \ + ! -name "*_test.py" \ + ! -name "__init__.py" \ + ! -name "utils_for_test.py" \ + || true) + + if [ -n "$invalid_integration" ]; then + echo "❌ Invalid Integration Test Filenames:" + echo "$invalid_integration" + exit 1 + fi + echo "✔️ Integration test names are valid." diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index eba973ba3..3d8a594a7 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -95,3 +95,32 @@ jobs: echo "FAIL: No line-level changes detected in CHANGELOG.md." exit 1 fi + + test-name-check: + name: Test File Naming Check + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate test file naming convention + run: | + echo "Checking for test files that don't end with _test.py..." + invalid_tests=$(find tests -type f -name "*.py" ! -name "*_test.py" || true) + + if [ -n "$invalid_tests" ]; then + echo "The following test files don't follow the naming convention (*_test.py):" + echo "$invalid_tests" + echo "" + echo "Please rename them to end with *_test.py so CI can detect and run them." + exit 1 + else + echo "All test files follow *_test.py naming convention." + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b941d59..1493e2070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. ## [Unreleased] ### Added +- Added CI check in `.github/workflows/pr-checks.yml` to ensure all test files follow the naming convention `*_test.py`.This prevents untracked or skipped tests from being missed during CI runs. - Add `TokenFeeScheduleUpdateTransaction` class to support updating custom fee schedules on tokens (#471). - Add `examples/token_update_fee_schedule_fungible.py` and `examples/token_update_fee_schedule_nft.py` demonstrating the use of `TokenFeeScheduleUpdateTransaction`. - Update `docs/sdk_users/running_examples.md` to include `TokenFeeScheduleUpdateTransaction`. diff --git a/tests/integration/account_balance_query_e2e.py b/tests/integration/account_balance_query_e2e.py new file mode 100644 index 000000000..325b7326c --- /dev/null +++ b/tests/integration/account_balance_query_e2e.py @@ -0,0 +1,14 @@ +import pytest + +from hiero_sdk_python.query.account_balance_query import CryptoGetAccountBalanceQuery +from tests.integration.utils_for_test import IntegrationTestEnv + + +@pytest.mark.integration +def test_integration_account_balance_query_can_execute(): + env = IntegrationTestEnv() + + try: + CryptoGetAccountBalanceQuery(account_id=env.operator_id).execute(env.client) + finally: + env.close() \ No newline at end of file diff --git a/unit/failing_test_example.py b/unit/failing_test_example.py new file mode 100644 index 000000000..295c213a5 --- /dev/null +++ b/unit/failing_test_example.py @@ -0,0 +1 @@ +def dummy_test(): pass