Skip to content

Commit

Permalink
Fix monthly patch output for schedule-builder
Browse files Browse the repository at this point in the history
The output was empty which is now fixed.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Apr 19, 2024
1 parent d6ed17f commit 5bbae9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions cmd/schedule-builder/cmd/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
table.SetAutoWrapText(false)
table.SetHeader([]string{"Monthly Patch Release", "Cherry Pick Deadline", "Target Date"})
for _, upcoming := range patchSchedule.UpcomingReleases {
table.Append([]string{strings.TrimSpace(upcoming.Release), strings.TrimSpace(upcoming.CherryPickDeadline), strings.TrimSpace(upcoming.TargetDate)})
targetDate, err := time.Parse(refDate, upcoming.TargetDate)
if err != nil {
logrus.Errorf("Unable to parse upcoming target date %q: %v", upcoming.TargetDate, err)
continue
}
table.Append([]string{
targetDate.Format(refDateMonthly),
strings.TrimSpace(upcoming.CherryPickDeadline),
strings.TrimSpace(upcoming.TargetDate)},

Check failure on line 56 in cmd/schedule-builder/cmd/markdown.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
)
}
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
Expand Down Expand Up @@ -167,8 +176,12 @@ func processFile(fileName string, vars interface{}) string {
return process(tmpl, vars)
}

const (
refDate = "2006-01-02"
refDateMonthly = "January 2006"
)

func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches EolBranches, filePath, eolFilePath string) error {

Check failure on line 184 in cmd/schedule-builder/cmd/markdown.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)
const refDate = "2006-01-02"

Check failure on line 185 in cmd/schedule-builder/cmd/markdown.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
removeSchedules := []int{}
for i, sched := range schedule.Schedules {
Expand Down Expand Up @@ -270,7 +283,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
continue
}

logrus.Infof("Using existing upcoming release for %s (%s)", upcomingRelease.Release, upcomingRelease.TargetDate)
logrus.Infof("Using existing upcoming release for %s", upcomingRelease.TargetDate)
newUpcomingReleases = append(newUpcomingReleases, upcomingRelease)
latestDate = upcomingTargetDate
}
Expand All @@ -286,7 +299,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches
nextCherryPickDeadline := time.Date(latestDate.Year(), latestDate.Month(), cherryPickDay, 0, 0, 0, 0, time.UTC)
nextTargetDate := time.Date(latestDate.Year(), latestDate.Month(), targetDateDay, 0, 0, 0, 0, time.UTC)

logrus.Infof("Adding new upcoming release for %s", nextTargetDate.Format("January 2006"))
logrus.Infof("Adding new upcoming release for %s", nextTargetDate.Format(refDateMonthly))

newUpcomingReleases = append(newUpcomingReleases, &PatchRelease{
CherryPickDeadline: nextCherryPickDeadline.Format(refDate),
Expand Down
2 changes: 1 addition & 1 deletion cmd/schedule-builder/cmd/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const expectedPatchSchedule = `### Upcoming Monthly Releases
| MONTHLY PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE |
|-----------------------|----------------------|-------------|
| | 2020-06-12 | 2020-06-17 |
| June 2020 | 2020-06-12 | 2020-06-17 |
### Timeline
Expand Down

0 comments on commit 5bbae9f

Please sign in to comment.