File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+
3+ # ======================================================================================================================================================
4+ # @file: pr-check-test-files.sh
5+ #
6+ # @Description A CI check written in bash that enforces the '_test.py' suffix, ensures Pytest can automatically discover
7+ # new or renamed test files in a Pull Request.
8+ #
9+ # @logic:
10+ # 1. Identifies files as (A) Added, (R) Renamed, or (C) copied using 'git diff' to check destination filename ($file2).
11+ # 2. Validates paths against allowed test directories (unit/integration).
12+ # 3. Excludes specific utility (ex., conftest.py, utils.py) and non-Python files.
13+ # 4. Parses tab-separated Git output via IFS=$'\t' to ensure robust filename handling.
14+ # 5. Routes files using 'case'. Checks $status before dispatching to the proper path.
15+ #
16+ # @types:
17+ # - String: Used for file paths and git status codes.
18+ # - Array: Used for 'TEST_DIRS', 'EXCEPTION_NAMES', and accumulating errors.
19+ #
20+ # @Parameters:
21+ # - None: This script does not accept CLI arguments. It derives the input from the current Git state compared against origin/main.
22+ #
23+ # @Dependencies:
24+ # - Git: (for diff)
25+ # - Bash: (runs the script)
26+ # - Pytest: (naming standard)
27+ #
28+ # @Permissions:
29+ # - Requires Execute permissions (chmod +x) to run. Also needs Read access to the git repository to perform the diff.
30+ #
31+ # @Return
32+ # - 0: All test files follow the naming standard.
33+ # - 1: Returns a RED error output identifying the specific file that's receiving the error.
34+ # Includes a yellow instructional block providing reason why the file failed.
35+ # ======================================================================================================================================================
36+
237RED=" \033[31m"
338YELLOW=" \033[33m"
439RESET=" \033[0m"
You can’t perform that action at this time.
0 commit comments