- add new configuration to enable exportCache (disabled by default)
- this changes behavior since `rc04`
This commit is contained in:
@@ -131,6 +131,7 @@ jobs:
|
||||
fromTag: "v8.1.0"
|
||||
toTag: "v8.1.6"
|
||||
token: ${{ secrets.PERSONAL_TOKEN }}
|
||||
exportCache: true
|
||||
exportOnly: true
|
||||
|
||||
- name: "External Repo Configuration"
|
||||
|
||||
@@ -588,20 +588,22 @@ it('Test custom changelog builder', async () => {
|
||||
'release-changelog-builder-action-playground', // repo
|
||||
'1.5.0', // fromTag
|
||||
'2.0.0', // toTag
|
||||
true, // includeOpen
|
||||
false, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
true, // enable to fetch reviewers
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch release information
|
||||
false, // enable to fetch reviews
|
||||
false, // commitMode
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(``)
|
||||
expect(changeLog).toStrictEqual(`define-expected-output`)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -53,6 +54,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -80,6 +82,7 @@ it('Should use empty placeholder', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -107,6 +110,7 @@ it('Should fill empty placeholders', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -136,6 +140,7 @@ it('Should fill `template` placeholders', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -166,6 +171,7 @@ it('Should fill `template` placeholders, ignore', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -195,6 +201,7 @@ it('Uncategorized category', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -224,6 +231,7 @@ it('Verify commit based changelog', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
true, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -253,6 +261,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
true, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration
|
||||
)
|
||||
@@ -282,6 +291,7 @@ it('Verify default inclusion of open PRs', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
@@ -311,6 +321,7 @@ it('Verify custom categorisation of open PRs', async () => {
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
@@ -340,6 +351,7 @@ it('Verify reviewers who approved are fetched and also release information', asy
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
@@ -370,6 +382,7 @@ it('Fetch release information', async () => {
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
@@ -398,6 +411,7 @@ it('Fetch release information for non existing tag / release', async () => {
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
+5
-2
@@ -43,8 +43,11 @@ inputs:
|
||||
commitMode:
|
||||
description: 'Enables a `light` commit based mode. This mode generates changelogs based on the commits. Please note that this is not officially supported, and lacks a lot of features only possible with PRs.'
|
||||
default: "false"
|
||||
exportCache:
|
||||
description: 'If enabled, the action will export the collected data to the cache. This is disabled by default. Can be passed to a follow up run via `cache`.'
|
||||
default: "false"
|
||||
exportOnly:
|
||||
description: 'If enabled, the action will only collect the data and terminate afterwards. Data can then be consumed by steps afterwards'
|
||||
description: 'If enabled, the action will only collect the data and terminate afterwards. Data can then be consumed by steps afterwards. This requires `exportCache` to be enabled'
|
||||
default: "false"
|
||||
outputFile:
|
||||
description: 'If defined, the changelog will get written to this file. (relative to the checkout dir)'
|
||||
@@ -54,7 +57,7 @@ inputs:
|
||||
baseUrl:
|
||||
description: 'Defines the base url for GitHub Enterprise authentication, uses `https://api.github.com` by default'
|
||||
cache:
|
||||
description: 'Provide the cache of a previous run. Allows to re-use collected information multiple times to generate different release notes.'
|
||||
description: 'Provide the cache of a previous run. Allows to re-use collected information multiple times to generate different release notes. Requires `exportCache` to be enabled for the previous run.'
|
||||
outputs:
|
||||
changelog:
|
||||
description: The built release changelog built from the merged pull requests
|
||||
|
||||
+18
-14
@@ -146,8 +146,9 @@ function run() {
|
||||
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true';
|
||||
const fetchReviews = core.getInput('fetchReviews') === 'true';
|
||||
const commitMode = core.getInput('commitMode') === 'true';
|
||||
const exportCache = core.getInput('exportCache') === 'true';
|
||||
const exportOnly = core.getInput('exportOnly') === 'true';
|
||||
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchViaCommits, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, exportOnly, configuration).build();
|
||||
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchViaCommits, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, exportCache, exportOnly, configuration).build();
|
||||
core.setOutput('changelog', result);
|
||||
// write the result in changelog to file if possible
|
||||
const outputFile = core.getInput('outputFile');
|
||||
@@ -283,7 +284,7 @@ const transform_1 = __nccwpck_require__(1644);
|
||||
const github_pr_collector_1 = __nccwpck_require__(3196);
|
||||
const utils_2 = __nccwpck_require__(853);
|
||||
class ReleaseNotesBuilder {
|
||||
constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, exportOnly = false, configuration) {
|
||||
constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, exportCache = false, exportOnly = false, configuration) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.token = token;
|
||||
this.repositoryPath = repositoryPath;
|
||||
@@ -299,6 +300,7 @@ class ReleaseNotesBuilder {
|
||||
this.fetchReleaseInformation = fetchReleaseInformation;
|
||||
this.fetchReviews = fetchReviews;
|
||||
this.commitMode = commitMode;
|
||||
this.exportCache = exportCache;
|
||||
this.exportOnly = exportOnly;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
@@ -341,17 +343,19 @@ class ReleaseNotesBuilder {
|
||||
const mergedPullRequests = prData.mergedPullRequests;
|
||||
const diffInfo = prData.diffInfo;
|
||||
this.setOutputs(options, diffInfo, mergedPullRequests);
|
||||
const cache = {
|
||||
mergedPullRequests,
|
||||
diffInfo,
|
||||
options
|
||||
};
|
||||
core.setOutput(`cache`, JSON.stringify(cache));
|
||||
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
|
||||
if (this.exportOnly) {
|
||||
core.info(`ℹ️ Enabled 'exportOnly' will not generate changelog`);
|
||||
core.endGroup();
|
||||
return null;
|
||||
if (this.exportCache) {
|
||||
const cache = {
|
||||
mergedPullRequests,
|
||||
diffInfo,
|
||||
options
|
||||
};
|
||||
core.setOutput(`cache`, JSON.stringify(cache));
|
||||
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
|
||||
if (this.exportOnly) {
|
||||
core.info(`ℹ️ Enabled 'exportOnly' will not generate changelog`);
|
||||
core.endGroup();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (0, transform_1.buildChangelog)(diffInfo, mergedPullRequests, options);
|
||||
}
|
||||
@@ -643,7 +647,7 @@ function buildChangelog(diffInfo, origPrs, options) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// note the `exclude label` configuration of categories will not apply to the legacy "UNCATEGORIZED" placeholder
|
||||
// note the `exclude label` configuration of categories will not apply to the legacy "UNCATEGORIZED" placeholder
|
||||
uncategorizedPrs.push(body);
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -55,6 +55,7 @@ async function run(): Promise<void> {
|
||||
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'
|
||||
const fetchReviews = core.getInput('fetchReviews') === 'true'
|
||||
const commitMode = core.getInput('commitMode') === 'true'
|
||||
const exportCache = core.getInput('exportCache') === 'true'
|
||||
const exportOnly = core.getInput('exportOnly') === 'true'
|
||||
|
||||
const result = await new ReleaseNotesBuilder(
|
||||
@@ -73,6 +74,7 @@ async function run(): Promise<void> {
|
||||
fetchReleaseInformation,
|
||||
fetchReviews,
|
||||
commitMode,
|
||||
exportCache,
|
||||
exportOnly,
|
||||
configuration
|
||||
).build()
|
||||
|
||||
+14
-11
@@ -45,6 +45,7 @@ export class ReleaseNotesBuilder {
|
||||
private fetchReleaseInformation: boolean = false,
|
||||
private fetchReviews: boolean = false,
|
||||
private commitMode: boolean = false,
|
||||
private exportCache: boolean = false,
|
||||
private exportOnly: boolean = false,
|
||||
private configuration: Configuration
|
||||
) {}
|
||||
@@ -107,18 +108,20 @@ export class ReleaseNotesBuilder {
|
||||
const diffInfo = prData.diffInfo
|
||||
this.setOutputs(options, diffInfo, mergedPullRequests)
|
||||
|
||||
const cache = {
|
||||
mergedPullRequests,
|
||||
diffInfo,
|
||||
options
|
||||
}
|
||||
core.setOutput(`cache`, JSON.stringify(cache))
|
||||
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
|
||||
if (this.exportCache) {
|
||||
const cache = {
|
||||
mergedPullRequests,
|
||||
diffInfo,
|
||||
options
|
||||
}
|
||||
core.setOutput(`cache`, JSON.stringify(cache))
|
||||
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
|
||||
|
||||
if (this.exportOnly) {
|
||||
core.info(`ℹ️ Enabled 'exportOnly' will not generate changelog`)
|
||||
core.endGroup()
|
||||
return null
|
||||
if (this.exportOnly) {
|
||||
core.info(`ℹ️ Enabled 'exportOnly' will not generate changelog`)
|
||||
core.endGroup()
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return buildChangelog(diffInfo, mergedPullRequests, options)
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ export function buildChangelog(diffInfo: DiffInfo, origPrs: PullRequestInfo[], o
|
||||
}
|
||||
}
|
||||
|
||||
// note the `exclude label` configuration of categories will not apply to the legacy "UNCATEGORIZED" placeholder
|
||||
// note the `exclude label` configuration of categories will not apply to the legacy "UNCATEGORIZED" placeholder
|
||||
uncategorizedPrs.push(body)
|
||||
} else {
|
||||
categorizedPrs.push(body)
|
||||
|
||||
Reference in New Issue
Block a user