Skip to content
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/pr-check-naming-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "PR Test Naming Check"

on:
pull_request:
types: [opened, reopened, synchronize, edited]

permissions:
contents: read

jobs:
test-name-check:
name: Validate test naming convention
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Run test naming validation
run: |
echo "🔍 Checking test file naming convention..."

bad_files=$(find tests -type f -name "*.py" \
! -name "*_test.py" \
! -path "tests/__init__.py" \
! -path "tests/unit/__init__.py" \
! -path "tests/integration/__init__.py" \
! -path "tests/unit/conftest.py" \
! -path "tests/unit/mock_server.py" \
! -path "tests/integration/utils_for_test.py")

if [ -n "$bad_files" ]; then
echo "❌ Invalid test filenames detected:"
echo "$bad_files"
exit 1
fi

echo "✅ All test files follow the _test.py convention!"
8 changes: 2 additions & 6 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,24 @@ jobs:

echo "Checking files changed in PR #${PR_NUMBER}..."

# List files in the PR and check for CHANGELOG.md (root or any path ending with /CHANGELOG.md)
FILES_JSON="$(gh api repos/${{ github.repository }}/pulls/${PR_NUMBER}/files --paginate)"
if ! echo "${FILES_JSON}" | jq -e '.[] | select(.filename | test("(^|/)CHANGELOG\\.md$"; "i"))' >/dev/null; then
echo "FAIL: CHANGELOG.md was not changed in this PR."
exit 1
fi

# Ensure there is at least one line-level change (+ or -) in the patch for CHANGELOG.md
PATCH_CONTENT="$(echo "${FILES_JSON}" \
| jq -r '.[] | select(.filename | test("(^|/)CHANGELOG\\.md$"; "i")) | .patch // empty')"

# If no patch is returned (very large file or API omission), treat presence as sufficient
if [[ -z "${PATCH_CONTENT}" ]]; then
echo "CHANGELOG.md modified (no patch provided by API). Passing."
echo "CHANGELOG.md modified (patch omitted). Passing."
exit 0
fi

# Look for actual line changes (exclude diff headers +++/---)
if echo "${PATCH_CONTENT}" | awk '{print $0}' | grep -E '^[+-]' | grep -vE '^\+\+\+|^\-\-\-' >/dev/null; then
echo "PASS: CHANGELOG.md contains line-level changes."
exit 0
else
echo "FAIL: No line-level changes detected in CHANGELOG.md."
exit 1
fi
fi
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.


### Added

- CI: Add standalone workflow `pr-check-naming-test.yml` to enforce test naming rules:
- Unit tests must be named `test_*.py`
- Integration tests must be named `*_test.py`
- Excludes helper files: `__init__.py`, `conftest.py`, `mock_server.py`, `utils_for_test.py`

### Changed
- Refactored token-related example scripts (`token_delete.py`, `token_dissociate.py`, etc.) for improved readability and modularity. [#370]
Expand Down
Loading