Skip to content

Commit 83a2ba1

Browse files
committed
docs: add technical docstrings and harden pr-check-test-files.sh
Signed-off-by: Dominiq Barbero <mr.dom.barbero@gmail.com>
1 parent 115b21f commit 83a2ba1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/scripts/pr-check-test-files.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ======================================================================================================================================================
5+
# @file: pr-check-test-files.sh
6+
#
7+
# @Description A CI check written in bash that enforces the '_test.py' suffix to ensure Pytest can automatically discover
8+
# new or renamed test files in a Pull Request.
9+
#
10+
# @logic:
11+
# 1. Identifies files as (A) Added, (R) Renamed, or (C) Copied using 'git diff' to check
12+
# relevant filename ($file1 for added files, $file2 for renamed/copied files).
13+
# 2. Validates paths against allowed test directories (unit/integration).
14+
# 3. Excludes specific utility (ex., conftest.py, utils.py) and non-Python files.
15+
# 4. Parses tab-separated Git output via IFS=$'\t' to ensure robust filename handling.
16+
# 5. Routes files using case statement based on git status
17+
#
18+
# @types:
19+
# - String: Used for file paths and git status codes.
20+
# - Array: Used for 'TEST_DIRS', 'EXCEPTION_NAMES', and accumulating errors.
21+
#
22+
# @Parameters:
23+
# - None: This script does not accept CLI arguments. It derives the input from the current Git state compared against origin/main.
24+
#
25+
# @Dependencies:
26+
# - Git: (for diff)
27+
# - Bash: (runs the script)
28+
# - Pytest: (naming standard)
29+
#
30+
# @Permissions:
31+
# - Requires Execute permissions (chmod +x) to run. Also needs Read access to the git repository to perform the diff.
32+
#
33+
# @Return
34+
# - 0: All test files follow the naming standard.
35+
# - 1: Exits with status 1 and outputs error messages in red.
36+
# Includes a yellow instructional block providing reason why the file failed.
37+
# ======================================================================================================================================================
38+
239
RED="\033[31m"
340
YELLOW="\033[33m"
441
RESET="\033[0m"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
8989
- Improved unit test coverage for `TransactionId` class, covering parsing logic, hashing, and scheduled transactions.
9090
- Chained Good First Issue assignment with mentor assignment to bypass GitHub's anti-recursion protection - mentor assignment now occurs immediately after successful user assignment in the same workflow execution. (#1369)
9191
- Add GitHub Actions script and workflow for automatic spam list updates.
92+
- Added technical docstrings and hardening (set -euo pipefail) to the pr-check-test-files.sh script(#1336)
9293

9394
### Changed
9495
- Added global review instructions to CodeRabbit configuration to limit reviews to issue/PR scope and prevent scope creep [#1373]

0 commit comments

Comments
 (0)