Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
56 changes: 56 additions & 0 deletions .github/scripts/pr-check-test-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node

const { execSync } = require("child_process");

// These are the directories we want to check for correct naming
const TEST_DIRS = ["tests/unit", "tests/integration", "tests/tck", "tests/fuzz"];

// These are the excluded paths and file names inside the TEST_DIRS
const IGNORED = ["tests/fuzz/support"];
const EXCEPTIONS = ["conftest.py", "__init__.py", "init.py", "mock_server.py", "utils.py"];

// Collect naming errors to report at the end
const name_errors = [];

// Get list of changed files compared to main
const output = execSync("git diff --name-only origin/main...HEAD", { encoding: "utf-8" });
// Split output into lines and filter out empty lines for easy manipulation
// e.g. output = "tests/unit/my_test.py\ntests/integration/other_test.py"
const files = output.split("\n").filter(Boolean);
Comment thread
exploreriii marked this conversation as resolved.
Outdated
Comment thread
exploreriii marked this conversation as resolved.
Outdated


for (const file of files) {
// --- PATH FILTERING ---
// Skip files that are not in any of the specified test directories
if (!TEST_DIRS.some(dir => file.startsWith(dir))) continue;

// Skip ignored paths (e.g. helpers)
if (IGNORED.some(path => file.startsWith(path))) continue;

// Now we have file paths that we need to check for correct naming
// e.g. file = "tests/unit/my_test.py"

// --- Correct PATH now apply NAMING checks ---

// Extract the file name from the path
// e.g. from file = "tests/unit/my_test.py" get name = "my_test.py"
const name = file.split("/").pop();

// Skip allowed special files
if (EXCEPTIONS.includes(name)) continue;

// Enforce naming rule on files
if (!name.endsWith("_test.py")) {
console.error(`::error file=${file}::Must end with '_test.py'`);
name_errors.push(file);
}
}

// Fail if any bad files found
if (name_errors.length > 0) {
console.error("\nInvalid test files:");
name_errors.forEach(f => console.error(`- ${f}`));
process.exit(1);
}

console.log("All test filenames are valid");
93 changes: 0 additions & 93 deletions .github/scripts/pr-check-test-files.sh

This file was deleted.

27 changes: 10 additions & 17 deletions .github/workflows/pr-check-test-files.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
name: Test Files Naming Check

on:
push:
branches-ignore:
- main
pull_request:
types: [opened, synchronize, review_requested]

permissions:
contents: read

concurrency:
group: pr-checks-${{ github.workflow }}-${{ github.ref || github.run_id }}
group: pr-checks-${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
check-test-files:
# No fork check needed: push-only workflow; fork pushes have different repository_owner
runs-on: ${{ (github.repository_owner != 'hiero-ledger') && 'ubuntu-latest' || 'hl-sdk-py-lin-md' }}
Comment thread
exploreriii marked this conversation as resolved.
Outdated

steps:
Expand All @@ -23,18 +21,13 @@ jobs:
with:
egress-policy: audit

- name: Checkout repository
- name: Checkout repository (shallow)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
fetch-depth: 2 # Fetch at least 2 commits to compare changes in test files

- name: Set up Hiero SDK Upstream
run: |
git remote set-url origin https://github.com/hiero-ledger/hiero-sdk-python.git

- name: Fetch main branch
run: |
git fetch origin main
- name: Fetch main
run: git fetch origin main --depth=1 # Ensure we have the latest main for accurate diff

- name: Check added test file names
run: |
chmod +x .github/scripts/pr-check-test-files.sh
.github/scripts/pr-check-test-files.sh
- name: Run test file naming check
run: node .github/scripts/pr-check-test-files.js
Comment thread
coderabbitai[bot] marked this conversation as resolved.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
- Refactored the Advanced Issue Template to V2 with stricter prerequisites and a focus on architectural design (#2016).
- Refactored the Advanced Issue Template to ensure PR-level quality checklists do not block maintainers during issue creation (#2036)
- Add automated label sync workflow to propagate labels from linked issues to pull requests (#1716)
- Added support to fuzz and TCK test naming check, converted to JS from shell (#2064)
Comment thread
exploreriii marked this conversation as resolved.
Outdated

## [0.2.3] - 2026-03-26

Expand Down
Loading