Skip to content

fix(action): post the comment before enforcing budget gates - #102

Merged
andreacappelletti97 merged 1 commit into
mainfrom
fix/action-gates-after-comment
Sep 29, 2026
Merged

andreacappelletti97 merged 1 commit into
mainfrom
fix/action-gates-after-comment

Conversation

@andreacappelletti97

Copy link
Copy Markdown
Contributor

Found while building the c3x-demo showcase.

Bugs

  1. Breaking a budget gate skipped the comment. The Estimate step ran with --budget (and a budget in the repo's .c3x.toml applies there too), and the Budget delta gate ran before the PR comment step. Either one failed the job first, so the pull requests that most needed a comment got none. The demo had to call the Action twice to work around it.
  2. currency was ignored in comments. Only the Estimate step's log used it. Comments and the base-branch baseline were always USD.
  3. The gate message said $+2781.48/mo.

Fix

  • When a comment will be posted, the Estimate step passes --budget 0 and no --strict.
  • Step order is now: Estimate → baseline → PR comment → Budget delta gate → Budget gate (new; applies the input or the .c3x.toml budget). strict was already enforced by the comment step after posting.
  • On pushes (no comment), gating is unchanged.
  • The delta gate now also runs without the input, so a budget_delta in .c3x.toml is enforced. The input is only passed when set, because passing 0 would disable the config value.
  • currency is passed as --currency to the baseline and gates, and as C3X_CURRENCY to the comment step (it has no --currency flag). It's exported only when set.
  • Empty-array expansion is written to be safe under set -u in bash 3.2 (macOS runners).

Tested

c3x-demo#17 ran c3xdev/c3x@fix/action-gates-after-comment on the GPU-cluster change with budget-delta: "500" and currency: EUR, in a single step:

Step Result
Estimate success (not gated)
Baseline success (EUR)
PR comment success, posted by c3x-cloud[bot]: Monthly cost increased by €2449.56 (+249.0%)
Budget delta gate failed: delta exceeds gate — €+2449.56/mo > €+500.00/mo (the released binary; this PR fixes the sign)
Budget gate skipped (the job had already failed)

The budget and budget-delta gates (and a budget in .c3x.toml) ran before
the PR comment step and failed the job first, so a pull request that
broke a gate got no comment. When a comment will be posted, the Estimate
step no longer gates; the comment is posted, then the budget-delta and
budget gates run. Pushes, with no comment, gate as before.

The currency input now reaches the comment and the baseline through
C3X_CURRENCY and --currency. The delta gate message puts the sign before
the currency symbol.
@andreacappelletti97
andreacappelletti97 merged commit 4f32729 into main Sep 29, 2026
6 checks passed
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