Skip to content

🧪 Improve snap-mem.py tests and fix Lint CI#271

Open
Ven0m0 wants to merge 1 commit into
mainfrom
improve-snap-mem-tests-7498783618997399508
Open

🧪 Improve snap-mem.py tests and fix Lint CI#271
Ven0m0 wants to merge 1 commit into
mainfrom
improve-snap-mem-tests-7498783618997399508

Conversation

@Ven0m0

@Ven0m0 Ven0m0 commented Jun 28, 2026

Copy link
Copy Markdown
Owner

This PR addresses both the testing gap for snap-mem.py and a critical CI failure.

🎯 What:

  • Unified and expanded the test suite for snap-mem.py.
  • Fixed the "Check Lint & Format" CI failure by restoring the missing lint-format.sh script.

📊 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.
  • CI: Restored lint-format.sh implementation matching AGENTS.md specs.

Result:

  • Improved reliability and maintainability of snap-mem.py utility functions.
  • Restored CI functionality and ensured codebase compliance with project formatting standards.

PR created automatically by Jules for task 7498783618997399508 started by @Ven0m0

- 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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread lint-format.sh
Comment on lines +29 to +31
"$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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
"$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
  1. Batch operations with a single fork are preferred over multiple forks to optimize hot paths and minimize external calls. (link)

Comment thread lint-format.sh
Comment on lines +33 to +37
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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
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
  1. Batch operations over loops should be used where possible to minimize external command costs. (link)

Comment thread lint-format.sh
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
"$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
  1. Batch operations with a single fork are preferred over multiple forks to optimize hot paths and minimize external calls. (link)

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.

1 participant