forgejo: report digger/apply as green when the plan is empty #3

Merged
simlau merged 2 commits from simlau/empty-plan-apply-status into main 2026-10-23 07:59:03 +00:00
Member

Branch protection on levior repos requires digger/plan and digger/apply. digger/apply only comes from a digger apply comment, which Forgejo runs from the default branch's workflow. So a new repo's first PR (levior/openbao #1: main has no digger workflow yet) can never get it, and PRs with nothing to apply need a pointless apply.

After a successful plan that covers every impacted project, and when every plan is strictly empty, Digger now also sets digger/apply = success ("nothing to apply: the plan is empty"). No auto-merge in that case; a person merges.

"Strictly empty" is read from tofu show -json: every resource change is no-op (or read for data sources) with no importing and no previous_address, and every output change is no-op. Imports, moves, forgets and output changes count as something to apply. Unparseable JSON, a project without a plan result, or no results count as not empty.

RunJobs keeps its signature (RunJobsWithResults beside it); the github and spec paths are untouched.

Opened by simlau@gmail.com with levior pr create.

Branch protection on levior repos requires digger/plan and digger/apply. digger/apply only comes from a `digger apply` comment, which Forgejo runs from the default branch's workflow. So a new repo's first PR (levior/openbao #1: main has no digger workflow yet) can never get it, and PRs with nothing to apply need a pointless apply. After a successful plan that covers every impacted project, and when every plan is strictly empty, Digger now also sets digger/apply = success ("nothing to apply: the plan is empty"). No auto-merge in that case; a person merges. "Strictly empty" is read from `tofu show -json`: every resource change is no-op (or read for data sources) with no importing and no previous_address, and every output change is no-op. Imports, moves, forgets and output changes count as something to apply. Unparseable JSON, a project without a plan result, or no results count as not empty. RunJobs keeps its signature (RunJobsWithResults beside it); the github and spec paths are untouched. Opened by simlau@gmail.com with `levior pr create`.
When a plan run covers all impacted projects and every plan has no
resource changes, also set digger/apply to success. Branch protection
requires digger/apply, which otherwise only a `digger apply` comment sets.
That comment cannot bootstrap a new repo: Forgejo runs issue_comment
workflows from the default branch, which has no digger workflow yet, so
the first PR could never be merged. Plans run on pull_request events from
the PR branch, so setting the status at plan time fixes this and spares
docs-only PRs a pointless apply.

Auto-merge is unchanged. Adds RunJobsWithResults (RunJobs wraps it) and
ForgejoService.SetStatusWithDescription.
forgejo: count imports, moves and output changes as something to apply
All checks were successful
release / test (pull_request) Successful in 1m10s
release / release (pull_request) Has been skipped
release / test (push) Successful in 49s
release / release (push) Successful in 1m33s
78b37f520f
AllPlansEmpty relied on the created/updated/deleted summary, which is 0/0/0
for plans that only change outputs, import, move or forget resources.
Applying those still changes state, so digger/apply must not turn green.
Decide emptiness strictly from the plan JSON (IsTerraformPlanStrictlyEmpty)
and carry it as DiggerExecutorPlanResult.IsEmpty. Unparseable JSON counts as
non-empty.
simlau merged commit 78b37f520f into main 2026-10-23 07:59:03 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
levior/digger!3
No description provided.