From c99d62743efea641bd181b0d2fce33932f9446a9 Mon Sep 17 00:00:00 2001 From: exploreriii <133720349+exploreriii@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:51:09 +0000 Subject: [PATCH 1/4] feat: new pr-checks-naming-tests workflow Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com> --- .github/workflows/pr-checks-naming-tests.yml | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/pr-checks-naming-tests.yml diff --git a/.github/workflows/pr-checks-naming-tests.yml b/.github/workflows/pr-checks-naming-tests.yml new file mode 100644 index 000000000..94a9aed58 --- /dev/null +++ b/.github/workflows/pr-checks-naming-tests.yml @@ -0,0 +1,47 @@ +--- +name: Test File Naming + +on: + pull_request: + types: + - "opened" + - "reopened" + - "edited" + - "synchronize" + +jobs: + test-name-check: + name: Test File Naming Check + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Harden the runner (Audit all outbound calls) + # v2.13.1 + uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a + 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" \ + ! -path "tests/integration/__init__.py" \ + ! -path "tests/unit/conftest.py" \ + ! -path "tests/unit/mock_server.py" \ + ! -path "tests/unit/__init__.py" \ + ! -path "tests/__init__.py" \ + || true) + if [ -n "$invalid_tests" ]; then + echo "The following test files don't follow (*_test.py):" + echo "$invalid_tests" + echo "" + echo "Please rename them as *_test.py." + exit 1 + else + echo "All test files follow *_test.py naming convention." + fi \ No newline at end of file From 168e15e781c5923a17b15da0a45068cf5cb8b860 Mon Sep 17 00:00:00 2001 From: exploreriii <133720349+exploreriii@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:52:06 +0000 Subject: [PATCH 2/4] chore: new pr-checks-naming-tests workflow Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b941d59..50e7ed132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. ## [0.1.7] - 2025-10-28 ### Added - +- New workflow pr-checks-naming-tests that responds with an error if incorrectly named test files are added - Expanded `README.md` with a new "Follow Us" section detailing how to watch, star, and fork the repository (#472). - Refactored `examples/topic_create.py` into modular functions for better readability and reuse. - Add Rebasing and Signing section to signing.md with instructions for maintaining commit verification during rebase operations (#556) From 0530c3e59d9062b92d7d041f7d952881ac21f98f Mon Sep 17 00:00:00 2001 From: exploreriii <133720349+exploreriii@users.noreply.github.com> Date: Mon, 10 Nov 2025 20:50:20 +0000 Subject: [PATCH 3/4] chore: testing Raja's PR version Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com> --- .github/workflows/pr-checks-naming-tests.yml | 73 ++++++++++++-------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr-checks-naming-tests.yml b/.github/workflows/pr-checks-naming-tests.yml index 94a9aed58..45d91b436 100644 --- a/.github/workflows/pr-checks-naming-tests.yml +++ b/.github/workflows/pr-checks-naming-tests.yml @@ -1,47 +1,62 @@ ---- -name: Test File Naming +name: "Test File Naming Check" on: pull_request: - types: - - "opened" - - "reopened" - - "edited" - - "synchronize" + types: [opened, reopened, synchronize, edited] + +permissions: + contents: read + +concurrency: + group: test-name-check-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: test-name-check: name: Test File Naming Check runs-on: ubuntu-latest - permissions: - contents: read + steps: - name: Harden the runner (Audit all outbound calls) - # v2.13.1 - uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: egress-policy: audit + # Using the specific commit SHA for actions/checkout@v5.0.0, as requested - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a368bb9860e15bcafd2cf940ba6f36c4c - 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" \ - ! -path "tests/integration/__init__.py" \ - ! -path "tests/unit/conftest.py" \ - ! -path "tests/unit/mock_server.py" \ - ! -path "tests/unit/__init__.py" \ - ! -path "tests/__init__.py" \ - || true) - if [ -n "$invalid_tests" ]; then - echo "The following test files don't follow (*_test.py):" - echo "$invalid_tests" - echo "" - echo "Please rename them as *_test.py." + echo "🔍 Checking test file naming rules..." + + # Helper files that must be excluded from naming validation + EXCLUDES="__init__.py conftest.py mock_server.py utils_for_test.py" + + # Build exclude arguments for find + EX_ARGS="" + for f in $EXCLUDES; do + EX_ARGS="$EX_ARGS ! -name \"$f\"" + done + + # Rule 1 — Unit tests (tests/unit) must start with test_*.py + echo "➡️ Checking UNIT tests (must start with test_)..." + invalid_unit=$(eval "find tests/unit -type f -name '*.py' $EX_ARGS ! -name 'test_*.py'") + + # Rule 2 — Integration tests (tests/integration) must end with *_test.py + echo "➡️ Checking INTEGRATION tests (must end with _test.py)..." + invalid_integration=$(eval "find tests/integration -type f -name '*.py' $EX_ARGS ! -name '*_test.py'") + + if [ -n "$invalid_unit" ]; then + echo "❌ Invalid Unit Test Filenames:" + echo "$invalid_unit" exit 1 - else - echo "All test files follow *_test.py naming convention." - fi \ No newline at end of file + fi + + if [ -n "$invalid_integration" ]; then + echo "❌ Invalid Integration Test Filenames:" + echo "$invalid_integration" + exit 1 + fi + + echo "✅ All test files follow the correct conventions!" \ No newline at end of file From 32c094668b4647a5fa601a00963d7e5daa7ba7fe Mon Sep 17 00:00:00 2001 From: exploreriii <133720349+exploreriii@users.noreply.github.com> Date: Mon, 10 Nov 2025 20:50:44 +0000 Subject: [PATCH 4/4] fix: non existing github action hash Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com> --- .github/workflows/pr-checks-naming-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checks-naming-tests.yml b/.github/workflows/pr-checks-naming-tests.yml index 45d91b436..1f3c6aa3f 100644 --- a/.github/workflows/pr-checks-naming-tests.yml +++ b/.github/workflows/pr-checks-naming-tests.yml @@ -24,7 +24,7 @@ jobs: # Using the specific commit SHA for actions/checkout@v5.0.0, as requested - name: Checkout repository - uses: actions/checkout@8ade135a368bb9860e15bcafd2cf940ba6f36c4c + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: Validate test file naming convention run: |