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

Prepend v to trimmedVersion #160

Merged
merged 1 commit into from
Feb 18, 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
7 changes: 6 additions & 1 deletion hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function run_test {

bin/hydrophone \
--output-dir ${ARTIFACTS}/results/ \
--conformance-image registry.k8s.io/conformance:${K8S_VERSION} \
--focus "${FOCUS}" \
--skip "${SKIP}" \
$EXTRA_ARGS| tee /tmp/test.log
Expand Down Expand Up @@ -99,6 +98,7 @@ DRYRUN=${DRYRUN:-"false"}
CONFORMANCE=${CONFORMANCE:-"false"}
EXTRA_ARGS=${EXTRA_ARGS:-""}
CHECK_DURATION=${CHECK_DURATION:-"false"}
SET_VERSION=${SET_VERSION:-"false"}

# Set the artifacts directory, defaulting to a local subdirectory
export ARTIFACTS="${ARTIFACTS:-${PWD}/_artifacts}"
Expand All @@ -114,5 +114,10 @@ if [[ ${CONFORMANCE} == "true" ]]; then
FOCUS="\\[Conformance\\]"
fi

# If SET_VERSION is set, set the K8S_VERSION to the value of SET_VERSION
if [[ ${SET_VERSION} == "true" ]]; then
EXTRA_ARGS="${EXTRA_ARGS} --conformance-image registry.k8s.io/conformance:${K8S_VERSION}"
fi

setup_kind
run_test
5 changes: 3 additions & 2 deletions pkg/common/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func trimVersion(version string) (string, error) {

parsedVersion, err := semver.Parse(version)
if err != nil {
return "", err
return "", fmt.Errorf("error parsing conformance image tag: %v", err)
}
return parsedVersion.FinalizeVersion(), nil

return "v" + parsedVersion.FinalizeVersion(), nil
}
34 changes: 31 additions & 3 deletions pkg/common/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,52 @@ func TestTrimVersion(t *testing.T) {
name string
version string
expectedVersion string
expectErr bool
}{
{
name: "stable version",
version: "v1.28.6",
expectedVersion: "1.28.6",
expectedVersion: "v1.28.6",
},
{
name: "pre released version",
version: "v1.28.6+0fb426",
expectedVersion: "1.28.6",
expectedVersion: "v1.28.6",
},
{
name: "pre released version with build metadata",
version: "v1.28.6+0fb426.20220304",
expectedVersion: "v1.28.6",
},
{
name: "invalid version",
version: "v1.28,0",
expectedVersion: "",
expectErr: true,
},
{
name: "short version",
version: "v1.28",
expectedVersion: "",
expectErr: true,
},
{
name: "no v prefix",
version: "1.28.6",
expectedVersion: "v1.28.6",
},
}

// Run the test cases
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
trimmedVersion, _ := trimVersion(tc.version)
trimmedVersion, err := trimVersion(tc.version)
assert.Equal(t, tc.expectedVersion, trimmedVersion)
if tc.expectErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
}