Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
62 changes: 62 additions & 0 deletions .github/workflows/pr-checks-naming-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "Test File Naming Check"

on:
pull_request:
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

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit

# Using the specific commit SHA for actions/[email protected], as requested
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8

- name: Validate test file naming convention
run: |
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
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!"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading