Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new API offering the ability to fetch reviewers who approved PRs #728

Merged
merged 8 commits into from
Apr 15, 2022
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ A full set list of possible output values for this action.
| `outputs.toTag` | Defines the `toTag` which describes the upper bound to process pull request for |
| `outputs.failed` | Defines if there was an issue with the action run, and the changelog may not have been generated correctly. [true, false] |
| `outputs.pull_requests` | Defines a `,` joined array with all PR IDs associated with the generated changelog. |
| `outputs.categorized_prs` | Count of PRs which were successfully categorized as part of the action. |
| `outputs.uncategorized_prs` | Count of PRs which were not categorized as part of the action. |
| `outputs.categorized_prs` | Count of PRs which were successfully categorized as part of the action. |
| `outputs.open_prs` | Count of open PRs. Only fetched if `includeOpen` is enabled. |
| `outputs.uncategorized_prs` | Count of PRs which were not categorized as part of the action. |


## Full Sample 🖥️
Expand Down Expand Up @@ -263,9 +264,11 @@ For advanced use cases additional settings can be provided to the action
| `toTag` | Defines until which tag the changelog will consider merged pull requests |
| `path` | Allows to specify an alternative sub directory, to use as base |
| `token` | Alternative config to specify token. You should prefer `env.GITHUB_TOKEN` instead though |
| `baseUrl` | Alternative config to specify base url for GitHub Enterprise authentication. Default value set to `https://api.github.com` |
| `baseUrl` | Alternative config to specify base url for GitHub Enterprise authentication. Default value set to `https://api.github.com` |
| `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 @@ -274,19 +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 |
| `${{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 `,` |
| **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 `,` |
| `${{APPROVERS}}` | GitHub Login names of users who approved the PR, joined by `,` |

### Template placeholders

Expand All @@ -296,6 +302,7 @@ Table of supported placeholders allowed to be used in the `template` and `empty_
|----------------------------|----------------------------------------------------------------------------------------------------|:---------:|
| `${{CHANGELOG}}` | The contents of the changelog, matching the labels as specified in the categories configuration | |
| `${{UNCATEGORIZED}}` | All pull requests not matching a specified label in categories | |
| `${{OPEN}}` | All open pull requests. Will only be fetched if `includeOpen` is enabled. | |
| `${{IGNORED}}` | All pull requests defining labels matching the `ignore_labels` configuration | |
| `${{OWNER}}` | Describes the owner of the repository the changelog was generated for | x |
| `${{REPO}}` | The repository name of the repo the changelog was generated for | x |
Expand All @@ -304,6 +311,7 @@ Table of supported placeholders allowed to be used in the `template` and `empty_
| `${{RELEASE_DIFF}}` | Introduces a link to the full diff between from tag and to tag releases | x |
| `${{CATEGORIZED_COUNT}}` | The count of PRs which were categorized | |
| `${{UNCATEGORIZED_COUNT}}` | The count of PRs and changes which were not categorized. No label overlapping with category labels | |
| `${{OPEN_COUNT}}` | The count of open PRs. Will only be fetched if `includeOpen` is configured. | |
| `${{IGNORED_COUNT}}` | The count of PRs and changes which were specifically ignored from the changelog. | |


Expand Down
16 changes: 16 additions & 0 deletions __tests__/releaseNotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ it('Should have empty changelog (tags)', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.2',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -33,7 +35,9 @@ it('Should match generated changelog (tags)', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.3',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -58,7 +62,9 @@ it('Should match generated changelog (refs)', async () => {
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -91,7 +97,9 @@ it('Should match generated changelog and replace all occurrences (refs)', async
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down Expand Up @@ -126,7 +134,9 @@ it('Should match ordered ASC', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -148,7 +158,9 @@ it('Should match ordered DESC', async () => {
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
includeOpen: false,
failOnError: false,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -170,7 +182,9 @@ 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,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand All @@ -190,7 +204,9 @@ 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,
fetchReviewers: false,
commitMode: false,
configuration
})
Expand Down
102 changes: 102 additions & 0 deletions __tests__/releaseNotesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -42,6 +44,8 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -65,6 +69,8 @@ it('Should use empty placeholder', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -89,6 +95,8 @@ it('Should fill empty placeholders', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -115,6 +123,8 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -141,6 +151,8 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -167,6 +179,8 @@ it('Uncategorized category', async () => {
false,
false,
false,
false, // enable to fetch reviewers
false,
configuration
)

Expand All @@ -192,6 +206,8 @@ it('Verify commit based changelog', async () => {
'v0.0.3',
false,
false,
false,
false, // enable to fetch reviewers
true,
configuration
)
Expand All @@ -218,6 +234,8 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
'17a9e4dfaedcabe6a6eff2754bebb715e1c58ec4',
false,
false,
false,
false, // enable to fetch reviewers
true,
configuration
)
Expand All @@ -228,3 +246,87 @@ 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 default inclusion of open PRs', async () => {
const configuration = resolveConfiguration(
'',
'configs_test/configuration_including_open.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
false, // 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\n\n\n\n\nUncategorized\n\n\n\nOpen\n- New feature to keep open (nr5) (#7) open\n`
)
})

it('Verify custom categorisation of open PRs', async () => {
const configuration = resolveConfiguration(
'',
'configs_test/configuration_excluding_open.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
false, // enable to fetch reviewers
false, // commitMode
configuration // configuration
)

const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 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`
)
})
Loading