Repository navigation
Conversation
gate.py reads Infracost JSON output and fails when the monthly increase exceeds a USD cap or a percent cap of the base total (both at zero is comment-only; decreases never fail; a zero base with an increase counts as exceeded for the percent rule). It writes a one-line gate statement for the PR comment and step summary, warns when usage-based resources have no usage file, and sets outputs. docs/cost-gate.md fixes the semantics, the recommended thresholds per repository class, the exception path and the infracost-usage.yml rules; docs/examples/infracost-usage.yml is the starter file. CI runs the gate against sample JSON. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPH9145e4gFo6bmXvMgBoF
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.
Closes #91. From
main; #89 (theinfracostcomposite's install, breakdown, diff and comment modes pluscost-diff-tofu.yml) stacks on this.What
.github/actions/infracost/gate.py(stdlib): readstotalMonthlyCost,pastTotalMonthlyCost,diffTotalMonthlyCostandsummary.totalUsageBasedResources.--max-monthly-increasefails on a positive delta above the USD cap;--max-percent-increasefails when the delta over the base total exceeds the cap (a $0 base with an increase counts as exceeded); both at 0 is comment-only; decreases never fail. Writes the gate line for the PR comment (--snippet) and the step summary, warns when usage-based resources exist and no usage file is given or found, and setsmonthly-diff,monthly-total,percent-change,threshold,gate. Exit 1 on a failed gate, 2 on a missing file.docs/cost-gate.md: threshold semantics, recommended values (client infra 200 USD / 10 %, internal 100 USD / 25 %, sandboxes comment-only), exception path through the docs: findings — finding-to-SLA mapping and exception template #81security-exceptionform, and the fourinfracost-usage.ymlrules.docs/examples/infracost-usage.yml: starter with commented entries for S3, data transfer, Lambda, DynamoDB on-demand, CloudWatch logs and NAT gateway.Cost Gatejob running the fixtures.Tests
tests/infracost/run.shon sample Infracost JSON (increase, decrease, zero base, no change): comment-only outputs and snippet, USD cap pass and fail, percent cap pass and fail, both caps, decreases with tight caps, zero base under each cap, usage warning present, absent and missing-file, exit codes.🤖 Generated with Claude Code
https://claude.ai/code/session_01NPH9145e4gFo6bmXvMgBoF