-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add go-changelog support #33
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{{- if index .NotesByType "breaking-change" -}} | ||
BREAKING CHANGES: | ||
|
||
{{range index .NotesByType "breaking-change" -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.security }} | ||
SECURITY: | ||
|
||
{{range .NotesByType.security -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.deprecation -}} | ||
DEPRECATIONS: | ||
|
||
{{range .NotesByType.deprecation -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.feature }} | ||
FEATURES: | ||
|
||
{{range .NotesByType.feature -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.improvement }} | ||
IMPROVEMENTS: | ||
|
||
{{range .NotesByType.improvement -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.bug }} | ||
BUG FIXES: | ||
|
||
{{range .NotesByType.bug -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.note -}} | ||
NOTES: | ||
|
||
{{range .NotesByType.note -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- define "note" -}} | ||
{{.Body}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/hcp/issues/{{- .Issue -}})] | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
breaking-change | ||
security | ||
deprecation | ||
feature | ||
improvement | ||
bug | ||
note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### Changes proposed in this PR: | ||
|
||
### How I've tested this PR: | ||
|
||
### How I expect reviewers to test this PR: | ||
|
||
<!-- If you are adding a new command or editing an existing one, please provide | ||
an example of the command being invoked. | ||
### Output of affected commands: | ||
--> | ||
|
||
### Checklist: | ||
- [ ] Tests added | ||
- [ ] CHANGELOG entry added | ||
> Run `make changelog-entry` for guidance in authoring a changelog entry, and | ||
> commit the resulting file, which should have a name matching your PR number. | ||
> Entries should use imperative present tense (e.g. Add support for...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
set -euo pipefail | ||
|
||
# check if there is a diff in the .changelog directory | ||
# for PRs against the main branch, the changelog file name should match the PR number | ||
if [ "$GITHUB_BASE_REF" = "$GITHUB_DEFAULT_BRANCH" ]; then | ||
enforce_matching_pull_request_number="matching this PR number " | ||
changelog_file_path=".changelog/(_)?$PR_NUMBER.txt" | ||
else | ||
changelog_file_path=".changelog/[_0-9]*.txt" | ||
fi | ||
|
||
changelog_files=$(git --no-pager diff --name-only HEAD "$(git merge-base HEAD "origin/main")" | egrep "${changelog_file_path}") | ||
|
||
# If we do not find a file in .changelog/, we fail the check | ||
if [ -z "$changelog_files" ]; then | ||
# Fail status check when no .changelog entry was found on the PR | ||
echo "Did not find a .changelog entry ${enforce_matching_pull_request_number}and the 'pr/no-changelog' label was not applied." | ||
exit 1 | ||
fi | ||
|
||
# Validate format with make changelog-check, exit with error if any note has an | ||
# invalid format | ||
for file in $changelog_files; do | ||
if ! cat $file | make changelog/check; then | ||
echo "Found a changelog entry ${enforce_matching_pull_request_number}but the note format in ${file} was invalid." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Found valid changelog entry!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow checks that there is either a 'pr/no-changelog' label applied to a PR | ||
# or there is a .changelog/<pr number>.txt file associated with a PR for a changelog entry | ||
|
||
name: Changelog Checker | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, labeled] | ||
# Runs on PRs to main and all release branches | ||
branches: | ||
- main | ||
- release/* | ||
|
||
jobs: | ||
# checks that a .changelog entry is present for a PR | ||
changelog-check: | ||
# If there a `pr/no-changelog` label we ignore this check. | ||
if: "! ( contains(github.event.pull_request.labels.*.name, 'pr/no-changelog')" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 # by default the checkout action doesn't checkout all branches | ||
- name: Check for changelog entry in diff | ||
run: ./.github/scripts/changelog_checker.sh | ||
env: | ||
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }} | ||
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should the checklist also include a checkmark for "Regenerated screenshot (if new top-level command was added)"?
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.
Do you think it is worth it given how rare it will be relative to all the expected PRs?
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 there is no reminder it will very likely be forgotten. Having the check-list entry could be a chance to remember it. But maybe it makes more sense to add a comment to here.