From 601dda0b8edeb65f042cb4c726724b76d9673672 Mon Sep 17 00:00:00 2001 From: Sajia Zafreen Date: Fri, 22 Dec 2023 13:05:21 -0800 Subject: [PATCH] Generalize supported branches for K8 patches --- templater/jobs/utils/utils.go | 18 ++++++++++++++---- templater/scripts/verify-prowjobs.sh | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/templater/jobs/utils/utils.go b/templater/jobs/utils/utils.go index 2505e2c58..7570b8feb 100644 --- a/templater/jobs/utils/utils.go +++ b/templater/jobs/utils/utils.go @@ -22,6 +22,10 @@ var releaseBranches = []string{ "1-29", } +var k8releaseBranches = []string{ + "1-23", +} + var golangVersions = []string{ "1-19", "1-20", @@ -123,11 +127,17 @@ func AddReleaseBranch(fileName string, data map[string]interface{}) map[string]m if !strings.Contains(fileName, "1-X") { return jobList } + currentReleaseBranches := releaseBranches + + if strings.Contains(fileName, "kubernetes") && !strings.Contains(fileName, "release") { + currentReleaseBranches = append(k8releaseBranches, releaseBranches...) + } + + for i, releaseBranch := range currentReleaseBranches { - for i, releaseBranch := range releaseBranches { releaseBranchBasedFileName := strings.ReplaceAll(fileName, "1-X", releaseBranch) - otherReleaseBranches := append(append([]string{}, releaseBranches[:i]...), - releaseBranches[i+1:]...) + otherReleaseBranches := append(append([]string{}, currentReleaseBranches[:i]...), + currentReleaseBranches[i+1:]...) jobList[releaseBranchBasedFileName] = AppendMap(data, map[string]interface{}{ "releaseBranch": releaseBranch, "otherReleaseBranches": strings.Join(otherReleaseBranches, "|"), @@ -135,7 +145,7 @@ func AddReleaseBranch(fileName string, data map[string]interface{}) map[string]m // If latest release branch, check if the release branch dir exists before executing cmd // This allows us to experiment with adding prow jobs for new branches without failing other runs - if len(releaseBranches)-1 == i { + if len(currentReleaseBranches)-1 == i { jobList[releaseBranchBasedFileName]["latestReleaseBranch"] = true } } diff --git a/templater/scripts/verify-prowjobs.sh b/templater/scripts/verify-prowjobs.sh index 749ef5626..0e6abb504 100755 --- a/templater/scripts/verify-prowjobs.sh +++ b/templater/scripts/verify-prowjobs.sh @@ -6,10 +6,10 @@ set -o pipefail REPO_ROOT=$(git rev-parse --show-toplevel) -DIFF_LINE_COUNT=$(git diff --name-only $REPO_ROOT/jobs ':(exclude,top)*-1-23-*' | wc -l) +DIFF_LINE_COUNT=$(git diff --name-only $REPO_ROOT/jobs | wc -l) if [ $DIFF_LINE_COUNT -ne 0 ]; then - CHANGED_FILES=$(git diff --name-only $REPO_ROOT/jobs ':(exclude,top)*-1-23-*') - git diff $REPO_ROOT/jobs ':(exclude,top)*-1-23-*' + CHANGED_FILES=$(git diff --name-only $REPO_ROOT/jobs) + git diff $REPO_ROOT/jobs echo "\n❌ Detected discrepancies between generated and expected Prowjobs!" echo "The following generated files need to be checked in:\n" echo "${CHANGED_FILES}\n" | tr ' ' '\n'