Skip to content

Commit 2146b50

Browse files
Feature/26 introduce idea of pr without issue as part for user defined chapters (#37)
#26 - Introduce the idea of PR without Issue as part of user-defined chapters - introduced logic to work with PR without linked Issues like with Issues - removed code duplication from logic extension "extraction of Release notes" from comments. - fix similar methods to get issues and PR contributors. - improved method `parseChaptersJson` - Added new related test. - Implemented logic to add PR without linking issues to custom chapters. - Added new related test. - Added logic to identify Duplicate mentions of already printed Issues or PR in custom chapters. - Simplified duplicate string as GitHub does not support colors.
1 parent 2f143f4 commit 2146b50

16 files changed

+648
-182
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Add the following step to your GitHub workflow (in example are used non-default
3434
published-at: true
3535
skip-release-notes-label: 'ignore-in-release' # changing default value of label
3636
print-empty-chapters: false
37+
chapters-to-pr-without-issue: true
3738
```
3839
3940
### Configure the Action
@@ -46,6 +47,7 @@ Configure the action by customizing the following parameters based on your needs
4647
- **published-at** (optional): Set to true to enable the use of the `published-at` timestamp as the reference point for searching closed issues and PRs, instead of the `created-at` date of the latest release.
4748
- **skip-release-notes** (optional): Set to a label name to skip issues and PRs with this label from release notes process generation. Defaults to `skip-release-notes` if not specified.
4849
- **print-empty-chapters** (optional): Set to true to print chapters with no issues or PRs. Defaults to false if not specified.
50+
- **chapters-to-pr-without-issue** (optional): Set false to avoid application of custom chapters for PRs without linked issues. Defaults to true if not specified.
4951

5052
## Setup
5153
### Build the Action:

__tests__/data/rls_notes_empty_with_all_chapters.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ All closed issues contain at least one of user defined labels.
1616
### Closed Issues without Release Notes ⚠️
1717
All closed issues have release notes.
1818

19-
### Merged PRs without Linked Issue ⚠️
19+
### Merged PRs without Linked Issue and Custom Labels ⚠️
2020
All merged PRs are linked to issues.
2121

2222
### Merged PRs Linked to Open Issue ⚠️
2323
All merged PRs are linked to Closed issues.
2424

25-
### Closed PRs without Linked Issue ⚠️
25+
### Closed PRs without Linked Issue and Custom Labels ⚠️
2626
All closed PRs are linked to issues.
2727

2828
#### Full Changelog

__tests__/data/rls_notes_empty_with_no_custom_chapters.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ All closed issues contain at least one of user defined labels.
77
### Closed Issues without Release Notes ⚠️
88
All closed issues have release notes.
99

10-
### Merged PRs without Linked Issue ⚠️
10+
### Merged PRs without Linked Issue and Custom Labels ⚠️
1111
All merged PRs are linked to issues.
1212

1313
### Merged PRs Linked to Open Issue ⚠️
1414
All merged PRs are linked to Closed issues.
1515

16-
### Closed PRs without Linked Issue ⚠️
16+
### Closed PRs without Linked Issue and Custom Labels ⚠️
1717
All closed PRs are linked to issues.
1818

1919
#### Full Changelog

__tests__/data/rls_notes_fully_populated_custom_skip_label.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
- note about change in Issue 4
1313
- #2 _Issue title 2_ implemented by @johnDoe in [#2](link-to-pr-2)
1414
- note about change in Issue 2
15+
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
16+
- note about change in Issue 1
17+
- note about change in Issue 1 (no bullet point at start of line)
1518

1619

1720
### Bugfixes 🛠
18-
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
21+
- **<span style="color: red;">[Duplicate]<span>** #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
1922
- note about change in Issue 1
2023
- note about change in Issue 1 (no bullet point at start of line)
2124

@@ -38,17 +41,17 @@
3841
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
3942

4043

41-
### Merged PRs without Linked Issue ⚠️
42-
#1004 _Pull Request 4 - no linked issue - merged_
43-
#1006 _Pull Request 6 - skip label_
44+
### Merged PRs without Linked Issue and Custom Labels ⚠️
45+
- #1004 _Pull Request 4 - no linked issue - merged_ implemented by @janeDoe
46+
- #1006 _Pull Request 6 - skip label_ implemented by @janeDoe
4447

4548

4649
### Merged PRs Linked to Open Issue ⚠️
47-
#1003 _Pull Request 3 - linked to open issue_
50+
- #1003 _Pull Request 3 - linked to open issue_
4851

4952

50-
### Closed PRs without Linked Issue ⚠️
51-
#1002 _Pull Request 2 - no linked issue - closed_
53+
### Closed PRs without Linked Issue and Custom Labels ⚠️
54+
- #1002 _Pull Request 2 - no linked issue - closed_ implemented by @janeDoe
5255

5356

5457
#### Full Changelog

__tests__/data/rls_notes_fully_populated_first_release.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414
- note about change in Issue 4
1515
- #2 _Issue title 2_ implemented by @johnDoe in [#2](link-to-pr-2)
1616
- note about change in Issue 2
17+
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
18+
- note about change in Issue 1
19+
- note about change in Issue 1 (no bullet point at start of line)
20+
- #1001 _Pull Request 1_ implemented by @janeDoe
21+
- This is second PR comment ad RLS note
22+
- This is third PR comment ad RLS note
1723

1824

1925
### Bugfixes 🛠
20-
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
26+
- **<span style="color: red;">[Duplicate]<span>** #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
2127
- note about change in Issue 1
2228
- note about change in Issue 1 (no bullet point at start of line)
29+
- **<span style="color: red;">[Duplicate]<span>** #1001 _Pull Request 1_ implemented by @janeDoe
30+
- This is second PR comment ad RLS note
31+
- This is third PR comment ad RLS note
2332

2433

2534
### Closed Issues without Pull Request ⚠️
@@ -37,17 +46,16 @@
3746
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
3847

3948

40-
### Merged PRs without Linked Issue ⚠️
41-
#1001 _Pull Request 1_
42-
#1004 _Pull Request 4 - no linked issue - merged_
49+
### Merged PRs without Linked Issue and Custom Labels ⚠️
50+
- #1004 _Pull Request 4 - no linked issue - merged_ implemented by @janeDoe
4351

4452

4553
### Merged PRs Linked to Open Issue ⚠️
46-
#1003 _Pull Request 3 - linked to open issue_
54+
- #1003 _Pull Request 3 - linked to open issue_
4755

4856

49-
### Closed PRs without Linked Issue ⚠️
50-
#1002 _Pull Request 2 - no linked issue - closed_
57+
### Closed PRs without Linked Issue and Custom Labels ⚠️
58+
- #1002 _Pull Request 2 - no linked issue - closed_ implemented by @janeDoe
5159

5260

5361
#### Full Changelog

__tests__/data/rls_notes_fully_populated_hide_warning_chapters.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
- note about change in Issue 4
1515
- #2 _Issue title 2_ implemented by @johnDoe in [#2](link-to-pr-2)
1616
- note about change in Issue 2
17+
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
18+
- note about change in Issue 1
19+
- note about change in Issue 1 (no bullet point at start of line)
1720

1821

1922
### Bugfixes 🛠
20-
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
23+
- **<span style="color: red;">[Duplicate]<span>** #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
2124
- note about change in Issue 1
2225
- note about change in Issue 1 (no bullet point at start of line)
2326

__tests__/data/rls_notes_fully_populated_in_default.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414
- note about change in Issue 4
1515
- #2 _Issue title 2_ implemented by @johnDoe in [#2](link-to-pr-2)
1616
- note about change in Issue 2
17+
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
18+
- note about change in Issue 1
19+
- note about change in Issue 1 (no bullet point at start of line)
20+
- #1001 _Pull Request 1_ implemented by @janeDoe
21+
- This is second PR comment ad RLS note
22+
- This is third PR comment ad RLS note
1723

1824

1925
### Bugfixes 🛠
20-
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
26+
- **<span style="color: red;">[Duplicate]<span>** #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
2127
- note about change in Issue 1
2228
- note about change in Issue 1 (no bullet point at start of line)
29+
- **<span style="color: red;">[Duplicate]<span>** #1001 _Pull Request 1_ implemented by @janeDoe
30+
- This is second PR comment ad RLS note
31+
- This is third PR comment ad RLS note
2332

2433

2534
### Closed Issues without Pull Request ⚠️
@@ -37,17 +46,16 @@
3746
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
3847

3948

40-
### Merged PRs without Linked Issue ⚠️
41-
#1001 _Pull Request 1_
42-
#1004 _Pull Request 4 - no linked issue - merged_
49+
### Merged PRs without Linked Issue and Custom Labels ⚠️
50+
- #1004 _Pull Request 4 - no linked issue - merged_ implemented by @janeDoe
4351

4452

4553
### Merged PRs Linked to Open Issue ⚠️
46-
#1003 _Pull Request 3 - linked to open issue_
54+
- #1003 _Pull Request 3 - linked to open issue_
4755

4856

49-
### Closed PRs without Linked Issue ⚠️
50-
#1002 _Pull Request 2 - no linked issue - closed_
57+
### Closed PRs without Linked Issue and Custom Labels ⚠️
58+
- #1002 _Pull Request 2 - no linked issue - closed_ implemented by @janeDoe
5159

5260

5361
#### Full Changelog
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
### Breaking Changes 💥
2+
- #8 _Issue title 8 - with co-author|private mail_ implemented by @johnDoe, Jane Doe in [#8](link-to-pr-8)
3+
- note about change in Issue 8
4+
- #7 _Issue title 7 - with co-author|public mail_ implemented by @janeDoe, @johnDoe in [#7](link-to-pr-7)
5+
- note about change in Issue 7
6+
7+
8+
### New Features 🎉
9+
- #6 _Issue title 6 - not assigned|no PR_ implemented by "Missing Assignee or Contributor"
10+
- note about change in Issue 6
11+
- #5 _Issue title 5 - not assigned|three PRs_ implemented by "Missing Assignee or Contributor" in [#5](link-to-pr-5), [#15](link-to-pr-15), [#16](link-to-pr-16)
12+
- note about change in Issue 5
13+
- #4 _Issue title 4 - assigned|one PR_ implemented by @johnDoe in [#4](link-to-pr-4)
14+
- note about change in Issue 4
15+
- #2 _Issue title 2_ implemented by @johnDoe in [#2](link-to-pr-2)
16+
- note about change in Issue 2
17+
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
18+
- note about change in Issue 1
19+
- note about change in Issue 1 (no bullet point at start of line)
20+
21+
22+
### Bugfixes 🛠
23+
- **<span style="color: red;">[Duplicate]<span>** #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
24+
- note about change in Issue 1
25+
- note about change in Issue 1 (no bullet point at start of line)
26+
27+
28+
### Closed Issues without Pull Request ⚠️
29+
- #6 _Issue title 6 - not assigned|no PR_ implemented by "Missing Assignee or Contributor"
30+
- note about change in Issue 6
31+
32+
33+
### Closed Issues without User Defined Labels ⚠️
34+
- #9 _Issue title 9 - no user defined label_ implemented by @janeDoe in [#9](link-to-pr-9)
35+
- note about change in Issue 9
36+
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
37+
38+
39+
### Closed Issues without Release Notes ⚠️
40+
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
41+
42+
43+
### Merged PRs without Linked Issue and Custom Labels ⚠️
44+
- #1001 _Pull Request 1_ implemented by @janeDoe
45+
- This is second PR comment ad RLS note
46+
- This is third PR comment ad RLS note
47+
- #1004 _Pull Request 4 - no linked issue - merged_ implemented by @janeDoe
48+
49+
50+
### Merged PRs Linked to Open Issue ⚠️
51+
- #1003 _Pull Request 3 - linked to open issue_
52+
53+
54+
### Closed PRs without Linked Issue and Custom Labels ⚠️
55+
- #1002 _Pull Request 2 - no linked issue - closed_ implemented by @janeDoe
56+
57+
58+
#### Full Changelog
59+
https://github.com/owner/repo/compare/v0.1.0...v0.1.1

__tests__/data/rls_notes_fully_populated_no_custom_chapters.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@
2828
- #3 _Issue title 3 - no release note comment|typo label_ implemented by @janeDoe in [#3](link-to-pr-3)
2929

3030

31-
### Merged PRs without Linked Issue ⚠️
32-
#1001 _Pull Request 1_
33-
#1004 _Pull Request 4 - no linked issue - merged_
31+
### Merged PRs without Linked Issue and Custom Labels ⚠️
32+
- #1001 _Pull Request 1_ implemented by @janeDoe
33+
- This is second PR comment ad RLS note
34+
- This is third PR comment ad RLS note
35+
- #1004 _Pull Request 4 - no linked issue - merged_ implemented by @janeDoe
3436

3537

3638
### Merged PRs Linked to Open Issue ⚠️
37-
#1003 _Pull Request 3 - linked to open issue_
39+
- #1003 _Pull Request 3 - linked to open issue_
3840

3941

40-
### Closed PRs without Linked Issue ⚠️
41-
#1002 _Pull Request 2 - no linked issue - closed_
42+
### Closed PRs without Linked Issue and Custom Labels ⚠️
43+
- #1002 _Pull Request 2 - no linked issue - closed_ implemented by @janeDoe
4244

4345

4446
#### Full Changelog

__tests__/data/rls_notes_fully_populated_second_release.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ All closed issues contain at least one of user defined labels.
1616
### Closed Issues without Release Notes ⚠️
1717
All closed issues have release notes.
1818

19-
### Merged PRs without Linked Issue ⚠️
19+
### Merged PRs without Linked Issue and Custom Labels ⚠️
2020
All merged PRs are linked to issues.
2121

2222
### Merged PRs Linked to Open Issue ⚠️
2323
All merged PRs are linked to Closed issues.
2424

25-
### Closed PRs without Linked Issue ⚠️
25+
### Closed PRs without Linked Issue and Custom Labels ⚠️
2626
All closed PRs are linked to issues.
2727

2828
#### Full Changelog

__tests__/generate-release-notes.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,27 @@ describe('run', () => {
247247
expect(firstCallArgs[1]).toBe(expectedOutput);
248248
});
249249

250+
it('should run successfully with valid inputs - no PRs in chapter', async () => {
251+
console.log('Test started: should run successfully with valid inputs - no PRs in chapter');
252+
253+
core.getInput.mockImplementation((name) => {
254+
return coreMocks.fullAndNoChaptersForPRsInputs(name);
255+
});
256+
Octokit.mockImplementation(octokitMocks.mockFullPerfectData);
257+
258+
await run();
259+
260+
expect(core.setFailed).not.toHaveBeenCalled();
261+
262+
// Get the arguments of the first call to setOutput
263+
const firstCallArgs = core.setOutput.mock.calls[0];
264+
expect(firstCallArgs[0]).toBe('releaseNotes');
265+
266+
const filePath = path.join(__dirname, 'data', 'rls_notes_fully_populated_no_PRs_in_chapters.md');
267+
let expectedOutput = fs.readFileSync(filePath, 'utf8');
268+
expect(firstCallArgs[1]).toBe(expectedOutput);
269+
});
270+
250271
/*
251272
Happy path tests - no option related
252273
*/

0 commit comments

Comments
 (0)