Repository navigation
refactor: simplify cleanup workflow, deduplicate shell scripts, and add unit test suite - #1
Open
getdownandcode wants to merge 2 commits into
Open
getdownandcode wants to merge 2 commits into
getdownandcode wants to merge 2 commits into
Conversation
…, and add unit test suite - scripts/cleanup.py: Consolidate 5 duplicated cleanup loops into a single run_cleanup processor and generator scanners, reducing ~140 lines of boilerplate while preserving all CLI flags, Prometheus metrics, and S3 logging - scripts/bootstrap_s3.sh & s3-sync.sh: Eliminate duplicated bucket resolution and streamline region argument handling using concise parameter expansion - Jenkinsfile: Streamline Apply stage shell parameter expansion and add unit test discovery to Lint stage - tests/test_cleanup.py: Add 16 automated unit tests covering MemoryLogHandler, tag filters, age calculations, resource scanners, and metric exports
Owner
Author
🤖 Automated PR Review: #1 - refactor: simplify cleanup workflow, deduplicate shell scripts, and add unit test suite1. Summary of Changes
2. Analysis & Key Highlights
3. Actionable Suggestions & Concerns
4. Merge StatusVerdict: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR simplifies and streamlines the Infra-Guard codebase by eliminating repetitive boilerplate across the core Python script and shell utilities, without changing any existing features, CLI flags, Prometheus metric names, or AWS behaviors.
Key Improvements
1. Unified Cleanup Engine (
scripts/cleanup.py)ebs,elastic_ips,instances,snapshots,security_groups) duplicated tag checks, skip evaluations,apply_actioncalls, and counter tracking across 150+ lines.run_cleanupengine. Each resource scanner is now a lightweight generator that yields(resource_id, description, action_callable, tags):2. Deduplicated Shell Scripts (
scripts/bootstrap_s3.sh&scripts/s3-sync.sh)if/elsebucket resolution with concise Bash parameter expansion:3. Declarative Jenkinsfile (
Jenkinsfile)Applystage shell command using native environment variable expansion, eliminating Groovy script blocks.Lintstage.4. Automated Unit Test Suite (
tests/test_cleanup.py)Verification & Test Output
All tests and syntax checks pass: