Skip to content

Commit

Permalink
Merge pull request #728 from mikepenz/feature/720
Browse files Browse the repository at this point in the history
Introduce new API offering the ability to fetch reviewers who approved PRs
  • Loading branch information
mikepenz authored Apr 15, 2022
2 parents 4d2ba0e + d0b0f4a commit fe2fbf9
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 25 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ For advanced use cases additional settings can be provided to the action
| `includeOpen` | Enables to also fetch currently open PRs. Default: false |
| `ignorePreReleases` | Allows to ignore pre-releases for changelog generation (E.g. for 1.0.1... 1.0.0-rc02 <- ignore, 1.0.0 <- pick). Only used if `fromTag` was not specified. Default: false |
| `failOnError` | Defines if the action will result in a build failure if problems occurred. Default: false |
| `fetchReviewers` | Will enable fetching the users/reviewers who approved the PR. Default: false |
| `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false |

💡 `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
Expand All @@ -276,21 +277,22 @@ For advanced use cases additional settings can be provided to the action

Table of supported placeholders allowed to be used in the `pr_template` configuration, which will be included in the release notes / changelog.

| **Placeholder** | **Description** |
|-------------------|-------------------------------------------------------------|
| `${{NUMBER}}` | The number referencing this pull request. E.g. 13 |
| `${{TITLE}}` | Specified title of the merged pull request |
| `${{URL}}` | Url linking to the pull request on GitHub |
| **Placeholder** | **Description** |
|-------------------|-------------------------------------------------------------------|
| `${{NUMBER}}` | The number referencing this pull request. E.g. 13 |
| `${{TITLE}}` | Specified title of the merged pull request |
| `${{URL}}` | Url linking to the pull request on GitHub |
| `${{STATUS}}` | Status of the PR. Usually always `merged`. Possibly `Open` if `includeOpen` is configured. |
| `${{CREATED_AT}}` | The ISO time, the pull request was created at |
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at |
| `${{MERGE_SHA}}` | The commit SHA, the pull request was merged with |
| `${{AUTHOR}}` | Author creating and opening the pull request |
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
| `${{BODY}}` | Description/Body of the pull request as specified on GitHub |
| `${{ASSIGNEES}}` | Login names of assigned GitHub users, joined by `,` |
| `${{REVIEWERS}}` | GitHub Login names of specified reviewers, joined by `,` |
| `${{CREATED_AT}}` | The ISO time, the pull request was created at |
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at |
| `${{MERGE_SHA}}` | The commit SHA, the pull request was merged with |
| `${{AUTHOR}}` | Author creating and opening the pull request |
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
| `${{BODY}}` | Description/Body of the pull request as specified on GitHub |
| `${{ASSIGNEES}}` | Login names of assigned GitHub users, joined by `,` |
| `${{REVIEWERS}}` | GitHub Login names of specified reviewers, joined by `,` |
| `${{APPROVERS}}` | GitHub Login names of users who approved the PR, joined by `,` |

### Template placeholders

Expand Down
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
Loading

0 comments on commit fe2fbf9

Please sign in to comment.