Skip to content

Commit 078fb1a

Browse files
generator: Refactor to make github API calls only when needed
Currently, everytime the verify job is run, API calls are made to github to fetch kubernetes release information since verify calls generate first. The issue with this is that everytime this runs in the CI, eventhough we only generate annual reports when ANNUAL_REPORT env is set, the API calls are made and if they are rate limited (since we don't use a token here), the job will fail without a legitamate reason. Signed-off-by: Madhav Jivrajani <[email protected]>
1 parent a3ddfc7 commit 078fb1a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

generator/app.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -999,11 +999,11 @@ func getCategorizedWorkingGroups(dir string) (map[string][]string, error) {
999999
return workingGroupsMap, nil
10001000
}
10011001

1002-
func main() {
1003-
// prep for automated listing of subprojects in the annual report
1002+
// prep for automated listing of subprojects in the annual report
1003+
func prepForAnnualReportGeneration() error {
10041004
intLastYear, err := strconv.Atoi(lastYear())
10051005
if err != nil {
1006-
log.Fatal(err)
1006+
return err
10071007
}
10081008
annualReportYear = time.Date(intLastYear, time.January, 1, 0, 0, 0, 0, time.UTC)
10091009
currentYear = time.Date(intLastYear+1, time.January, 1, 0, 0, 0, 0, time.UTC)
@@ -1015,35 +1015,39 @@ func main() {
10151015
URL: communityRepoURL,
10161016
})
10171017
} else {
1018-
log.Fatal(err)
1018+
return err
10191019
}
10201020
}
10211021

10221022
commitFromAnnualReportYear, err = getCommitByDate(repo, annualReportYear)
10231023
if err != nil {
1024-
log.Fatal(err)
1024+
return err
10251025
}
10261026

10271027
commitFromCurrentYear, err = getCommitByDate(repo, currentYear)
10281028
if err != nil {
1029-
log.Fatal(err)
1029+
return err
10301030
}
10311031

10321032
// fetch KEPs and cache them in the keps variable
10331033
err = fetchKEPs()
10341034
if err != nil {
1035-
log.Fatal(err)
1035+
return err
10361036
}
10371037

10381038
releases, err = getLastThreeK8sReleases()
10391039
if err != nil {
1040-
log.Fatal(err)
1040+
return err
10411041
}
10421042

1043+
return nil
1044+
}
1045+
1046+
func main() {
10431047
yamlPath := filepath.Join(baseGeneratorDir, sigsYamlFile)
10441048
var ctx Context
10451049

1046-
err = readYaml(yamlPath, &ctx)
1050+
err := readYaml(yamlPath, &ctx)
10471051
if err != nil {
10481052
log.Fatal(err)
10491053
}
@@ -1076,6 +1080,9 @@ func main() {
10761080
}
10771081

10781082
if envVal, ok := os.LookupEnv("ANNUAL_REPORT"); ok && envVal == "true" {
1083+
if err := prepForAnnualReportGeneration(); err != nil {
1084+
log.Fatal(err)
1085+
}
10791086
fmt.Println("Generating annual reports")
10801087
for prefix, groups := range ctx.PrefixToGroupMap() {
10811088
err = createAnnualReportIssue(groups, prefix)

0 commit comments

Comments
 (0)