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

test bumper #11264

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ baseImageOverrides:
github.com/kyma-project/test-infra/cmd/tools/pjtester: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240705-f43bf98f
github.com/kyma-project/test-infra/cmd/markdown-index: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240705-f43bf98f
github.com/kyma-project/test-infra/cmd/image-detector: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240705-f43bf98f
github.com/kyma-project/test-infra/cmd/image-autobumper: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240705-f43bf98f
github.com/kyma-project/test-infra/cmd/external-plugins/automated-approver: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240705-f43bf98f
defaultPlatforms:
- linux/arm64
Expand Down
1 change: 1 addition & 0 deletions .koapps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ apps:
- ko://github.com/kyma-project/test-infra/cmd/cloud-run/cors-proxy
- ko://github.com/kyma-project/test-infra/cmd/external-plugins/automated-approver
- ko://github.com/kyma-project/test-infra/cmd/dashboard-token-proxy
- ko://github.com/kyma-project/test-infra/cmd/image-autobumper
86 changes: 86 additions & 0 deletions cmd/image-autobumper/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package main

import (
"fmt"
"strings"

"github.com/kyma-project/test-infra/pkg/github/bumper"
"github.com/kyma-project/test-infra/pkg/github/imagebumper"
)

// Extract image from image name
func imageFromName(name string) string {
parts := strings.Split(name, ":")
if len(parts) < 2 {
return ""
}
return parts[0]
}

// Extract image tag from image name
func tagFromName(name string) string {
parts := strings.Split(name, ":")
if len(parts) < 2 {
return ""
}
return parts[1]
}

// Extract prow component name from image
func componentFromName(name string) string {
s := strings.SplitN(strings.Split(name, ":")[0], "/", 3)
return s[len(s)-1]
}

func formatTagDate(d string) string {
if len(d) != 8 {
return d
}
// &#x2011; = U+2011 NON-BREAKING HYPHEN, to prevent line wraps.
return fmt.Sprintf("%s&#x2011;%s&#x2011;%s", d[0:4], d[4:6], d[6:8])
}

// commitToRef converts git describe part of a tag to a ref (commit or tag).
//
// v0.0.30-14-gdeadbeef => deadbeef
// v0.0.30 => v0.0.30
// deadbeef => deadbeef
func commitToRef(commit string) string {
tag, _, commit := imagebumper.DeconstructCommit(commit)
if commit != "" {
return commit
}
return tag
}

// Format variant for PR summary
func formatVariant(variant string) string {
if variant == "" {
return ""
}
return fmt.Sprintf("(%s)", strings.TrimPrefix(variant, "-"))
}

// Check whether the path is under the given path
func isUnderPath(name string, paths []string) bool {
for _, p := range paths {
if p != "" && strings.HasPrefix(name, p) {
return true
}
}
return false
}

// isBumpedPrefix takes a prefix and a map of new tags resulted from bumping
// : the images using those tags and iterates over the map to find if the
// prefix is found. If it is, this means it has been bumped.
func isBumpedPrefix(prefix bumper.Prefix, versions map[string][]string) (string, bool) {
for tag, imageList := range versions {
for _, image := range imageList {
if strings.HasPrefix(image, prefix.Prefix) {
return tag, true
}
}
}
return "", false
}
Loading
Loading