Skip to content

Commit 9c133b6

Browse files
authored
Support rendering description for breaking changes and known issues (#129)
* changelog: add newlines for readability * changelog: add crossreferenceList template Fn * changelog: support description in rendered changelog * changelog: test description presence * fragment: note when description is rendered * add fragment * fragment: update fragment in test
1 parent 517e3be commit 9c133b6

File tree

8 files changed

+69
-7
lines changed

8 files changed

+69
-7
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: feature
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Support rendering description for breaking changes and known issues.
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; a word indicating the component this changeset affects.
22+
component:
23+
24+
# PR number; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
#pr: 1234
29+
30+
# Issue number; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
#issue: 1234

internal/assets/asciidoc-template.asciidoc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Review important information about the {{.Component}} {{.Version}} release.
1717
{{- end }}
1818
{{- end }}
1919
{{- end }}
20+
2021
{{ if .BreakingChange -}}
2122
[discrete]
2223
[[breaking-changes-{{.Version}}]]
@@ -30,10 +31,17 @@ impact to your application.
3031
{{ range $k, $v := .BreakingChange }}
3132
{{ $k | header2}}
3233
{{ range $item := $v }}
33-
* {{ $item.Summary | beautify }} {{ linkPRSource $item.Component $item.LinkedPR }} {{ linkIssueSource $item.Component $item.LinkedIssue }}
34+
[discrete]
35+
[[breaking-{{crossreferenceList $item.LinkedPR}}]]
36+
.{{ $item.Summary | beautify }} {{ linkPRSource $item.Component $item.LinkedPR }} {{ linkIssueSource $item.Component $item.LinkedIssue }}
37+
[%collapsible]
38+
====
39+
{{ $item.Description }}
40+
====
3441
{{- end }}
3542
{{- end }}
3643
{{- end }}
44+
3745
{{ if .KnownIssue -}}
3846
[discrete]
3947
[[known-issues-{{.Version}}]]
@@ -43,10 +51,17 @@ impact to your application.
4351
{{ range $k, $v := .KnownIssue }}
4452
{{ $k | header2}}
4553
{{ range $item := $v }}
46-
* {{ $item.Summary | beautify }} {{ linkPRSource $item.Component $item.LinkedPR }} {{ linkIssueSource $item.Component $item.LinkedIssue }}
54+
[discrete]
55+
[[known-issue-issue-{{crossreferenceList $item.LinkedIssue}}]]
56+
.{{ $item.Summary | beautify }} {{ linkPRSource $item.Component $item.LinkedPR }} {{ linkIssueSource $item.Component $item.LinkedIssue }}
57+
[%collapsible]
58+
====
59+
{{ $item.Description }}
60+
====
4761
{{- end }}
4862
{{- end }}
4963
{{- end }}
64+
5065
{{ if .Deprecation -}}
5166
[discrete]
5267
[[deprecations-{{.Version}}]]
@@ -64,6 +79,7 @@ upgrade to {{.Version}}.
6479
{{- end }}
6580
{{- end }}
6681
{{- end }}
82+
6783
{{ if .Feature -}}
6884
[discrete]
6985
[[new-features-{{.Version}}]]
@@ -78,6 +94,7 @@ The {{.Version}} release adds the following new and notable features.
7894
{{- end }}
7995
{{- end }}
8096
{{- end }}
97+
8198
{{ if .Enhancement }}
8299
[discrete]
83100
[[enhancements-{{.Version}}]]
@@ -90,6 +107,7 @@ The {{.Version}} release adds the following new and notable features.
90107
{{- end }}
91108
{{- end }}
92109
{{- end }}
110+
93111
{{ if .BugFix }}
94112
[discrete]
95113
[[bug-fixes-{{.Version}}]]
@@ -103,4 +121,4 @@ The {{.Version}} release adds the following new and notable features.
103121
{{- end }}
104122
{{- end }}
105123

106-
// end {{.Version}} relnotes
124+
// end {{.Version}} relnotes

internal/changelog/fragment/creator_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ summary: foobar
8989
9090
# Long description; in case the summary is not enough to describe the change
9191
# this field accommodate a description without length limits.
92+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
9293
#description:
9394
9495
# Affected component; a word indicating the component this changeset affects.

internal/changelog/fragment/template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ summary: {{.Summary}}
1515

1616
# Long description; in case the summary is not enough to describe the change
1717
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
1819
#description:
1920

2021
# Affected component; a word indicating the component this changeset affects.

internal/changelog/renderer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ func (r Renderer) Render() error {
7777

7878
tmpl, err := template.New("release-notes").
7979
Funcs(template.FuncMap{
80+
"crossreferenceList": func(ids []string) string {
81+
return strings.Join(ids, "-")
82+
},
8083
// nolint:staticcheck // ignoring for now, supports for multiple component is not implemented
8184
"linkPRSource": func(component string, ids []string) string {
8285
res := make([]string, len(ids))

internal/changelog/renderer_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ func TestRenderer(t *testing.T) {
4848
switch e.Kind {
4949
// NOTE: this is the list of kinds of entries we expect to see
5050
// in the rendered changelog (not all kinds are expected)
51-
case changelog.BreakingChange, changelog.Deprecation,
52-
changelog.BugFix, changelog.Enhancement,
53-
changelog.Feature, changelog.KnownIssue,
54-
changelog.Security:
51+
case changelog.BreakingChange, changelog.KnownIssue:
52+
require.Contains(t, strings.ToLower(string(out)), e.Summary)
53+
require.Contains(t, string(out), e.Description)
54+
case changelog.Deprecation, changelog.BugFix, changelog.Enhancement,
55+
changelog.Feature, changelog.Security:
5556
require.Contains(t, strings.ToLower(string(out)), e.Summary)
5657
default:
5758
require.NotContains(t, strings.ToLower(string(out)), e.Summary)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
kind: breaking-change
22
summary: a breaking change
3+
description: This paragraph to describe details and impact of this breaking change
4+
pr: 1234
5+
component: whatever
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
kind: known-issue
22
summary: a known issue
3+
description: This paragraph to describe details and impact of this known issue
4+
issue: 1234
5+
component: whatever

0 commit comments

Comments
 (0)