Skip to content

feat: add status for plan/apply to commits - #941

Open
DjinnS wants to merge 12 commits into
mainfrom
feat/commit_statuses_v2
Open

feat: add status for plan/apply to commits#941
DjinnS wants to merge 12 commits into
mainfrom
feat/commit_statuses_v2

Conversation

@DjinnS

@DjinnS DjinnS commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@github-project-automation github-project-automation Bot moved this to 📋 Backlog in Burrito Jul 10, 2026
@DjinnS

DjinnS commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author
image image image

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 49.07652% with 193 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.79%. Comparing base (68f576a) to head (9bc6987).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/controllers/terraformpullrequest/layer.go 0.00% 43 Missing ⚠️
...nal/controllers/terraformpullrequest/conditions.go 23.40% 35 Missing and 1 partial ⚠️
...nternal/controllers/terraformpullrequest/states.go 27.08% 30 Missing and 5 partials ⚠️
internal/webhook/event/pullrequest.go 0.00% 17 Missing ⚠️
.../controllers/terraformpullrequest/comment/apply.go 0.00% 14 Missing ⚠️
internal/repository/providers/github/api.go 71.87% 5 Missing and 4 partials ⚠️
internal/repository/providers/gitlab/api.go 76.31% 5 Missing and 4 partials ⚠️
internal/controllers/manager.go 0.00% 7 Missing ⚠️
internal/repository/providers/mock/mock.go 0.00% 5 Missing ⚠️
internal/controllers/commitstatus/commitstatus.go 91.11% 2 Missing and 2 partials ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   47.62%   47.79%   +0.17%     
==========================================
  Files          99      102       +3     
  Lines        6163     6532     +369     
==========================================
+ Hits         2935     3122     +187     
- Misses       3022     3185     +163     
- Partials      206      225      +19     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DjinnS
DjinnS force-pushed the feat/commit_statuses_v2 branch 3 times, most recently from 1d24fd3 to 47cbbe1 Compare July 10, 2026 15:45
DjinnS and others added 2 commits July 10, 2026 18:20
Adds two related improvements to the pull request lifecycle:

- Post a comment on the pull/merge request once Burrito applies the
  merged changes, reporting success or failure per affected layer
  (internal/controllers/terraformpullrequest/comment/apply.go). The
  TerraformPullRequest resource is kept alive after merge (annotated
  with the merge date instead of being deleted) so its controller can
  track layer applies and post that comment once they complete.

- Report plan and apply status via the GitHub Commit Statuses API and
  GitLab External Commit Statuses (internal/controllers/terraformpullrequest/status,
  APIProvider.SetStatus in the github/gitlab/mock providers). The
  status is set to pending when a phase starts and updated to
  success/failure based on the actual outcome:
  - plan: pending when temp layers are created, success/failure once
    the comment is posted, based on whether every layer produced a
    plan.
  - apply: pending while waiting for the merged layers to apply,
    success/failure once they all have, based on LastApplyDate vs a
    failed TerraformRun created after the merge.

Status updates are best-effort and never fail the reconciliation loop.
…anch

Commits pushed straight to a repository's base branch never go through a
TerraformPullRequest, so no plan/apply commit status was ever posted for
them. The terraformrun controller now posts one itself when a run's layer
isn't pull-request-managed, disambiguated per layer since there's no PR to
aggregate multiple layers under a single status context.
@DjinnS
DjinnS force-pushed the feat/commit_statuses_v2 branch from a21eab3 to 3c10a6e Compare July 10, 2026 16:23
@corrieriluca corrieriluca linked an issue Jul 17, 2026 that may be closed by this pull request
4 tasks
@corrieriluca corrieriluca moved this from 📋 Backlog to 🏗 In progress in Burrito Jul 17, 2026
Guillaume Leccese and others added 9 commits July 17, 2026 16:31
… whole run lifecycle

Commit statuses were only ever posted once plan/apply had already finished, and
aggregated across all layers on a pull request (or not posted at all on a
direct push). Every layer now gets its own status as soon as a run is
decided (pending: needed), when its pod starts (pending: in progress), and
on completion (success/failure) — for both pull-request-managed and
base-branch layers alike. The now-redundant PR-level aggregate statuses and
merge-commit resolution are removed.
…sult

The description now mirrors the layer's "Last Result" field (the short
plan/apply summary, or a placeholder like "Layer has never been planned")
instead of repeating the phase/outcome already carried by the native
pending/success/failure state and the context. Truncated to GitHub's
140-character limit, with no emoji (GitHub rejects 4-byte UTF-8 there).
Adds a "Details" link on plan/apply commit statuses pointing at the
matching layer/run logs page, gated behind a new server.publicUrl config
value (defaults to empty, which omits the link entirely).
…ding

GitLab's commit status is a real state machine (pending -> running ->
success/failed) and rejects posting "pending" twice in a row with a 400
("Cannot transition status via :enqueue from :pending") — which is exactly
what happened once a run's pod started right after it was decided. GitHub
has no such restriction and no "running" state, so its provider folds the
new state back into "pending".
Retrying a validation error (422) or a provider-side cap (e.g. "maximum
number of statuses reached") three times with backoff was pure waste — it
would never succeed. Only retry on what's actually transient: 5xx, 429, or
a plain network failure with no HTTP response at all. Logging moves into
commitstatus.Post itself, with a message that says whether the failure was
given up on immediately or only after exhausting retries, replacing the
generic "Error while setting commit status" logged by each provider.
apply always wrote a hardcoded "Apply Successful" as its short result,
unlike plan which summarizes the diff ("Plan: X to create, Y to update,
Z to delete"). Reuse the same summary, computed from the JSON plan
artifact that was actually applied, falling back to the old placeholder
when that artifact is missing or unparseable.
…e Details link

The dashboard's hide-PR-layers filter defaults to on. Following a commit
status's "Details" link without hidepr=false could land on a filtered-out,
empty layer list.
Fixes GHSA-hrxh-6v49-42gf (gRPC-Go xDS RBAC and HTTP/2 vulnerabilities),
flagged by the Trivy vulnerability scan.
@DjinnS

DjinnS commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Tests

Github

PR

image

Details link show the layer in Burrito

Merge

image

Gitlab

MR

image

The job send to Burrito and show the layer

image

(same as Github)

Merge

image

It posts to a repository provider (GitHub/GitLab), so it belongs next to
providers/, credentials/ and types/ rather than under internal/controllers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Feature: GitHub/GitLab Status Notification

2 participants