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

fix, botreview, image_bump: skip hunks if no image config changes found #3118

Merged
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
19 changes: 17 additions & 2 deletions external-plugins/botreview/review/image_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ I found suspicious hunks:
)

var (
prowJobImageUpdateHunkBodyMatcher = regexp.MustCompile(`(?m)^(-[\s]+- image: [^\s]+$[\n]^\+[\s]+- image: [^\s]+|-[\s]+image: [^\s]+$[\n]^\+[\s]+image: [^\s]+)$`)
prowJobReleaseBranchFileNameMatcher = regexp.MustCompile(`.*\/[\w-]+-[0-9-\.]+\.yaml`)
prowJobImageUpdateLineMatcher = regexp.MustCompile(`(?m)^\+\s+- image: \S+$`)
prowJobImageUpdateHunkBodyMatcher = regexp.MustCompile(`(?m)^(-\s+- image: \S+$\n^\+\s+- image: \S+|-\s+image: \S+$\n^\+\s+image: \S+)$`)
prowJobReleaseBranchFileNameMatcher = regexp.MustCompile(`.*/[\w-]+-[0-9-.]+\.yaml`)
)

type ProwJobImageUpdateResult struct {
Expand Down Expand Up @@ -106,13 +107,27 @@ func (t *ProwJobImageUpdate) AddIfRelevant(fileDiff *diff.FileDiff) {
// * where the path is not beyond the jobconfig path
// * where the name changed and
// * who are not yaml
// * who match the release branch file name pattern
if strings.TrimPrefix(fileDiff.OrigName, "a/") != fileName ||
!strings.HasSuffix(fileName, ".yaml") ||
!strings.HasPrefix(fileName, "github/ci/prow-deploy/files/jobs") ||
prowJobReleaseBranchFileNameMatcher.MatchString(fileName) {
return
}

// do a quick scan for image changes in hunks
foundImageUpdate := false
for _, hunk := range fileDiff.Hunks {
if prowJobImageUpdateLineMatcher.Match(hunk.Body) {
foundImageUpdate = true
break
}
}
// skip diff if none found
if !foundImageUpdate {
return
}

t.relevantFileDiffs = append(t.relevantFileDiffs, fileDiff)
}

Expand Down
8 changes: 6 additions & 2 deletions external-plugins/botreview/review/image_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func TestProwJobImageUpdate_AddIfRelevant(t1 *testing.T) {
NewName: "b/github/ci/prow-deploy/files/jobs/kubevirt/kubevirt/kubevirt-presubmits.yaml",
NewTime: nil,
Extended: nil,
Hunks: nil,
Hunks: []*diff.Hunk{
{Body: []byte("+ - image: quay.io/kubevirtci/bootstrap:v20220110-c066ff5")},
},
},
},
expectedRelevantFileDiffs: []*diff.FileDiff{
Expand All @@ -140,7 +142,9 @@ func TestProwJobImageUpdate_AddIfRelevant(t1 *testing.T) {
NewName: "b/github/ci/prow-deploy/files/jobs/kubevirt/kubevirt/kubevirt-presubmits.yaml",
NewTime: nil,
Extended: nil,
Hunks: nil,
Hunks: []*diff.Hunk{
{Body: []byte("+ - image: quay.io/kubevirtci/bootstrap:v20220110-c066ff5")},
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion external-plugins/botreview/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const botReviewCommentPattern = `@%s's review-bot says:

%s

**Note: botreview (kubevirt/project-infra#2448) is a Work In Progress!**
**Note: botreview (kubevirt/project-infra#3100) is a Work In Progress!**
`
const holdPRComment = `Holding this PR for further manual action to occur.

Expand Down
10 changes: 10 additions & 0 deletions external-plugins/botreview/review/review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestGuessReviewTypes(t *testing.T) {
"testdata/simple_bump-prow-job-images_sh.patch1",
"testdata/move_prometheus_stack.patch0",
"testdata/move_prometheus_stack.patch1",
"testdata/cdi_arm_release.patch0",
}
diffFilePathsToDiffs := map[string]*diff.FileDiff{}
for _, diffFile := range diffFilePaths {
Expand Down Expand Up @@ -95,6 +96,15 @@ func TestGuessReviewTypes(t *testing.T) {
},
want: []KindOfChange{},
},
{
name: "non image bump should not yield a change 2",
args: args{
fileDiffs: []*diff.FileDiff{
diffFilePathsToDiffs["testdata/cdi_arm_release.patch0"],
},
},
want: []KindOfChange{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
43 changes: 43 additions & 0 deletions external-plugins/botreview/review/testdata/cdi_arm_release.patch0
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
a/github/ci/prow-deploy/files/jobs/kubevirt/containerized-data-importer/containerized-data-importer-postsubmits.yaml b/github/ci/prow-deploy/files/jobs/kubevirt/containerized-data-importer/containerized-data-importer-postsubmits.yaml
index 3483e309..79798046 100644
--- a/github/ci/prow-deploy/files/jobs/kubevirt/containerized-data-importer/containerized-data-importer-postsubmits.yaml
+++ b/github/ci/prow-deploy/files/jobs/kubevirt/containerized-data-importer/containerized-data-importer-postsubmits.yaml
@@ -3,7 +3,7 @@ postsubmits:
- name: push-release-containerized-data-importer-images
branches:
- release-v\d+\.\d+
- cluster: kubevirt-prow-control-plane
+ cluster: kubevirt-prow-workloads
always_run: true
optional: false
skip_report: true
@@ -11,13 +11,15 @@ postsubmits:
testgrid-create-test-group: "false"
decorate: true
decoration_config:
- timeout: 1h
+ timeout: 2h
grace_period: 5m
labels:
preset-podman-in-container-enabled: "true"
preset-docker-mirror-proxy: "false"
preset-kubevirtci-quay-credential: "true"
spec:
+ nodeSelector:
+ type: bare-metal-external
containers:
- image: quay.io/kubevirtci/bootstrap:v20231115-51a244f
env:
@@ -29,9 +31,10 @@ postsubmits:
- "-c"
- |
cat "$QUAY_PASSWORD" | docker login --username $(cat "$QUAY_USER") --password-stdin=true quay.io &&
- # Only push images on tags
+ # Only push images on tags, for amd64 and aarch64 (crossbuild, since we have no aarch64 builder)
[ -z "$(git tag --points-at HEAD | head -1)" ] ||
- DOCKER_TAG="$(git tag --points-at HEAD | head -1)" make bazel-push-images
+ DOCKER_TAG="$(git tag --points-at HEAD | head -1)-amd64" make bazel-push-images ||
+ DOCKER_TAG="$(git tag --points-at HEAD | head -1)-arm64" BUILD_ARCH="crossbuild-aarch64" make bazel-push-images
# docker-in-docker needs privileged mode
securityContext:
privileged: true