diff --git a/pkg/notes/notes.go b/pkg/notes/notes.go index 605b7f5ed08..da7ffaa6cac 100644 --- a/pkg/notes/notes.go +++ b/pkg/notes/notes.go @@ -372,6 +372,16 @@ func (g *Gatherer) ListReleaseNotes() (*ReleaseNotes, error) { // may contain the commit message, the PR description, etc. // This is generally the content inside the ```release-note ``` stanza. func noteTextFromString(s string) (string, error) { + // check release note is not empty + // Matches "release-notes" block with no meaningful content (ex. only whitespace, empty, just newlines) + emptyExps := []*regexp.Regexp{ + regexp.MustCompile("(?i)```release-notes?\\s*```\\s*"), + } + + if matchesFilter(s, emptyExps) { + return "", errors.New("empty release note") + } + exps := []*regexp.Regexp{ // (?s) is needed for '.' to be matching on newlines, by default that's disabled // we need to match ungreedy 'U', because after the notes a `docs` block can occur @@ -627,7 +637,7 @@ func (l *commitList) List() []*gogithub.RepositoryCommit { // that do NOT contain release notes. Notably, this is all of the variations of // "release note none" that appear in the commit log. var noteExclusionFilters = []*regexp.Regexp{ - // 'none','n/a','na' case insensitive with optional trailing + // 'none','n/a','na' case-insensitive with optional trailing // whitespace, wrapped in ``` with/without release-note identifier // the 'none','n/a','na' can also optionally be wrapped in quotes ' or " regexp.MustCompile("(?i)```release-notes?\\s*('\")?(none|n/a|na)('\")?\\s*```"), diff --git a/pkg/notes/notes_gatherer_test.go b/pkg/notes/notes_gatherer_test.go index 771b2c7b26c..fe5832f5164 100644 --- a/pkg/notes/notes_gatherer_test.go +++ b/pkg/notes/notes_gatherer_test.go @@ -351,9 +351,11 @@ func TestGatherNotes(t *testing.T) { {pullRequest(9, "release-note /release-note-none", "closed")}, // excluded, the exclusion filters take precedence {pullRequest(10, "```release-note\nNAAAAAAAAAA\n```", "closed")}, // included, does not match the N/A filter, but the 'release-note' check {pullRequest(11, "```release-note\nnone something\n```", "closed")}, // included, does not match the N/A filter, but the 'release-note' check - // empty release note block shouldn't be matched + // empty release note block should skipped because noteTextFromString returns an error {pullRequest(12, "```release-note\n\n```", "closed")}, - {pullRequest(13, "```release-note\n\n```", "open")}, + {pullRequest(13, "```release-note```", "closed")}, + {pullRequest(14, "```release-note ```", "closed")}, + {pullRequest(15, "```release-note\n\n```", "open")}, } var callCount int64 = -1 diff --git a/pkg/notes/notes_test.go b/pkg/notes/notes_test.go index 69c3bb125bc..94b06393104 100644 --- a/pkg/notes/notes_test.go +++ b/pkg/notes/notes_test.go @@ -297,6 +297,16 @@ func TestNoteTextFromString(t *testing.T) { require.Equal(t, "item\nitem\n- item\n item", res) }, }, + { + noteBlock( + "", + ), + func(res string, err error) { + require.NotNil(t, err) + require.Contains(t, err.Error(), "empty release note") + require.Equal(t, "", res) + }, + }, } { tc.expect(noteTextFromString(tc.input)) } @@ -328,25 +338,63 @@ func TestMatchesExcludeFilter(t *testing.T) { shouldExclude: false, }, { - input: `@kubernetes/sig-auth-pr-reviews -/milestone v1.19 -/priority important-longterm -/kind cleanup -/kind deprecation - -xref: #81126 -xref: #81152 -xref: https://github.com/kubernetes/website/pull/19630 - + input: `@kubernetes/sig-auth-pr-reviews + /milestone v1.19 + /priority important-longterm + /kind cleanup + /kind deprecation + + xref: #81126 + xref: #81152 + xref: https://github.com/kubernetes/website/pull/19630 + + ` + mdSep + `release-note + Action Required: Support for basic authentication via the --basic-auth-file flag has been removed. Users should migrate to --token-auth-file for similar functionality. + ` + mdSep + ` + + ` + mdSep + `docs + Removed "Static Password File" section from https://kubernetes.io/docs/reference/access-authn-authz/authentication/#static-password-file + https://github.com/kubernetes/website/pull/19630 + ` + mdSep, + shouldExclude: false, + }, + { + input: ` +#### Does this PR introduce a user-facing change? + ` + mdSep + `release-note -Action Required: Support for basic authentication via the --basic-auth-file flag has been removed. Users should migrate to --token-auth-file for similar functionality. + ` + mdSep + ` +#### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: + + ` + mdSep + `docs -Removed "Static Password File" section from https://kubernetes.io/docs/reference/access-authn-authz/authentication/#static-password-file -https://github.com/kubernetes/website/pull/19630 -` + mdSep, - shouldExclude: false, + +` + mdSep + ` + +`, + shouldExclude: false, // noteTextFromString will catch empty release notes }, } { res := MatchesExcludeFilter(tc.input)