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 to include open PRs within the generated changelog #726

Merged
merged 6 commits into from Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 22 additions & 16 deletions README.md
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,7 +264,8 @@ 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 |
| `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 |
Expand All @@ -274,19 +276,21 @@ 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 `,` |

### Template placeholders

Expand All @@ -296,6 +300,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 +309,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
8 changes: 8 additions & 0 deletions __tests__/releaseNotes.test.ts
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
63 changes: 63 additions & 0 deletions __tests__/releaseNotesBuilder.test.ts
Expand Up @@ -16,6 +16,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -42,6 +43,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -65,6 +67,7 @@ it('Should use empty placeholder', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -89,6 +92,7 @@ it('Should fill empty placeholders', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -115,6 +119,7 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -141,6 +146,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -167,6 +173,7 @@ it('Uncategorized category', async () => {
false,
false,
false,
false,
configuration
)

Expand All @@ -192,6 +199,7 @@ it('Verify commit based changelog', async () => {
'v0.0.3',
false,
false,
false,
true,
configuration
)
Expand All @@ -218,6 +226,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
'17a9e4dfaedcabe6a6eff2754bebb715e1c58ec4',
false,
false,
false,
true,
configuration
)
Expand All @@ -228,3 +237,57 @@ 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, // 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, // 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`
)
})