Skip to content

Commit

Permalink
Generalize supported branches for K8 patches (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
zafs23 authored Jan 9, 2024
1 parent f70553a commit 2991cd1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions templater/jobs/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var releaseBranches = []string{
"1-29",
}

var k8releaseBranches = []string{
"1-23",
}

var golangVersions = []string{
"1-19",
"1-20",
Expand Down Expand Up @@ -123,19 +127,25 @@ 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, "|"),
})

// 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
}
}
Expand Down
6 changes: 3 additions & 3 deletions templater/scripts/verify-prowjobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 2991cd1

Please sign in to comment.