Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize supported branches for K8 patches #581

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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