Skip to content

Commit 320c5f1

Browse files
committed
generator: add validation of subprojects
specifically: - only sigs+committees can have subprojects - subprojects need at least one owners entry - owners should be raw github links I think the last one could/should change, but: - I'm about to auto-generate links assuming this format, so I want to verify I can assume all owners are in this format - I am not quite sure if we should treat sigs.yaml as public api and give notice/deprecation for field changes
1 parent 6687a08 commit 320c5f1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

generator/app.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func (c *Context) Sort() {
246246
func (c *Context) Validate() []error {
247247
errors := []error{}
248248
people := make(map[string]Person)
249+
rawGitHubURL := regexp.MustCompile(regexRawGitHubURL)
249250
for prefix, groups := range c.PrefixToGroupMap() {
250251
for _, group := range groups {
251252
expectedDir := group.DirName(prefix)
@@ -294,6 +295,21 @@ func (c *Context) Validate() []error {
294295
errors = append(errors, fmt.Errorf("%s: has no subprojects", group.Dir))
295296
}
296297
}
298+
if prefix != "committee" && prefix != "sig" {
299+
if len(group.Subprojects) > 0 {
300+
errors = append(errors, fmt.Errorf("%s: only sigs and committees can own code / have subprojects, found: %v", group.Dir, group.Subprojects))
301+
}
302+
}
303+
for _, subproject := range group.Subprojects {
304+
if len(subproject.Owners) == 0 {
305+
errors = append(errors, fmt.Errorf("%s/%s: subproject has no owners", group.Dir, subproject.Name))
306+
}
307+
for _, ownerURL := range subproject.Owners {
308+
if !rawGitHubURL.MatchString(ownerURL) {
309+
errors = append(errors, fmt.Errorf("%s/%s: subproject owners should match regexp %s, found: %s", group.Dir, subproject.Name, regexRawGitHubURL, ownerURL))
310+
}
311+
}
312+
}
297313
}
298314
}
299315
return errors

generator/testdata/sigs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ sigs:
66
mission_statement: covers foo
77
subprojects:
88
- name: sub-foo
9+
owners:
10+
- "https://raw.githubusercontent.com/org/foo/main/OWNERS"
911
- dir: sig-bar
1012
name: Bar
1113
label: bar
1214
charter_link: charter-bar
1315
mission_statement: owns areas related to bar
1416
subprojects:
1517
- name: sub-bar
18+
owners:
19+
- "https://raw.githubusercontent.com/org/bar/main/test/OWNERS"
1620
workinggroups:
1721
- dir: wg-baz
1822
name: Baz

0 commit comments

Comments
 (0)