-
Notifications
You must be signed in to change notification settings - Fork 167
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
chore: Adjusts check-changelog-entry-file to verify the entry types our guidelines define #2179
Conversation
…ur guidelines define
@@ -76,3 +100,21 @@ func skipLabel(labels []string) bool { | |||
} | |||
return false | |||
} | |||
|
|||
func getValidTypes(path string) []string { | |||
file, err := os.Open(path) |
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.
knit: i think it's a bit easier to read a file with ReadFile, e.g. above:
https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/tools/check-changelog-entry-file/main.go#L33
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.
and I think later you can get the lines, e.g. with: lines := strings.Split(content, "\n")
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.
thanks for the suggestion, simplified the function 👍
fmt.Printf("Changelog entry file is valid: %s\n", filePath) | ||
} | ||
|
||
func isValidType(t string) bool { |
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.
knit: a bit confusing this short variable names but i guess you got them as it is
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.
renamed to make more clear
skipTitles = []string{"chore", "test", "doc", "ci"} // Dependabot uses chore. | ||
skipLabelName = "skip-changelog-check" | ||
skipTitles = []string{"chore", "test", "doc", "ci"} // Dependabot uses chore. | ||
allowedTypeValues = getValidTypes("scripts/changelog/allowed-types.txt") |
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.
nice to have the values in a common place
@@ -53,12 +55,34 @@ func validateChangelog(filePath, body string) { | |||
entry := changelog.Entry{ | |||
Body: body, | |||
} | |||
if err := entry.Validate(); err != nil { | |||
log.Fatalf("Error validating changelog file: %s, err: %v", filePath, err) | |||
notes := changelog.NotesFromEntry(entry) |
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.
knit: it might be worth it to have a comment pointing to the original code so we don't forget to check from time to time to see if they made it more extensible and can use it
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.
added a small comment giving this context
Our allowed entry types a subset of the hardcoded go-changelog entry.Validate() types. Do we expect our allowed entry types to be different than those? (more entry types than the ones hardcoded) |
Description
Link to any related issue(s): CLOUDP-244157
Our
check-changelog-entry-file
script was currently delegating the validation logic completely to go-changelog entry.Validate(), but this does have to downside that its allowed types are hardcoded and not configurable (hashicorp/go-changelog#6). The hardcoded values are not fully aligned with our allowed entry types.This PR extracts the validation logic and ensures that we verify our allowed entry types.
Testing
2024/04/19 12:50:26 Error validating changelog file: .changelog/3000.txt. Unknown changelog types [other], please use only the configured changelog entry types [breaking-change new-resource new-datasource new-guide note enhancement bug]
new-guide
type (this was throwing an error before the changes):Changelog entry file is valid: .changelog/3000.txt
Type of change:
Required Checklist:
Further comments