Skip to content

Commit 63b569f

Browse files
jflowersclaude
andcommitted
ci: retire main's classic protection for safe-settings' ruleset
main's required checks ("CI OK", "Standardized CI / Run linters") now live in unbound-force/.github's safe-settings (repos/replicator.yml), without the up-to-date rule. protection: null has the Settings app remove the classic branch protection, whose strict: true left every open PR behind after each auto-merge. The org code-repos ruleset still requires the code owner's approval. The settings test now checks that the classic protection is retired, rather than pinning the checks that moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 005c9eb commit 63b569f

2 files changed

Lines changed: 15 additions & 43 deletions

File tree

‎.github/settings.yml‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@ _extends: .github
33
repository:
44
has_wiki: true
55

6+
# main's protection lives in unbound-force/.github's safe-settings
7+
# (repos/replicator.yml: "CI OK" and "Standardized CI / Run linters",
8+
# not strict; the org code-repos ruleset requires the code owner's
9+
# approval). protection: null has the Settings app remove the classic
10+
# branch protection, whose strict: true left every open PR behind after
11+
# each auto-merge.
612
branches:
713
- name: main
8-
protection:
9-
required_pull_request_reviews:
10-
required_approving_review_count: 1
11-
dismiss_stale_reviews: true
12-
require_code_owner_reviews: true
13-
dismissal_restrictions:
14-
users: []
15-
teams: []
16-
required_status_checks:
17-
strict: true
18-
contexts:
19-
# Aggregate job from ci.yml that always reports, even when
20-
# build-and-test is skipped (issue #182, CLS-FR-003).
21-
- "CI OK"
22-
# Never gated: secret scanning and PR title validation run on
23-
# every PR (CLS-FR-002). Confirmed by PR 101's Standardized CI
24-
# run at the pinned org-infra SHA.
25-
- "Standardized CI / Run linters"
26-
enforce_admins: false
27-
required_linear_history: false
28-
restrictions: null
14+
protection: null

‎internal/workflowtest/ci_gating_test.go‎

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ func TestCIGatingWorkflows_StandardizedCIIsNeverGated(t *testing.T) {
123123
}
124124
}
125125

126-
func TestCIGatingSettings_RequiredContextsAreAggregates(t *testing.T) {
126+
// main's required checks moved to unbound-force/.github's safe-settings
127+
// (repos/replicator.yml). The Settings app must remove the classic branch
128+
// protection, not set it again: its strict rule left every open PR behind
129+
// after each auto-merge.
130+
func TestCIGatingSettings_ClassicProtectionRetired(t *testing.T) {
127131
settings := readRepositoryFile(t, ".github", "settings.yml")
128-
checks := yamlSection(t, settings, "required_status_checks", 6)
129-
contexts := yamlSection(t, checks, "contexts", 8)
130-
got := yamlListItems(t, contexts, 10)
131-
sort.Strings(got)
132-
want := []string{"CI OK", "Standardized CI / Run linters"}
133-
if strings.Join(got, ",") != strings.Join(want, ",") {
134-
t.Errorf("required_status_checks.contexts = %v, want exactly %v", got, want)
132+
assertMatches(t, settings, `(?m)^ - name: main\n protection: null\s*$`, "main's classic protection set to null")
133+
if strings.Contains(settings, "required_status_checks") {
134+
t.Error("settings.yml must not set required_status_checks; they live in safe-settings")
135135
}
136136
}
137137

@@ -163,20 +163,6 @@ func needsJobs(t *testing.T, job, jobID string) []string {
163163
return needs
164164
}
165165

166-
func yamlListItems(t *testing.T, section string, indentation int) []string {
167-
t.Helper()
168-
pattern := regexp.MustCompile(fmt.Sprintf(`(?m)^ {%d}- (.+)$`, indentation))
169-
matches := pattern.FindAllStringSubmatch(section, -1)
170-
if len(matches) == 0 {
171-
t.Fatalf("YAML section has no list items at indentation %d", indentation)
172-
}
173-
items := make([]string, 0, len(matches))
174-
for _, match := range matches {
175-
items = append(items, strings.Trim(strings.TrimSpace(match[1]), `"'`))
176-
}
177-
return items
178-
}
179-
180166
// TestCIGatingWorkflows_DetectionScriptBehavior runs the changes job's
181167
// script against real pull request merge commits, so the learnings rule
182168
// is pinned by execution, not only by the text checks above.

0 commit comments

Comments
 (0)