- introduce new flag to include open PRs into the changelog

- only fetch open with this flag
- expand pull request spec with
  - status, created at timestamp
- expand definition for placeholder patterns in the changelog
This commit is contained in:
Mike Penz
2022-04-08 11:00:39 +02:00
parent 7a59e9f4b4
commit 85af6a8181
10 changed files with 333 additions and 58 deletions
+8
View File
@@ -16,6 +16,7 @@ it('Should have empty changelog (tags)', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.2',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -33,6 +34,7 @@ it('Should match generated changelog (tags)', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.3',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -58,6 +60,7 @@ it('Should match generated changelog (refs)', async () => {
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -91,6 +94,7 @@ it('Should match generated changelog and replace all occurrences (refs)', async
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -126,6 +130,7 @@ it('Should match ordered ASC', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -148,6 +153,7 @@ it('Should match ordered DESC', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -170,6 +176,7 @@ it('Should ignore PRs not merged into develop branch', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v1.3.1',
toTag: 'v1.4.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -190,6 +197,7 @@ it('Should ignore PRs not merged into main branch', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v1.3.1',
toTag: 'v1.4.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
+37
View File
@@ -16,6 +16,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false,
false,
configuration
)
@@ -42,6 +43,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false,
false,
configuration
)
@@ -65,6 +67,7 @@ it('Should use empty placeholder', async () => {
false,
false,
false,
false,
configuration
)
@@ -89,6 +92,7 @@ it('Should fill empty placeholders', async () => {
false,
false,
false,
false,
configuration
)
@@ -115,6 +119,7 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false,
false,
configuration
)
@@ -141,6 +146,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false,
false,
configuration
)
@@ -167,6 +173,7 @@ it('Uncategorized category', async () => {
false,
false,
false,
false,
configuration
)
@@ -192,6 +199,7 @@ it('Verify commit based changelog', async () => {
'v0.0.3',
false,
false,
false,
true,
configuration
)
@@ -218,6 +226,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
'17a9e4dfaedcabe6a6eff2754bebb715e1c58ec4',
false,
false,
false,
true,
configuration
)
@@ -228,3 +237,31 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
`## 🚀 Features\n\n- add dynamic merging\n- add auto-cleaning\n- add built-in adb support\n- add adb fallback (thanks to @mikepenz ;))\n- add install note\n- add @mikepenz to credits\n\n## 🐛 Fixes\n\n- fix dynamic lib replacement\n- fix apostrophe issue with app name\n- fix java.util.logger error\n\n## 💬 Other\n\n- update screenshot with truecaller stack\n\n`
)
})
it('Verify inclusion of open PRs', async () => {
const configuration = resolveConfiguration(
'',
'configs_test/configuration_commits_emoji.json'
)
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
null, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
'1.5.0', // fromTag
'2.0.0', // toTag
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
true, // commitMode
configuration // configuration
)
const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(
``
)
})
+39 -9
View File
@@ -33,6 +33,7 @@ mergedPullRequests.push(
title: '[Feature][AB-1234] - this is a PR 1 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
@@ -41,13 +42,15 @@ mergedPullRequests.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 2,
title: '[Issue][AB-4321] - this is a PR 2 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
@@ -56,13 +59,15 @@ mergedPullRequests.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 3,
title: '[Issue][Feature][AB-1234321] - this is a PR 3 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
@@ -71,13 +76,15 @@ mergedPullRequests.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 4,
title: '[AB-404] - not found label',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
@@ -86,7 +93,8 @@ mergedPullRequests.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
}
)
@@ -95,6 +103,7 @@ const pullRequestWithLabelInBody: PullRequestInfo = {
title: 'label in body',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
@@ -103,7 +112,8 @@ const pullRequestWithLabelInBody: PullRequestInfo = {
milestone: '',
body: '[Issue][Feature][AB-1234321] - no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
}
it('Extract label from title, combined regex', async () => {
@@ -120,6 +130,7 @@ it('Extract label from title, combined regex', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -147,6 +158,7 @@ it('Extract label from title and body, combined regex', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -176,6 +188,7 @@ it('Extract label from title, split regex', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -205,6 +218,7 @@ it('Extract label from title, match', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -229,6 +243,7 @@ it('Extract label from title, match multiple', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -254,6 +269,7 @@ it('Extract label from title, match multiple, custon non matching label', async
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration
@@ -272,6 +288,7 @@ pullRequestsWithLabels.push(
title: '[ABC-1234] - this is a PR 1 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-1',
author: 'Mike',
@@ -280,13 +297,15 @@ pullRequestsWithLabels.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 2,
title: '[ABC-4321] - this is a PR 2 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-2',
author: 'Mike',
@@ -295,13 +314,15 @@ pullRequestsWithLabels.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 3,
title: '[ABC-1234] - this is a PR 3 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment().add(1, 'days'),
mergeCommitSha: 'sha1-3',
author: 'Mike',
@@ -310,13 +331,15 @@ pullRequestsWithLabels.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
},
{
number: 4,
title: '[AB-404] - not found label',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-4',
author: 'Mike',
@@ -325,7 +348,8 @@ pullRequestsWithLabels.push(
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: []
requestedReviewers: [],
status: "merged"
}
)
@@ -354,6 +378,7 @@ it('Match multiple labels exhaustive for category', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration: customConfig
@@ -377,6 +402,7 @@ it('Deduplicate duplicated PRs', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration: customConfig
@@ -401,6 +427,7 @@ it('Deduplicate duplicated PRs DESC', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration: customConfig
@@ -421,6 +448,7 @@ it('Commit SHA-1 in commitMode', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: true,
configuration: customConfig
@@ -440,6 +468,7 @@ it('Release Diff', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v2.8.0',
toTag: 'v2.8.1',
includeOpen: false,
failOnError: false,
commitMode: true,
configuration: customConfig
@@ -477,6 +506,7 @@ it('Use exclude labels to not include a PR within a category.', async () => {
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
commitMode: false,
configuration: customConfig