-
Notifications
You must be signed in to change notification settings - Fork 598
ci: Allow release note enrichment when "closes" is present #5398
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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 hidden or 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 hidden or 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,120 @@ | ||
| package main | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestExtractCommitSHA(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| input string | ||
| expectedSHA string | ||
| }{ | ||
| { | ||
| name: "commit link at end of line", | ||
| input: "* HTTP/2 is no longer always disabled in loki.write ([#5267](https://github.com/grafana/alloy/issues/5267)) ([1c97c2d](https://github.com/grafana/alloy/commit/1c97c2d569fcda2f6761534150b063d1404dc388))", | ||
| expectedSHA: "1c97c2d", | ||
| }, | ||
| { | ||
| name: "commit link with closes reference after", | ||
| input: "* Invalid handling of `id` in `foreach` when using discovery components ([#5322](https://github.com/grafana/alloy/issues/5322)) ([61fe184](https://github.com/grafana/alloy/commit/61fe1845d3b109992cbb0ec99a062ac113c1a411)), closes [#5297](https://github.com/grafana/alloy/issues/5297)", | ||
| expectedSHA: "61fe184", | ||
| }, | ||
| { | ||
| name: "commit link with extra notes after", | ||
| input: "* Some fix ([deadbeef](https://github.com/grafana/alloy/commit/deadbeef)) - extra notes here", | ||
| expectedSHA: "deadbeef", | ||
| }, | ||
| { | ||
| name: "full 40-character SHA", | ||
| input: "* Fix bug ([abc1234567890def1234567890abc1234567890](https://github.com/grafana/alloy/commit/abc1234567890def1234567890abc1234567890))", | ||
| expectedSHA: "abc1234567890def1234567890abc1234567890", | ||
| }, | ||
| { | ||
| name: "no parens around link", | ||
| input: "* No parens [abc1234](https://github.com/grafana/alloy/commit/abc1234)", | ||
| expectedSHA: "", | ||
| }, | ||
| { | ||
| name: "just a PR reference", | ||
| input: "* Just a PR reference (#1234)", | ||
| expectedSHA: "", | ||
| }, | ||
| { | ||
| name: "empty line", | ||
| input: "", | ||
| expectedSHA: "", | ||
| }, | ||
| { | ||
| name: "line with no commit info", | ||
| input: "### Bug Fixes", | ||
| expectedSHA: "", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| sha := extractCommitSHA(tt.input) | ||
| if sha != tt.expectedSHA { | ||
| t.Errorf("extractCommitSHA(%q) = %q, want %q", tt.input, sha, tt.expectedSHA) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestFormatAttribution(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| usernames []string | ||
| expected string | ||
| }{ | ||
| { | ||
| name: "single user", | ||
| usernames: []string{"alice"}, | ||
| expected: "(@alice)", | ||
| }, | ||
| { | ||
| name: "multiple users", | ||
| usernames: []string{"alice", "bob", "charlie"}, | ||
| expected: "(@alice, @bob, @charlie)", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result := formatAttribution(tt.usernames) | ||
| if result != tt.expected { | ||
| t.Errorf("formatAttribution(%v) = %q, want %q", tt.usernames, result, tt.expected) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestDeriveDocTag(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| tag string | ||
| expected string | ||
| }{ | ||
| { | ||
| name: "standard release", | ||
| tag: "v1.15.2", | ||
| expected: "v1.15", | ||
| }, | ||
| { | ||
| name: "release candidate", | ||
| tag: "v1.2.3-rc.0", | ||
| expected: "v1.2", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result, err := deriveDocTag(tt.tag) | ||
| if err != nil { | ||
| t.Fatalf("deriveDocTag(%q) returned error: %v", tt.tag, err) | ||
| } | ||
| if result != tt.expected { | ||
| t.Errorf("deriveDocTag(%q) = %q, want %q", tt.tag, result, tt.expected) | ||
| } | ||
| }) | ||
| } | ||
| } |
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.
the main difference is the absence of
\s*$