🧪 Improve snap-mem.py tests and fix Lint CI#271
Conversation
- Consolidate snap-mem tests into Cachyos/Scripts/WIP/test_snap_mem.py - Add test cases for build_base_name (whitespace, invalid dates) - Add test cases for make_unique_name (collisions, empty sets) - Fix CI failure by implementing missing lint-format.sh script - Apply project-wide formatting via lint-format.sh Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new local linting and formatting script, lint-format.sh, to automate checks for shell scripts, Python, YAML, and GitHub Actions. It also adds new unit tests to test_snap_mem.py and applies minor markdown formatting and spacing updates across various documentation files. The feedback on lint-format.sh highlights performance optimization opportunities in alignment with the repository's style guide. Specifically, it recommends using batch execution (-X or --exec-batch) instead of individual execution (-x) for fd commands running shfmt, shellcheck, and prettier to minimize process spawning overhead, as well as batching file processing in the fallback loop.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -x shfmt "${OPTS[@]}" | ||
| fi | ||
| has shellcheck && "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -x shellcheck --severity=style |
There was a problem hiding this comment.
⚡ Performance & Style Guide Alignment
Using -x (or --exec) with fd executes the command individually for each found file, which spawns a new process per file. According to the repository style guide (under Performance / Bash Optimization), batch operations with a single fork are highly preferred over multiple forks.
Since shfmt and shellcheck both accept multiple file arguments, we can use -X (or --exec-batch) instead of -x. This executes the tool once with all found files appended as arguments, significantly reducing process spawning overhead and ensuring all files are processed/reported before any potential exit on error.
Approach A: Individual execution (-x)
❌ Con: Spawns a process per file (slow)
❌ Con: Aborts on the first failure due to set -e before checking other files
Approach B: Batch execution (-X)
✅ Pro: Spawns a single process (extremely fast)
✅ Pro: Runs on all files and reports all errors at once
Recommendation: Use -X ∵ Aligns with the repository's performance guidelines.
| "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -x shfmt "${OPTS[@]}" | |
| fi | |
| has shellcheck && "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -x shellcheck --severity=style | |
| "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -X shfmt "${OPTS[@]}" | |
| fi | |
| has shellcheck && "$FD" -t f -e sh --exclude "WIP" --exclude ".github/agents" -X shellcheck --severity=style |
References
- Batch operations with a single fork are preferred over multiple forks to optimize hot paths and minimize external calls. (link)
| while IFS= read -r f; do | ||
| [[ $f == *"WIP"* || $f == *".github/agents"* ]] && continue | ||
| has shfmt && ( [[ $CHECK -eq 0 ]] && shfmt -i 2 -bn -ci -s -ln bash -w "$f" || shfmt -i 2 -bn -ci -s -ln bash -d "$f" ) | ||
| has shellcheck && shellcheck --severity=style "$f" | ||
| done < <(find . -type f -name "*.sh") |
There was a problem hiding this comment.
⚡ Performance & Style Guide Alignment
The fallback path currently loops over each file and runs shfmt and shellcheck individually, which spawns multiple processes (multiple forks). This violates the repository's performance guidelines.
We can collect the files into a Bash array and run shfmt and shellcheck in a single batch invocation. This is much faster and aligns with the repository standards.
| while IFS= read -r f; do | |
| [[ $f == *"WIP"* || $f == *".github/agents"* ]] && continue | |
| has shfmt && ( [[ $CHECK -eq 0 ]] && shfmt -i 2 -bn -ci -s -ln bash -w "$f" || shfmt -i 2 -bn -ci -s -ln bash -d "$f" ) | |
| has shellcheck && shellcheck --severity=style "$f" | |
| done < <(find . -type f -name "*.sh") | |
| local -a files=() | |
| while IFS= read -r f; do | |
| [[ $f == *"WIP"* || $f == *".github/agents"* ]] && continue | |
| files+=("$f") | |
| done < <(find . -type f -name "*.sh") | |
| if (( ${#files[@]} > 0 )); then | |
| if has shfmt; then | |
| if [[ $CHECK -eq 0 ]]; then | |
| shfmt -i 2 -bn -ci -s -ln bash -w "${files[@]}" | |
| else | |
| shfmt -i 2 -bn -ci -s -ln bash -d "${files[@]}" | |
| fi | |
| fi | |
| has shellcheck && shellcheck --severity=style "${files[@]}" | |
| fi |
References
- Batch operations over loops should be used where possible to minimize external command costs. (link)
| log "🎨 Formatting with Prettier..." | ||
| P_OPTS=$([[ $CHECK -eq 1 ]] && echo "--check" || echo "--write") | ||
| if [[ -n "$FD" ]]; then | ||
| "$FD" -t f -e md -e json -e yml -e yaml --exclude "WIP" --exclude ".github/agents" -x prettier "$P_OPTS" |
There was a problem hiding this comment.
⚡ Performance & Style Guide Alignment
Similarly, running prettier individually for each file via -x incurs significant Node.js startup overhead (~100-200ms per file). Batching the files with -X will run prettier once with all found files, resulting in a massive speedup.
Recommendation: Use -X ∵ Minimizes Node.js process spawning overhead.
| "$FD" -t f -e md -e json -e yml -e yaml --exclude "WIP" --exclude ".github/agents" -x prettier "$P_OPTS" | |
| "$FD" -t f -e md -e json -e yml -e yaml --exclude "WIP" --exclude ".github/agents" -X prettier "$P_OPTS" |
References
- Batch operations with a single fork are preferred over multiple forks to optimize hot paths and minimize external calls. (link)
This PR addresses both the testing gap for
snap-mem.pyand a critical CI failure.🎯 What:
snap-mem.py.lint-format.shscript.📊 Coverage:
build_base_name: Added tests for leap years, year boundaries, invalid formats, empty strings, whitespace, and logical errors.make_unique_name: Unified tests and added cases for multiple collisions and initial empty sets.lint-format.shimplementation matchingAGENTS.mdspecs.✨ Result:
snap-mem.pyutility functions.PR created automatically by Jules for task 7498783618997399508 started by @Ven0m0