fix: improve move and remove count parsing in plan parser#32
Open
fix: improve move and remove count parsing in plan parser#32
Conversation
Fix remove count detection: the old code looked for the banner text "Some objects will no longer be managed by Terraform" which is absent in newer Terraform output formats. Now counts per-resource comments containing "will no longer be managed by Terraform" directly. Fix grep error handling: replace '|| true' pattern with set +e/set -e blocks and explicit exit code checks (0=match, 1=no match, 2+=error). This ensures '?' is returned on unexpected errors instead of silently reporting 0.
eaa4579 to
b824892
Compare
Add a clickable '🔗 Job Logs' link below the validation table in PR comments, pointing to the GitHub Actions job logs for the current run. Uses job.check_run_id to resolve the correct job URL per matrix combination without requiring API calls.
Extract inline bash from action.yml into step_parse_plan_output.sh following the action implementation guide conventions.
Fix grep operating on file content variable via echo which caused "Argument list too long" on large plan files. grep now operates directly on the plan file.
Use more specific pattern for removed resource counting ("# .* will no longer be managed by Terraform") to exclude summary warning lines that inflated the count.
Add test data files with plan output for various scenarios: no changes, adds/changes/destroys, moves, and removed resources. Add run_all_tests.sh with 6 test cases covering all test data files plus edge cases (empty path, empty file). Add run_local_step_parse_plan_output.sh for manual debugging.
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.
Summary
Fixes the
parse-terraform-planaction failing to count removed resources, outputting?instead of the correct count.Changes
Fix remove count detection
The old code looked for the banner text
"Some objects will no longer be managed by Terraform"which is absent in newer Terraform output formats. The new approach counts per-resource comment lines containing"will no longer be managed by Terraform"directly, which works across all Terraform versions.Fix grep error handling
Replaced the
|| truepattern withset +e/set -eblocks and explicit exit code checks (grep -cexits 0 on match, 1 on no match, 2+ on error). This ensures?is properly returned on unexpected errors instead of silently reporting0.