- introduce new configuration flag to fetchReleaseInformation

- if enabled, it will unlock the ability to use new placeholders
  - `${{ DAYS_SINCE }}`
  - `${{ FROM_TAG_DATE }}`
  - `${{ TO_TAG_DATE }}`
- refactor to carry on the full `TagInfo` information instead of only the tagname
- refresh testcases to new apis
This commit is contained in:
Mike Penz
2022-07-26 16:47:23 +02:00
parent 09ae38aa7f
commit c061d0e577
12 changed files with 291 additions and 83 deletions
+30 -20
View File
@@ -14,11 +14,12 @@ it('Should have empty changelog (tags)', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.2',
fromTag: { name: 'v0.0.1' },
toTag: { name: 'v0.0.2' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -33,11 +34,12 @@ it('Should match generated changelog (tags)', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.0.1',
toTag: 'v0.0.3',
fromTag: { name: 'v0.0.1'},
toTag: { name: 'v0.0.3' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -60,11 +62,12 @@ it('Should match generated changelog (refs)', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
fromTag: { name: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3' },
toTag: { name: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -95,11 +98,12 @@ it('Should match generated changelog and replace all occurrences (refs)', async
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3',
toTag: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa',
fromTag: { name: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3' },
toTag: { name: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -132,11 +136,12 @@ it('Should match ordered ASC', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
fromTag: { name: 'v0.3.0' },
toTag: { name: 'v0.5.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -156,11 +161,12 @@ it('Should match ordered DESC', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
fromTag: { name: 'v0.3.0' },
toTag: { name: 'v0.5.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -180,11 +186,12 @@ it('Should match ordered by title ASC', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
fromTag: { name: 'v0.3.0' },
toTag: { name: 'v0.5.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -204,11 +211,12 @@ it('Should match ordered by title DESC', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v0.3.0',
toTag: 'v0.5.0',
fromTag: { name: 'v0.3.0' },
toTag: { name: 'v0.5.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -228,11 +236,12 @@ it('Should ignore PRs not merged into develop branch', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v1.3.1',
toTag: 'v1.4.0',
fromTag: { name: 'v1.3.1' },
toTag: { name: 'v1.4.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -250,11 +259,12 @@ it('Should ignore PRs not merged into main branch', async () => {
const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v1.3.1',
toTag: 'v1.4.0',
fromTag: { name: 'v1.3.1' },
toTag: { name: 'v1.4.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
+12
View File
@@ -17,6 +17,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -45,6 +46,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -70,6 +72,7 @@ it('Should use empty placeholder', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -96,6 +99,7 @@ it('Should fill empty placeholders', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -124,6 +128,7 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -152,6 +157,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -180,6 +186,7 @@ it('Uncategorized category', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false,
configuration
)
@@ -208,6 +215,7 @@ it('Verify commit based changelog', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
true,
configuration
)
@@ -236,6 +244,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
false,
false,
false, // enable to fetch reviewers
false, // enable to fetch tag release information
true,
configuration
)
@@ -264,6 +273,7 @@ it('Verify default inclusion of open PRs', async () => {
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // commitMode
configuration // configuration
)
@@ -292,6 +302,7 @@ it('Verify custom categorisation of open PRs', async () => {
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // commitMode
configuration // configuration
)
@@ -320,6 +331,7 @@ it('Verify reviewers who approved are fetched', async () => {
false, // failOnError
false, // ignorePrePrelease
true, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // commitMode
configuration // configuration
)
+41 -28
View File
@@ -134,11 +134,12 @@ it('Extract label from title, combined regex', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -163,11 +164,12 @@ it('Extract label from title and body, combined regex', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, prs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -194,11 +196,12 @@ it('Extract label from title, split regex', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -225,11 +228,12 @@ it('Extract label from title, match', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -251,11 +255,12 @@ it('Extract label from title, match multiple', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -278,11 +283,12 @@ it('Extract label from title, match multiple, custon non matching label', async
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration
})
@@ -392,11 +398,12 @@ it('Match multiple labels exhaustive for category', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})
@@ -417,11 +424,12 @@ it('Deduplicate duplicated PRs', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})
@@ -443,11 +451,12 @@ it('Deduplicate duplicated PRs DESC', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})
@@ -475,11 +484,12 @@ it('Use empty_content for empty category', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})
@@ -497,11 +507,12 @@ it('Commit SHA-1 in commitMode', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: true,
configuration: customConfig
})
@@ -513,22 +524,23 @@ it('Commit SHA-1 in commitMode', async () => {
it('Release Diff', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.template = "${{RELEASE_DIFF}}"
customConfig.template = "${{RELEASE_DIFF}}\n${{DAYS_SINCE}}"
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: 'v2.8.0',
toTag: 'v2.8.1',
fromTag: { name: 'v2.8.0' },
toTag: { name: 'v2.8.1' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: true,
commitMode: true,
configuration: customConfig
})
expect(resultChangelog).toStrictEqual(
`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1`
`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1\n`
)
})
@@ -557,11 +569,12 @@ it('Use exclude labels to not include a PR within a category.', async () => {
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: '1.0.0',
toTag: '2.0.0',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})