-
Notifications
You must be signed in to change notification settings - Fork 147
docs: add technical docstring to pr-check-test-files.sh #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughEnabled strict shell options and added ANSI color constants plus expanded header/docstrings in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.github/scripts/pr-check-test-files.sh (2)
44-44: Validate git diff command success and origin/main existence.Line 44 calls
git diff --name-status origin/mainwithout validating success. If git diff fails ororigin/maindoesn't exist, the script could process invalid data or silently fail. Validate the command before using its output.💡 Suggested fix
+if ! git rev-parse origin/main >/dev/null 2>&1; then + echo -e "${RED}ERROR${RESET}: origin/main reference not found. Ensure git remote 'origin' is configured." >&2 + exit 1 +fi + DIFF_FILES=$(git diff --name-status origin/main) +if [[ -z "$DIFF_FILES" ]]; then + # No files changed; exit cleanly + exit 0 +fi
62-62: Apply defensive quoting to pattern literals in conditional expressions.Lines 62 and 70 use unquoted glob patterns (
*.py,*_test.py) inside[[ ]]. While this works in most cases, defensive quoting—treating patterns as literals and enabling pattern matching explicitly—improves clarity and prevents edge-case issues.✨ Proposed refactor
- if [[ $(basename "$filename") != *.py ]]; then + if [[ $(basename "$filename") != *.py ]] && ! [[ $(basename "$filename") == *.py ]]; thenAlternatively, if the pattern matching behavior is intentional, add a clarifying comment. Otherwise, use a case statement or explicit string matching.
Also applies to: 70-70
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/scripts/pr-check-test-files.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
.github/scripts/pr-check-test-files.sh (2)
3-35: Comprehensive docstring enhances maintainability and clarity.The newly added docstring provides excellent documentation covering purpose, logic flow, data types, parameters, dependencies, permissions, and return codes. The structure follows a professional standard and accurately reflects the script's behavior. The five-step logic breakdown (lines 9–14) is particularly helpful for future maintainers.
One minor suggestion: the @return section (lines 31–34) could be more explicit about the dual-color output pattern (RED for error status, YELLOW for instructional text), as this is now materialized in the constants added below.
37-39: Color constants improve output visibility and maintainability.The introduction of color constants (RED, YELLOW, RESET) is a good refactor for readability and consistency. These are properly leveraged in error messages (line 71) and align with modern CI best practices for human-readable output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/scripts/pr-check-test-files.sh (1)
44-44: Consider validating Git availability and branch existence.Per coding guidelines for
.github/scripts/scripts, untrusted input should be validated. The commandgit diff --name-status origin/maincould fail if:
- Git is not available
origin/mainbranch doesn't exist- Repository is in an unexpected state
While this is less critical in CI environments, adding validation would make the script more robust:
if ! command -v git >/dev/null 2>&1; then echo -e "${RED}ERROR${RESET}: Git command not found" exit 1 fi if ! git rev-parse --verify origin/main >/dev/null 2>&1; then echo -e "${RED}ERROR${RESET}: Branch origin/main not found" exit 1 fiNote: Once
set -euo pipefailis added (per previous review), command failures will automatically terminate the script, providing basic error handling.As per coding guidelines, production-grade scripts should validate prerequisites.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/scripts/pr-check-test-files.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/scripts/pr-check-test-files.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
.github/scripts/pr-check-test-files.sh (1)
3-35: Documentation header is comprehensive and accurate.The added documentation effectively addresses the previous review feedback:
- Improved phrasing for suffix enforcement (line 6-7)
- Consistent formatting for git status codes (line 10)
- Clearer exit status description (line 33)
The docstring accurately describes the script's purpose, logic flow, data types, dependencies, and return behavior.
Akshat8510
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/scripts/pr-check-test-files.sh (1)
48-77: Consider adding logging for key decisions and early exits.Per coding guidelines for
.github/scripts/**/*.sh, scripts MUST log key decisions and early exits. The current implementation silently returns in several cases:
- Line 57: File not in test directories
- Line 64: Non-Python files
- Line 68: Exception/utility files
- Line 76: Default success case
While the script functions correctly, adding informational logging would improve debuggability when investigating CI failures. For example:
# In is_in_test_dir function if ! (found in any test dir); then echo "Skipping '$file' (not in test directory)" >&2 return 1 fi # In check_test_file_name function if [[ $(basename "$filename") != *.py ]]; then echo "Skipping '$(basename "$filename")' (not a Python file)" >&2 return 0 fiNote: This is pre-existing code and beyond the scope of your documentation-focused PR. Consider addressing in a follow-up if the team wants enhanced observability.
As per coding guidelines for CI scripts.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.github/scripts/pr-check-test-files.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
.github/scripts/pr-check-test-files.sh (2)
2-3: Excellent addition of strict error handling.The
set -euo pipefaildirective is correctly placed and fully addresses the critical requirement from coding guidelines. This ensures the script will exit on errors, fail on undefined variables, and propagate pipeline failures—essential for reliable CI automation.As per coding guidelines, this is a mandatory requirement for all scripts in
.github/scripts/.
4-36: Comprehensive and accurate documentation header.The documentation block is well-structured and technically accurate. Each section correctly describes the script's behavior:
- Logic: All 5 steps accurately reflect the implementation (git status codes, path validation, exclusions, tab-separated parsing, case routing)
- Types, Parameters, Dependencies: Correctly identified and documented
- Return values: Accurately describes the exit codes and colored output format
This provides excellent reference material for maintainers and addresses the PR objective of adding technical documentation.
This comment was marked as resolved.
This comment was marked as resolved.
|
Hi @MrMadHatt, this is LinkBot 👋 Linking pull requests to issues helps us significantly with reviewing pull requests and keeping the repository healthy. 🚨 This pull request does not have an issue linked. Please link an issue using the following format: 📖 Guide: If no issue exists yet, please create one: Thanks! |
This comment was marked as resolved.
This comment was marked as resolved.
|
Hi @MrMadHatt, this is LinkBot 👋 Linking pull requests to issues helps us significantly with reviewing pull requests and keeping the repository healthy. 🚨 This pull request does not have an issue linked. Please link an issue using the following format: 📖 Guide: If no issue exists yet, please create one: Thanks! |
|
Hi, this is MergeConflictBot. Please resolve these conflicts locally and push the changes. To assist you, please read: Thank you for contributing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/scripts/pr-check-test-files.shCHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
🪛 LanguageTool
CHANGELOG.md
[grammar] ~86-~86: Ensure spelling is correct
Context: ...pipefail) to the pr-check-test-files.sh script ### Changed - Renamed the GitHub notify te...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
CHANGELOG.md (1)
86-86: CHANGELOG entry accurately describes the PR changes.This entry correctly captures both the technical docstring additions and the hardening (
set -euo pipefail) applied to the script..github/scripts/pr-check-test-files.sh (1)
2-2: Excellent addition of strict error handling.The
set -euo pipefaildirective correctly implements the required safety measures per coding guidelines, ensuring the script:
- Exits immediately on errors (
-e)- Fails on undefined variable expansion (
-u)- Propagates failures in pipelines (
-o pipefail)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/scripts/pr-check-test-files.shCHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
🪛 LanguageTool
CHANGELOG.md
[grammar] ~92-~92: Ensure spelling is correct
Context: ...pipefail) to the pr-check-test-files.sh script ### Changed - Added global review instructi...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
CHANGELOG.md (1)
92-92: LGTM! Accurate changelog entry.This entry correctly describes the changes made in this PR: adding technical docstrings and the
set -euo pipefaildirective to the pr-check-test-files.sh script..github/scripts/pr-check-test-files.sh (2)
2-3: Excellent! Critical safety requirement addressed.The addition of
set -euo pipefailfollows the coding guidelines for.github/scripts/**/*.shand ensures the script will:
- Exit on error (
-e)- Fail on unset variable expansion (
-u)- Propagate pipeline failures (
-o pipefail)This hardening prevents silent failures in CI and aligns with production-grade script standards.
4-36: Outstanding documentation! Comprehensive and well-structured.The technical docstring provides excellent coverage of the script's purpose, logic, types, parameters, dependencies, permissions, and return values. This significantly improves maintainability and helps contributors understand the script's behavior.
3a124b9 to
429bb14
Compare
|
Everything looks great now! Just one minor thing to match our standard format: please add the issue number to the end of your changelog entry. |
|
You can see how the other entries are formatted for reference here:https://github.com/hiero-ledger/hiero-sdk-python/blob/main/CHANGELOG.md |
|
Once that's added, we are all set to merge! Great job. |
|
Thanks for the guidance @Akshat8510! I've updated the changelog.md to include the issue number. Everything should be in order now and ready for merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/scripts/pr-check-test-files.shCHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (1)
.github/scripts/**/*.sh
⚙️ CodeRabbit configuration file
.github/scripts/**/*.sh: Treat shell scripts as production-grade automation.Scripts should be small, focused, and explicit.
Avoid “do-everything” or overly generic scripts.
- MUST use:
set -euo pipefail- MUST validate all required environment variables
- MUST defensively quote variables
- MUST validate all untrusted input
- MUST have bounded loops and pagination
- MUST support dry-run mode if state is mutated
- MUST log key decisions and early exits
Files:
.github/scripts/pr-check-test-files.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
.github/scripts/pr-check-test-files.sh (1)
2-2: Excellent addition of strict error handling.The
set -euo pipefaildirective satisfies the coding guidelines requirement for shell scripts and will cause the script to exit immediately on undefined variables, command failures, or pipe failures.As per coding guidelines, this is a required hardening measure for production-grade automation scripts.
Signed-off-by: Dominiq Barbero <[email protected]>
Akshat8510
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! Thanks for your contribution
|
Thanks for the review and the help with the formatting @Akshat8510. Happy to contribute! |
|
Everything is closed nicely inside hashes |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1390 +/- ##
=======================================
Coverage 92.44% 92.44%
=======================================
Files 139 139
Lines 8528 8528
=======================================
Hits 7884 7884
Misses 644 644 🚀 New features to boost your workflow:
|
|
Thank you so much for the kind words @exploreriii! and thank you for your assistance resolving the changelog.md issue I was having @Akshat8510! I'm really glad the extra information in the docstrings is helpful. I wanted to make sure it was as clear as possible for the next person stepping in. I'd definitely love to keep the momentum going! I'm getting comfortable with the standards, so if you have any other issues in a similar vein, whether it's more documentation, script hardening, or repo maintenance, please let me know. I'd love to help standardize more of the project as I continue to "level up"! |
|
Of course! Thanks so much |
|
Thanks for the suggestions @exploreriii! both of those look like great next steps to continue building on what I learned in the last PR. I'll start with "Edit.giuthubs/scripts/bit-office-hours.sh to avoid posting on pull requests by bots". I'll head over to that issue now to request assignment and get started. Looking forward to it! |
Description:
Related issue(s):
Fixes # 1336
Notes for reviewer:
The docstring was verified to ensure it doesn't interfere with the script's execution. The commit is GPG-signed and includes the DCO sign-off. Appreciated the deep dive into this logic!
Checklist