Skip to content

Commit f25a582

Browse files
motatoessubstrate-botclaude
authored
Add digger:force label to bypass impacted projects limit (#2549)
* Auto-succeed digger/apply check when plan shows zero changes This change implements automatic success for the digger/apply check when all plan jobs complete with zero infrastructure changes, eliminating the need for manual intervention in no-change scenarios. Changes: - Create both digger/plan and digger/apply checks when PR opens with plan jobs - The apply check starts in "queued" state with message indicating it will auto-succeed if no changes are detected - After plan batch completes successfully, detect if all jobs have zero changes (ResourcesCreated = 0, ResourcesUpdated = 0, ResourcesDeleted = 0) - If all jobs have zero changes, automatically update apply check to "completed" with "success" conclusion - Add GetCheckRunsForCommit() method to query check runs for a commit SHA Benefits: - Improved UX: Users see both checks immediately when PR opens - Automation: No manual action needed for zero-change plans - Clear communication: Check messages explain the automatic behavior - No breaking changes: Existing behavior for plans with changes unchanged Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * feat: add digger:force label to bypass impacted projects limit Add support for the 'digger:force' label on pull requests to bypass the ImpactedProjectsPerChange limit. This allows users to intentionally proceed with plan/apply operations on PRs that impact more projects than the configured limit. Changes: - Check for 'digger:force' label in both PR and comment event handlers - Update error messages to inform users about the bypass option - Add warning logs when limit is bypassed for audit purposes - Add slices import to github_comment.go for label checking Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: substrate-bot <bot@substrate.run> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 88d866b commit f25a582

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

backend/controllers/github_comment.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log/slog"
77
"os"
88
"runtime/debug"
9+
"slices"
910
"strconv"
1011
"strings"
1112

@@ -359,14 +360,15 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
359360
}
360361

361362
maxImpactedProjectsPerChange := config2.MaxImpactedProjectsPerChange()
362-
if len(impactedProjectsForComment) > maxImpactedProjectsPerChange {
363+
hasForceLabel := slices.Contains(prLabelsStr, "digger:force")
364+
if len(impactedProjectsForComment) > maxImpactedProjectsPerChange && !hasForceLabel {
363365
slog.Error("Number of impacted projects exceeds number of changed files",
364366
"prNumber", issueNumber,
365367
"impactedProjectCount", len(impactedProjectsForComment),
366368
"changedFileCount", len(changedFiles),
367369
)
368370

369-
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error the number impacted projects %v exceeds Max allowed ImpactedProjectsPerChange: %v, we set this limit to protect against hitting github API limits", len(impactedProjectsForComment), maxImpactedProjectsPerChange))
371+
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error the number impacted projects %v exceeds Max allowed ImpactedProjectsPerChange: %v, we set this limit to protect against hitting github API limits. Add the 'digger:force' label to bypass this limit.", len(impactedProjectsForComment), maxImpactedProjectsPerChange))
370372

371373
slog.Debug("Detailed event information",
372374
slog.Group("details",
@@ -378,6 +380,14 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
378380
return fmt.Errorf("error processing event")
379381
}
380382

383+
if hasForceLabel && len(impactedProjectsForComment) > maxImpactedProjectsPerChange {
384+
slog.Warn("Bypassing impacted projects limit due to digger:force label",
385+
"prNumber", issueNumber,
386+
"impactedProjectCount", len(impactedProjectsForComment),
387+
"maxAllowed", maxImpactedProjectsPerChange,
388+
)
389+
}
390+
381391
if !config.AllowDraftPRs && isDraft {
382392
slog.Info("Draft PRs are disabled, skipping",
383393
"issueNumber", issueNumber,

backend/controllers/github_pull_request.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,15 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
261261
}
262262

263263
maxImpactedProjectsPerChange := config2.MaxImpactedProjectsPerChange()
264-
if len(impactedProjects) > maxImpactedProjectsPerChange {
264+
hasForceLabel := slices.Contains(prLabelsStr, "digger:force")
265+
if len(impactedProjects) > maxImpactedProjectsPerChange && !hasForceLabel {
265266
slog.Error("Number of impacted projects exceeds number of changed files",
266267
"prNumber", prNumber,
267268
"impactedProjectCount", len(impactedProjects),
268269
"changedFileCount", len(changedFiles),
269270
)
270271

271-
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error the number impacted projects %v exceeds Max allowed ImpactedProjectsPerChange: %v, we set this limit to protect against hitting github API limits", len(impactedProjects), maxImpactedProjectsPerChange))
272+
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error the number impacted projects %v exceeds Max allowed ImpactedProjectsPerChange: %v, we set this limit to protect against hitting github API limits. Add the 'digger:force' label to bypass this limit.", len(impactedProjects), maxImpactedProjectsPerChange))
272273

273274
slog.Debug("Detailed event information",
274275
slog.Group("details",
@@ -280,6 +281,14 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
280281
return fmt.Errorf("error processing event")
281282
}
282283

284+
if hasForceLabel && len(impactedProjects) > maxImpactedProjectsPerChange {
285+
slog.Warn("Bypassing impacted projects limit due to digger:force label",
286+
"prNumber", prNumber,
287+
"impactedProjectCount", len(impactedProjects),
288+
"maxAllowed", maxImpactedProjectsPerChange,
289+
)
290+
}
291+
283292
diggerCommand, err := scheduler.GetCommandFromJob(jobsForImpactedProjects[0])
284293
if err != nil {
285294
slog.Error("Could not determine Digger command from job",

0 commit comments

Comments
 (0)