-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Add validation for PREVIOUS_RELEASE_TAG in release-notes-tool #12380
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
base: main
Are you sure you want to change the base?
🌱 Add validation for PREVIOUS_RELEASE_TAG in release-notes-tool #12380
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@chandankumar4 |
80ce3de
to
a36f7cf
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments. PTAL.
hack/tools/release/notes/main.go
Outdated
preReleaseRC = "rc" | ||
preReleaseBeta = "beta" | ||
preReleaseAlpha = "alpha" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preReleaseRC = "rc" | |
preReleaseBeta = "beta" | |
preReleaseAlpha = "alpha" | |
preReleaseAlpha = "alpha" | |
preReleaseBeta = "beta" | |
preReleaseRC = "rc" |
hack/tools/release/notes/main.go
Outdated
|
||
versionStr := parts[1] | ||
|
||
// Parse the version to check if it contains rc, beta, or alpha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Parse the version to check if it contains rc, beta, or alpha | |
// Parse the version to check if it contains alpha, beta, or rc |
hack/tools/release/notes/main.go
Outdated
func validatePreviousReleaseVersion(previousReleaseVersion string) error { | ||
// Extract version string from ref format (e.g., "tags/v1.0.0-rc.1" -> "v1.0.0-rc.1") | ||
if !strings.Contains(previousReleaseVersion, "/") { | ||
return errors.New("--previous-release-version must be in ref format (e.g., tags/v1.0.0-rc.1)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.New("--previous-release-version must be in ref format (e.g., tags/v1.0.0-rc.1)") | |
return errors.New("--previous-release-version must be in ref format (e.g. tags/v1.0.0-rc.1)") |
Same with other error messages.
hack/tools/release/notes/main.go
Outdated
|
||
// Check if the version has pre-release identifiers | ||
if len(version.Pre) == 0 { | ||
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseRC, preReleaseBeta, preReleaseAlpha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseRC, preReleaseBeta, preReleaseAlpha) | |
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", , preReleaseAlpha, preReleaseBeta, preReleaseRC) |
hack/tools/release/notes/main.go
Outdated
// Check if the first pre-release identifier is 'rc', 'beta', or 'alpha' | ||
preReleaseType := version.Pre[0].VersionStr | ||
if preReleaseType != preReleaseRC && preReleaseType != preReleaseBeta && preReleaseType != preReleaseAlpha { | ||
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseRC, preReleaseBeta, preReleaseAlpha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseRC, preReleaseBeta, preReleaseAlpha) | |
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseAlpha, preReleaseBeta, preReleaseRC) |
hack/tools/release/notes/main.go
Outdated
return errors.Errorf("--previous-release-version must contain '%s', '%s', or '%s' pre-release identifier", preReleaseRC, preReleaseBeta, preReleaseAlpha) | ||
} | ||
|
||
// Check if the first pre-release identifier is 'rc', 'beta', or 'alpha' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Check if the first pre-release identifier is 'rc', 'beta', or 'alpha' | |
// Check if the first pre-release identifier is 'alpha', 'beta', or 'rc' |
if err == nil { | ||
t.Errorf("expected error '%s', got no error", tt.errorMessage) | ||
} else if !strings.Contains(err.Error(), tt.errorMessage) { | ||
t.Errorf("expected error to contain '%s', got '%v'", tt.errorMessage, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err == nil { | |
t.Errorf("expected error '%s', got no error", tt.errorMessage) | |
} else if !strings.Contains(err.Error(), tt.errorMessage) { | |
t.Errorf("expected error to contain '%s', got '%v'", tt.errorMessage, err) | |
if err == nil || !strings.Contains(err.Error(), tt.errorMessage) { | |
t.Errorf("expected error '%s', got %v", tt.errorMessage, err) | |
} |
a36f7cf
to
d74021f
Compare
Validate that PREVIOUS_RELEASE_TAG uses proper ref format and contains alpha, beta, or rc pre-release identifier. Co-authored-by: sivchari <[email protected]>
d74021f
to
51a6c70
Compare
/lgtm |
LGTM label has been added. Git tree hash: 73279cb64ee7f62263e788e108c8a03acd45214b
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign @chandankumar4
}, | ||
wantErr: true, | ||
errorMessage: "invalid --previous-release-version, is not a valid semver", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to add test case for beta
version as well
New changes are detected. LGTM label has been removed. |
What this PR does / why we need it:
Add a validation logic for
make release-notes
✅ Now Accepts:
❌ Now Rejects:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #12278
/area release