Skip to content

Conversation

@MrMadHatt
Copy link
Contributor

@MrMadHatt MrMadHatt commented Jan 7, 2026

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

  • [ x] Documented (Code comments, README, etc.)
  • [ x] Tested (unit, integration, etc.)

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Enabled strict shell options and added ANSI color constants plus expanded header/docstrings in .github/scripts/pr-check-test-files.sh. Updated CHANGELOG.md with an "Unreleased -> Added" entry documenting the script hardening and docstring additions.

Changes

Cohort / File(s) Summary
Script runtime safety & docs
.github/scripts/pr-check-test-files.sh
Added set -euo pipefail; expanded header/docstrings (purpose, logic, params, deps, permissions, return values); introduced ANSI color constants RED, YELLOW, and RESET.
Changelog update
CHANGELOG.md
Added "Unreleased -> Added" entry noting script hardening and technical docstrings; minor content adjustments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: adding a technical docstring to the pr-check-test-files.sh script, which is confirmed by the raw_summary and pr_objectives.
Description check ✅ Passed The PR description is directly related to the changeset, detailing the technical docstring addition, script hardening, CHANGELOG update, and issue fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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/main without validating success. If git diff fails or origin/main doesn'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 ]]; then

Alternatively, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 89afede and 23b2ed0.

📒 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.

Copy link

@coderabbitai coderabbitai bot left a 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 command git diff --name-status origin/main could fail if:

  • Git is not available
  • origin/main branch 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
fi

Note: Once set -euo pipefail is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 23b2ed0 and e7aa7b6.

📒 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

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e7aa7b6 and 405e902.

📒 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.

@exploreriii exploreriii requested a review from a team January 8, 2026 00:53
Copy link
Contributor

@Akshat8510 Akshat8510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update CHANGELOG.md

Copy link

@coderabbitai coderabbitai bot left a 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
fi

Note: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 405e902 and 80aaeff.

📒 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 pipefail directive 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.

@Akshat8510

This comment was marked as resolved.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

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:
docs/sdk_developers/training/workflow/how_to_link_issues.md

If no issue exists yet, please create one:
docs/sdk_developers/creating_issues.md

Thanks!

@Akshat8510

This comment was marked as resolved.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

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:
docs/sdk_developers/training/workflow/how_to_link_issues.md

If no issue exists yet, please create one:
docs/sdk_developers/creating_issues.md

Thanks!

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Hi, this is MergeConflictBot.
Your pull request cannot be merged because it contains merge conflicts.

Please resolve these conflicts locally and push the changes.

To assist you, please read:

Thank you for contributing!

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 80aaeff and 875a654.

📒 Files selected for processing (2)
  • .github/scripts/pr-check-test-files.sh
  • CHANGELOG.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 pipefail directive 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)

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 875a654 and 79e6156.

📒 Files selected for processing (2)
  • .github/scripts/pr-check-test-files.sh
  • CHANGELOG.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 pipefail directive 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 pipefail follows the coding guidelines for .github/scripts/**/*.sh and 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.

@MrMadHatt MrMadHatt force-pushed the main branch 2 times, most recently from 3a124b9 to 429bb14 Compare January 8, 2026 05:41
@Akshat8510
Copy link
Contributor

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.

@Akshat8510
Copy link
Contributor

You can see how the other entries are formatted for reference here:https://github.com/hiero-ledger/hiero-sdk-python/blob/main/CHANGELOG.md

@Akshat8510
Copy link
Contributor

Once that's added, we are all set to merge! Great job.

@MrMadHatt
Copy link
Contributor Author

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!

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 429bb14 and 83a2ba1.

📒 Files selected for processing (2)
  • .github/scripts/pr-check-test-files.sh
  • CHANGELOG.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 pipefail directive 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.

Copy link
Contributor

@Akshat8510 Akshat8510 left a 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

@MrMadHatt
Copy link
Contributor Author

Thanks for the review and the help with the formatting @Akshat8510. Happy to contribute!

@exploreriii
Copy link
Contributor

Everything is closed nicely inside hashes
I really like the useful information you have added
Helps future maintainers and also developers 🥇

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exploreriii exploreriii merged commit 62bdfe7 into hiero-ledger:main Jan 8, 2026
19 checks passed
@MrMadHatt
Copy link
Contributor Author

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"!

@exploreriii
Copy link
Contributor

Of course! Thanks so much
We have a couple of open beginner issues still available that will provide a different challenge:
https://github.com/hiero-ledger/hiero-sdk-python/issues?q=is%3Aissue%20state%3Aopen%20label%3Abeginner%20no%3Aassignee

@MrMadHatt
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants