Skip to content

Commit

Permalink
- introduce new flag allowing to fetch reviewers who approved PRs
Browse files Browse the repository at this point in the history
  - add new testcase which verifies approvers being included
  - adjust config for some test cases to verify reviewers not being pulled if disabled
  • Loading branch information
mikepenz committed Apr 8, 2022
1 parent df9a355 commit 1e867df
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 11 deletions.
8 changes: 8 additions & 0 deletions __tests__/releaseNotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it('Should have empty changelog (tags)', async () => {
toTag: 'v0.0.2',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -36,6 +37,7 @@ it('Should match generated changelog (tags)', async () => {
toTag: 'v0.0.3',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -62,6 +64,7 @@ it('Should match generated changelog (refs)', async () => {
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -96,6 +99,7 @@ it('Should match generated changelog and replace all occurrences (refs)', async
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -132,6 +136,7 @@ it('Should match ordered ASC', async () => {
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -155,6 +160,7 @@ it('Should match ordered DESC', async () => {
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -178,6 +184,7 @@ it('Should ignore PRs not merged into develop branch', async () => {
toTag: 'v1.4.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -199,6 +206,7 @@ it('Should ignore PRs not merged into main branch', async () => {
toTag: 'v1.4.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down
39 changes: 39 additions & 0 deletions __tests__/releaseNotesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand Down Expand Up @@ -43,6 +44,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand All @@ -67,6 +69,7 @@ it('Should use empty placeholder', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand All @@ -92,6 +95,7 @@ it('Should fill empty placeholders', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand Down Expand Up @@ -119,6 +123,7 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand Down Expand Up @@ -146,6 +151,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand Down Expand Up @@ -173,6 +179,7 @@ it('Uncategorized category', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)
Expand Down Expand Up @@ -200,6 +207,7 @@ it('Verify commit based changelog', async () => {
false,
false,
false,
false, // enable to fetch reviewers
true,
configuration
)
Expand Down Expand Up @@ -227,6 +235,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
false,
false,
false,
false, // enable to fetch reviewers
true,
configuration
)
Expand Down Expand Up @@ -254,6 +263,7 @@ it('Verify default inclusion of open PRs', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch reviewers
false, // commitMode
configuration // configuration
)
Expand Down Expand Up @@ -281,6 +291,7 @@ it('Verify custom categorisation of open PRs', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch reviewers
false, // commitMode
configuration // configuration
)
Expand All @@ -291,3 +302,31 @@ it('Verify custom categorisation of open PRs', async () => {
`## 🚀 Features Merged\n\n- A feature to be going to v2 (nr3) -- (#3) [merged] {feature}\n\n## 🚀 Features Open\n\n- New feature to keep open (nr5) -- (#7) [open] {feature}\n\n`
)
})

it('Verify reviewers who approved are fetched', async () => {
const configuration = resolveConfiguration(
'',
'configs_test/configuration_approvers.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, // enable to fetch reviewers
false, // commitMode
configuration // configuration
)

const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 Features\n\n- A feature to be going to v2 (nr3) -- (#3) [merged] --- \n- New feature to keep open (nr5) -- (#7) [open] --- gabrielpopa\n\n`
)
})
21 changes: 21 additions & 0 deletions __tests__/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mergedPullRequests.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -60,6 +61,7 @@ mergedPullRequests.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -77,6 +79,7 @@ mergedPullRequests.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -94,6 +97,7 @@ mergedPullRequests.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
}
)
Expand All @@ -113,6 +117,7 @@ const pullRequestWithLabelInBody: PullRequestInfo = {
body: '[Issue][Feature][AB-1234321] - no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
}

Expand All @@ -132,6 +137,7 @@ it('Extract label from title, combined regex', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -160,6 +166,7 @@ it('Extract label from title and body, combined regex', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -190,6 +197,7 @@ it('Extract label from title, split regex', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -220,6 +228,7 @@ it('Extract label from title, match', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -245,6 +254,7 @@ it('Extract label from title, match multiple', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -271,6 +281,7 @@ it('Extract label from title, match multiple, custon non matching label', async
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -298,6 +309,7 @@ pullRequestsWithLabels.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -315,6 +327,7 @@ pullRequestsWithLabels.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -332,6 +345,7 @@ pullRequestsWithLabels.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
},
{
Expand All @@ -349,6 +363,7 @@ pullRequestsWithLabels.push(
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: "merged"
}
)
Expand Down Expand Up @@ -380,6 +395,7 @@ it('Match multiple labels exhaustive for category', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration: customConfig
})
Expand All @@ -404,6 +420,7 @@ it('Deduplicate duplicated PRs', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration: customConfig
})
Expand All @@ -429,6 +446,7 @@ it('Deduplicate duplicated PRs DESC', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration: customConfig
})
Expand All @@ -450,6 +468,7 @@ it('Commit SHA-1 in commitMode', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: true,
configuration: customConfig
})
Expand All @@ -470,6 +489,7 @@ it('Release Diff', async () => {
toTag: 'v2.8.1',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: true,
configuration: customConfig
})
Expand Down Expand Up @@ -508,6 +528,7 @@ it('Use exclude labels to not include a PR within a category.', async () => {
toTag: '2.0.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration: customConfig
})
Expand Down
4 changes: 4 additions & 0 deletions configs_test/configuration_approvers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"template": "${{CHANGELOG}}",
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] ${{REVIEWERS}} --- ${{APPROVERS}}"
}
2 changes: 1 addition & 1 deletion configs_test/configuration_excluding_open.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
}
],
"template": "${{CHANGELOG}}",
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] {${{LABELS}}}"
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] {${{LABELS}}}${{APPROVERS}}"
}
2 changes: 1 addition & 1 deletion configs_test/configuration_including_open.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
],
"template": "${{CHANGELOG}}\n\n\nUncategorized\n${{UNCATEGORIZED}}\n\n\nOpen\n${{OPEN}}",
"pr_template": "- ${{TITLE}} (#${{NUMBER}}) ${{STATUS}}"
"pr_template": "- ${{TITLE}} (#${{NUMBER}}) ${{STATUS}}${{APPROVERS}}"
}
Loading

0 comments on commit 1e867df

Please sign in to comment.