Skip to content

Add command for checking stale image updates, refactor python utils - #363

Merged
bubacoder merged 1 commit into
mainfrom
stale-images
Jul 4, 2026
Merged

Add command for checking stale image updates, refactor python utils#363
bubacoder merged 1 commit into
mainfrom
stale-images

Conversation

@bubacoder

@bubacoder bubacoder commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a new report for identifying older Docker image references in compose files, with sorting, filtering, and row limits.
    • Enhanced service export and docs update workflows to use the updated script layout.
  • Bug Fixes

    • Improved detection of image reference locations so reports can include more accurate source-line tracking.
    • Updated script imports and paths for more reliable runtime execution.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@bubacoder, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 03b1f534-0f7e-4a6f-9859-786066170fff

📥 Commits

Reviewing files that changed from the base of the PR and between eadfed2 and 620ebcc.

📒 Files selected for processing (10)
  • docs/ai/ai-agents.md
  • docs/web/Taskfile.web.yaml
  • docs/web/git_utils.py
  • docs/web/update-docs.py
  • scripts/check-stale-images.py
  • scripts/export-services.py
  • scripts/utils/__init__.py
  • scripts/utils/compose_processor.py
  • scripts/utils/docker_scanner.py
  • scripts/utils/git_utils.py

Walkthrough

Git and Docker Compose utility modules were relocated into scripts/utils, with dependent scripts and the docs Taskfile updated to reference the new import paths. Compose processing gained image reference extraction with line numbers. A new CLI script, check-stale-images.py, reports image ages based on git blame history.

Changes

Shared utils relocation and stale image tooling

Layer / File(s) Summary
New shared git utilities module
scripts/utils/git_utils.py, docs/web/git_utils.py
New module provides GitExecutableNotFoundError, NotInGitRepositoryError, get_line_last_changed() (via git blame --porcelain), and get_git_root(); the old duplicate module in docs/web is removed.
Compose image reference extraction and scanner import fix
scripts/utils/compose_processor.py, scripts/utils/docker_scanner.py
ComposeFileProcessor gains extract_image_references() and _find_image_line() to locate per-service image lines with line numbers; docker_scanner.py switches to a relative import.
Rewire consumer scripts and Taskfile to new utils paths
scripts/export-services.py, docs/web/update-docs.py, docs/web/Taskfile.web.yaml
Import paths updated to utils.docker_scanner/utils.git_utils, sys.path adjusted, and the Taskfile's create-service-list task now runs scripts/export-services.py.
New check-stale-images CLI
scripts/check-stale-images.py
Adds a new script with ImageEntry dataclass, logger setup, compose scanning/entry collection, age calculation, tabular report printing, and CLI argument parsing.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • bubacoder/infra#153: Both PRs modify docs/web/update-docs.py around the same git/docker utility import surface.
  • bubacoder/infra#236: Both PRs touch the create-service-list task wiring in docs/web/Taskfile.web.yaml involving export-services.py.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main addition of a stale image checking command and the related Python utility refactor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stale-images

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.

@bubacoder

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
scripts/check-stale-images.py (2)

135-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor: repeated datetime.now(tz=UTC) calls in sort key.

The sort key calls datetime.now(tz=UTC) once per uncommitted entry rather than a single reference timestamp, giving each None entry a slightly different "now" value. This has negligible practical impact but a single computed timestamp would be more deterministic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-stale-images.py` at line 135, The sort key in the entries
ordering uses datetime.now(tz=UTC) repeatedly for each None last_changed value,
which makes the fallback timestamp vary slightly across items. Update the logic
around the entries sort to compute one UTC “now” timestamp once before sorting,
then reuse that single value in the key function so all uncommitted entries
share the same deterministic fallback.

190-192: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the configured logger instead of the module-level logging.exception.

logging.exception(...) logs against the root logger, not the logger configured via configure_logger. In --verbose mode this bypasses the custom formatter/handler attached to logger, producing inconsistently formatted error output compared to the rest of the script's logging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-stale-images.py` around lines 190 - 192, The exception handler
in the stale image report flow is logging through the root logger instead of the
configured logger. Update the except block in the stale image reporting path to
use the existing logger created by configure_logger, so the error goes through
the same formatter and handlers as the rest of the script. Keep the same error
message in the report-generation error path, but route it via logger rather than
logging.exception.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/check-stale-images.py`:
- Around line 183-192: The repository path resolution in the stale-images script
bypasses the existing error handler because `get_git_root()` is called before
the `try` block. Move the `repository_path = args.repository_path or
Path(get_git_root())` logic inside the `main` flow’s `try` section so
`GitExecutableNotFoundError` and `NotInGitRepositoryError` from `get_git_root()`
are caught and routed through the existing `logging.exception("Error generating
stale image report")` and `sys.exit(1)` path, alongside the rest of
`collect_image_entries` and `print_report`.
- Around line 37-59: The non-verbose path in configure_logger() sets the logger
to INFO but never attaches any handler, so INFO messages are dropped by the
default logging flow. Update configure_logger() so both branches configure an
output handler (or rely on a shared root handler) and ensure the non-verbose
branch still emits INFO-level logs, while preserving the existing DEBUG
formatter/handler behavior for verbose mode. Reference configure_logger() and
its verbose=False branch when making the change.

---

Nitpick comments:
In `@scripts/check-stale-images.py`:
- Line 135: The sort key in the entries ordering uses datetime.now(tz=UTC)
repeatedly for each None last_changed value, which makes the fallback timestamp
vary slightly across items. Update the logic around the entries sort to compute
one UTC “now” timestamp once before sorting, then reuse that single value in the
key function so all uncommitted entries share the same deterministic fallback.
- Around line 190-192: The exception handler in the stale image report flow is
logging through the root logger instead of the configured logger. Update the
except block in the stale image reporting path to use the existing logger
created by configure_logger, so the error goes through the same formatter and
handlers as the rest of the script. Keep the same error message in the
report-generation error path, but route it via logger rather than
logging.exception.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7be5058d-6a2b-4aad-b1da-d496eb6d25ca

📥 Commits

Reviewing files that changed from the base of the PR and between c2fc501 and eadfed2.

📒 Files selected for processing (10)
  • docs/ai/ai-agents.md
  • docs/web/Taskfile.web.yaml
  • docs/web/git_utils.py
  • docs/web/update-docs.py
  • scripts/check-stale-images.py
  • scripts/export-services.py
  • scripts/utils/__init__.py
  • scripts/utils/compose_processor.py
  • scripts/utils/docker_scanner.py
  • scripts/utils/git_utils.py
💤 Files with no reviewable changes (1)
  • docs/web/git_utils.py

Comment thread scripts/check-stale-images.py Outdated
Comment thread scripts/check-stale-images.py Outdated
@bubacoder
bubacoder merged commit 3d99d15 into main Jul 4, 2026
4 checks passed
@bubacoder
bubacoder deleted the stale-images branch July 4, 2026 12:55
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