- group logs together to have a better visualisation of what's going on

- add emojis to all sorts of logs
This commit is contained in:
Mike Penz
2020-10-17 19:37:11 +02:00
parent c8090bcb0d
commit f675789732
8 changed files with 90 additions and 101 deletions
Generated Vendored
+45 -44
View File
@@ -72,7 +72,7 @@ class Commits {
commits = compareResult.data.commits.concat(commits); commits = compareResult.data.commits.concat(commits);
compareHead = `${commits[0].sha}^`; compareHead = `${commits[0].sha}^`;
} }
core.info(`Found ${commits.length} commits from the GitHub API for ${owner}/${repo}`); core.info(`Found ${commits.length} commits from the GitHub API for ${owner}/${repo}`);
return commits.map(commit => ({ return commits.map(commit => ({
sha: commit.sha, sha: commit.sha,
summary: commit.commit.message.split('\n')[0], summary: commit.commit.message.split('\n')[0],
@@ -379,21 +379,21 @@ function run() {
repo = splitRepository[1]; repo = splitRepository[1];
} }
if (!owner) { if (!owner) {
core.error(`Missing or couldn't resolve 'owner'`); core.error(`💥 Missing or couldn't resolve 'owner'`);
return; return;
} }
else { else {
core.debug(`Resolved 'owner' as ${owner}`); core.debug(`Resolved 'owner' as ${owner}`);
} }
if (!repo) { if (!repo) {
core.error(`Missing or couldn't resolve 'owner'`); core.error(`💥 Missing or couldn't resolve 'owner'`);
return; return;
} }
else { else {
core.debug(`Resolved 'repo' as ${repo}`); core.debug(`Resolved 'repo' as ${repo}`);
} }
if (!toTag) { if (!toTag) {
core.error(`Missing or couldn't resolve 'toTag'`); core.error(`💥 Missing or couldn't resolve 'toTag'`);
return; return;
} }
else { else {
@@ -500,7 +500,7 @@ class PullRequests {
}; };
} }
catch (e) { catch (e) {
core.warning(`Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`); core.warning(`⚠️ Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`);
return null; return null;
} }
}); });
@@ -546,7 +546,7 @@ class PullRequests {
if ((firstPR.merged_at && fromDate.isAfter(moment_1.default(firstPR.merged_at))) || if ((firstPR.merged_at && fromDate.isAfter(moment_1.default(firstPR.merged_at))) ||
mergedPRs.length >= maxPullRequests) { mergedPRs.length >= maxPullRequests) {
if (mergedPRs.length >= maxPullRequests) { if (mergedPRs.length >= maxPullRequests) {
core.info(`Reached 'maxPullRequests' count ${maxPullRequests}`); core.info(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`);
} }
// bail out early to not keep iterating on PRs super old // bail out early to not keep iterating on PRs super old
return sortPullRequests(mergedPRs, true); return sortPullRequests(mergedPRs, true);
@@ -674,40 +674,47 @@ class ReleaseNotes {
}); });
const { owner, repo, toTag, ignorePreReleases, configuration } = this.options; const { owner, repo, toTag, ignorePreReleases, configuration } = this.options;
if (!this.options.fromTag) { if (!this.options.fromTag) {
core.startGroup(`:bookmark: Resolve 'fromTag'`);
core.debug(`fromTag undefined, trying to resolve via API`); core.debug(`fromTag undefined, trying to resolve via API`);
const tagsApi = new tags_1.Tags(octokit); const tagsApi = new tags_1.Tags(octokit);
const previousTag = yield tagsApi.findPredecessorTag(owner, repo, toTag, ignorePreReleases, (_a = configuration.max_tags_to_fetch) !== null && _a !== void 0 ? _a : configuration_1.DefaultConfiguration.max_tags_to_fetch); const previousTag = yield tagsApi.findPredecessorTag(owner, repo, toTag, ignorePreReleases, (_a = configuration.max_tags_to_fetch) !== null && _a !== void 0 ? _a : configuration_1.DefaultConfiguration.max_tags_to_fetch);
if (previousTag == null) { if (previousTag == null) {
core.error(`Unable to retrieve previous tag given ${toTag}`); core.error(`💥 Unable to retrieve previous tag given ${toTag}`);
return ((_b = configuration.empty_template) !== null && _b !== void 0 ? _b : configuration_1.DefaultConfiguration.empty_template); return ((_b = configuration.empty_template) !== null && _b !== void 0 ? _b : configuration_1.DefaultConfiguration.empty_template);
} }
this.options.fromTag = previousTag.name; this.options.fromTag = previousTag.name;
core.debug(`fromTag resolved via previousTag as: ${previousTag.name}`); core.debug(`fromTag resolved via previousTag as: ${previousTag.name}`);
core.endGroup();
} }
core.startGroup(`🚀 Load pull requests`);
const mergedPullRequests = yield this.getMergedPullRequests(octokit); const mergedPullRequests = yield this.getMergedPullRequests(octokit);
core.endGroup();
if (mergedPullRequests.length === 0) { if (mergedPullRequests.length === 0) {
core.warning(`No pull requests found`); core.warning(`⚠️ No pull requests found`);
return (_c = configuration.empty_template) !== null && _c !== void 0 ? _c : configuration_1.DefaultConfiguration.empty_template; return (_c = configuration.empty_template) !== null && _c !== void 0 ? _c : configuration_1.DefaultConfiguration.empty_template;
} }
return transform_1.buildChangelog(mergedPullRequests, configuration); core.startGroup("📦 Build changelog");
const resultChangelog = transform_1.buildChangelog(mergedPullRequests, configuration);
core.endGroup();
return resultChangelog;
}); });
} }
getMergedPullRequests(octokit) { getMergedPullRequests(octokit) {
var _a; var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { owner, repo, fromTag, toTag, configuration } = this.options; const { owner, repo, fromTag, toTag, configuration } = this.options;
core.info(`Comparing ${owner}/${repo} - ${fromTag}...${toTag}`); core.info(`Comparing ${owner}/${repo} - ${fromTag}...${toTag}`);
const commitsApi = new commits_1.Commits(octokit); const commitsApi = new commits_1.Commits(octokit);
let commits; let commits;
try { try {
commits = yield commitsApi.getDiff(owner, repo, fromTag, toTag); commits = yield commitsApi.getDiff(owner, repo, fromTag, toTag);
} }
catch (error) { catch (error) {
core.error(`Failed to retrieve - Invalid tag? - Because of: ${error}`); core.error(`💥 Failed to retrieve - Invalid tag? - Because of: ${error}`);
return []; return [];
} }
if (commits.length === 0) { if (commits.length === 0) {
core.warning(`No commits found between - ${fromTag}...${toTag}`); core.warning(`💥 No commits found between - ${fromTag}...${toTag}`);
return []; return [];
} }
const firstCommit = commits[0]; const firstCommit = commits[0];
@@ -717,19 +724,15 @@ class ReleaseNotes {
const maxDays = (_a = configuration.max_back_track_time_days) !== null && _a !== void 0 ? _a : configuration_1.DefaultConfiguration.max_back_track_time_days; const maxDays = (_a = configuration.max_back_track_time_days) !== null && _a !== void 0 ? _a : configuration_1.DefaultConfiguration.max_back_track_time_days;
const maxFromDate = toDate.clone().subtract(maxDays, 'days'); const maxFromDate = toDate.clone().subtract(maxDays, 'days');
if (maxFromDate.isAfter(fromDate)) { if (maxFromDate.isAfter(fromDate)) {
core.info(`Adjusted 'fromDate' to go max ${maxDays} back`); core.info(`⚠️ Adjusted 'fromDate' to go max ${maxDays} back`);
fromDate = maxFromDate; fromDate = maxFromDate;
} }
core.info(`Fetching PRs between dates ${fromDate.toISOString()} to ${toDate.toISOString()} for ${owner}/${repo}`); core.info(`Fetching PRs between dates ${fromDate.toISOString()} to ${toDate.toISOString()} for ${owner}/${repo}`);
const pullRequestsApi = new pullRequests_1.PullRequests(octokit); const pullRequestsApi = new pullRequests_1.PullRequests(octokit);
const pullRequests = yield pullRequestsApi.getBetweenDates(owner, repo, fromDate, toDate, configuration.max_pull_requests const pullRequests = yield pullRequestsApi.getBetweenDates(owner, repo, fromDate, toDate, (_b = configuration.max_pull_requests) !== null && _b !== void 0 ? _b : configuration_1.DefaultConfiguration.max_pull_requests);
? configuration.max_pull_requests core.info(`️ Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`);
: configuration_1.DefaultConfiguration.max_pull_requests); const prCommits = pullRequestsApi.filterCommits(commits, (_c = configuration.exclude_merge_branches) !== null && _c !== void 0 ? _c : configuration_1.DefaultConfiguration.exclude_merge_branches);
core.info(`Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`); core.info(`Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`);
const prCommits = pullRequestsApi.filterCommits(commits, configuration.exclude_merge_branches
? configuration.exclude_merge_branches
: configuration_1.DefaultConfiguration.exclude_merge_branches);
core.info(`Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`);
const filteredPullRequests = []; const filteredPullRequests = [];
const pullRequestsByNumber = {}; const pullRequestsByNumber = {};
for (const pr of pullRequests) { for (const pr of pullRequests) {
@@ -749,11 +752,11 @@ class ReleaseNotes {
filteredPullRequests.push(pullRequest); filteredPullRequests.push(pullRequest);
} }
else { else {
core.warning(`${prRef} not found! Commit text: ${commit.summary}`); core.warning(`⚠️ ${prRef} not found! Commit text: ${commit.summary}`);
} }
} }
else { else {
core.info(`${prRef} not in date range, excluding from changelog`); core.info(`${prRef} not in date range, excluding from changelog`);
} }
} }
return filteredPullRequests; return filteredPullRequests;
@@ -845,7 +848,7 @@ class Tags {
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
core.info(`Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`); core.info(`Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`);
return tagsInfo; return tagsInfo;
}); });
} }
@@ -857,7 +860,7 @@ class Tags {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (tags[i].name.toLowerCase() === tag.toLowerCase()) { if (tags[i].name.toLowerCase() === tag.toLowerCase()) {
if (ignorePreReleases) { if (ignorePreReleases) {
core.info(`Enabled 'ignorePreReleases', searching for the closest release`); core.info(`Enabled 'ignorePreReleases', searching for the closest release`);
for (let ii = i + 1; ii < length; ii++) { for (let ii = i + 1; ii < length; ii++) {
if (!tags[ii].name.includes('-')) { if (!tags[ii].name.includes('-')) {
return tags[ii]; return tags[ii];
@@ -874,6 +877,20 @@ class Tags {
} }
}); });
} }
/*
Sorts an array of tags as shown below:
2020.4.0
2020.4.0-rc02
2020.3.2
2020.3.1
2020.3.1-rc03
2020.3.1-rc02
2020.3.1-rc01
2020.3.1-b01
2020.3.1-a01
2020.3.0
*/
sortTags(commits) { sortTags(commits) {
commits.sort((b, a) => { commits.sort((b, a) => {
const partsA = a.name.replace(/^v/, '').split('-'); const partsA = a.name.replace(/^v/, '').split('-');
@@ -898,22 +915,6 @@ class Tags {
} }
} }
exports.Tags = Tags; exports.Tags = Tags;
/*
2020.3.2 ( should resolve 2020.3.1 )
2020.4.0
2020.4.0-rc02
2020.3.1
2020.3.1-rc03
2020.3.1-rc02
2020.3.1-rc01
2020.3.1-b01
2020.3.1-a01
2020.3.0
*/
/***/ }), /***/ }),
@@ -1046,7 +1047,7 @@ function validateTransfomers(specifiedTransformers) {
}; };
} }
catch (e) { catch (e) {
core.warning(`Bad replacer regex: ${transformer.pattern}`); core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`);
return { return {
pattern: null, pattern: null,
target: '' target: ''
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -3
View File
@@ -54,9 +54,7 @@ export class Commits {
compareHead = `${commits[0].sha}^` compareHead = `${commits[0].sha}^`
} }
core.info( core.info(`️ Found ${commits.length} commits from the GitHub API for ${owner}/${repo}`)
`Found ${commits.length} commits from the GitHub API for ${owner}/${repo}`
)
return commits.map(commit => ({ return commits.map(commit => ({
sha: commit.sha, sha: commit.sha,
summary: commit.commit.message.split('\n')[0], summary: commit.commit.message.split('\n')[0],
+3 -3
View File
@@ -75,21 +75,21 @@ async function run(): Promise<void> {
} }
if (!owner) { if (!owner) {
core.error(`Missing or couldn't resolve 'owner'`) core.error(`💥 Missing or couldn't resolve 'owner'`)
return return
} else { } else {
core.debug(`Resolved 'owner' as ${owner}`) core.debug(`Resolved 'owner' as ${owner}`)
} }
if (!repo) { if (!repo) {
core.error(`Missing or couldn't resolve 'owner'`) core.error(`💥 Missing or couldn't resolve 'owner'`)
return return
} else { } else {
core.debug(`Resolved 'repo' as ${repo}`) core.debug(`Resolved 'repo' as ${repo}`)
} }
if (!toTag) { if (!toTag) {
core.error(`Missing or couldn't resolve 'toTag'`) core.error(`💥 Missing or couldn't resolve 'toTag'`)
return return
} else { } else {
core.debug(`Resolved 'toTag' as ${toTag}`) core.debug(`Resolved 'toTag' as ${toTag}`)
+2 -2
View File
@@ -55,7 +55,7 @@ export class PullRequests {
}) })
} }
} catch (e) { } catch (e) {
core.warning(`Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`) core.warning(`⚠️ Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`)
return null return null
} }
} }
@@ -108,7 +108,7 @@ export class PullRequests {
mergedPRs.length >= maxPullRequests mergedPRs.length >= maxPullRequests
) { ) {
if (mergedPRs.length >= maxPullRequests) { if (mergedPRs.length >= maxPullRequests) {
core.info(`Reached 'maxPullRequests' count ${maxPullRequests}`) core.info(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`)
} }
// bail out early to not keep iterating on PRs super old // bail out early to not keep iterating on PRs super old
+21 -24
View File
@@ -26,6 +26,7 @@ export class ReleaseNotes {
const {owner, repo, toTag, ignorePreReleases, configuration} = this.options const {owner, repo, toTag, ignorePreReleases, configuration} = this.options
if (!this.options.fromTag) { if (!this.options.fromTag) {
core.startGroup(`:bookmark: Resolve 'fromTag'`)
core.debug(`fromTag undefined, trying to resolve via API`) core.debug(`fromTag undefined, trying to resolve via API`)
const tagsApi = new Tags(octokit) const tagsApi = new Tags(octokit)
@@ -38,41 +39,47 @@ export class ReleaseNotes {
DefaultConfiguration.max_tags_to_fetch DefaultConfiguration.max_tags_to_fetch
) )
if (previousTag == null) { if (previousTag == null) {
core.error(`Unable to retrieve previous tag given ${toTag}`) core.error(`💥 Unable to retrieve previous tag given ${toTag}`)
return ( return (
configuration.empty_template ?? DefaultConfiguration.empty_template configuration.empty_template ?? DefaultConfiguration.empty_template
) )
} }
this.options.fromTag = previousTag.name this.options.fromTag = previousTag.name
core.debug(`fromTag resolved via previousTag as: ${previousTag.name}`) core.debug(`fromTag resolved via previousTag as: ${previousTag.name}`)
core.endGroup()
} }
core.startGroup(`🚀 Load pull requests`)
const mergedPullRequests = await this.getMergedPullRequests(octokit) const mergedPullRequests = await this.getMergedPullRequests(octokit)
core.endGroup()
if (mergedPullRequests.length === 0) { if (mergedPullRequests.length === 0) {
core.warning(`No pull requests found`) core.warning(`⚠️ No pull requests found`)
return configuration.empty_template ?? DefaultConfiguration.empty_template return configuration.empty_template ?? DefaultConfiguration.empty_template
} }
return buildChangelog(mergedPullRequests, configuration) core.startGroup("📦 Build changelog")
const resultChangelog = buildChangelog(mergedPullRequests, configuration)
core.endGroup()
return resultChangelog
} }
private async getMergedPullRequests( private async getMergedPullRequests(
octokit: Octokit octokit: Octokit
): Promise<PullRequestInfo[]> { ): Promise<PullRequestInfo[]> {
const {owner, repo, fromTag, toTag, configuration} = this.options const {owner, repo, fromTag, toTag, configuration} = this.options
core.info(`Comparing ${owner}/${repo} - ${fromTag}...${toTag}`) core.info(`Comparing ${owner}/${repo} - ${fromTag}...${toTag}`)
const commitsApi = new Commits(octokit) const commitsApi = new Commits(octokit)
let commits: CommitInfo[] let commits: CommitInfo[]
try { try {
commits = await commitsApi.getDiff(owner, repo, fromTag!!, toTag) commits = await commitsApi.getDiff(owner, repo, fromTag!!, toTag)
} catch (error) { } catch (error) {
core.error(`Failed to retrieve - Invalid tag? - Because of: ${error}`) core.error(`💥 Failed to retrieve - Invalid tag? - Because of: ${error}`)
return [] return []
} }
if (commits.length === 0) { if (commits.length === 0) {
core.warning(`No commits found between - ${fromTag}...${toTag}`) core.warning(`💥 No commits found between - ${fromTag}...${toTag}`)
return [] return []
} }
@@ -86,13 +93,11 @@ export class ReleaseNotes {
DefaultConfiguration.max_back_track_time_days DefaultConfiguration.max_back_track_time_days
const maxFromDate = toDate.clone().subtract(maxDays, 'days') const maxFromDate = toDate.clone().subtract(maxDays, 'days')
if (maxFromDate.isAfter(fromDate)) { if (maxFromDate.isAfter(fromDate)) {
core.info(`Adjusted 'fromDate' to go max ${maxDays} back`) core.info(`⚠️ Adjusted 'fromDate' to go max ${maxDays} back`)
fromDate = maxFromDate fromDate = maxFromDate
} }
core.info( core.info(`️ Fetching PRs between dates ${fromDate.toISOString()} to ${toDate.toISOString()} for ${owner}/${repo}`)
`Fetching PRs between dates ${fromDate.toISOString()} to ${toDate.toISOString()} for ${owner}/${repo}`
)
const pullRequestsApi = new PullRequests(octokit) const pullRequestsApi = new PullRequests(octokit)
const pullRequests = await pullRequestsApi.getBetweenDates( const pullRequests = await pullRequestsApi.getBetweenDates(
@@ -100,25 +105,17 @@ export class ReleaseNotes {
repo, repo,
fromDate, fromDate,
toDate, toDate,
configuration.max_pull_requests configuration.max_pull_requests ?? DefaultConfiguration.max_pull_requests
? configuration.max_pull_requests
: DefaultConfiguration.max_pull_requests
) )
core.info( core.info(`️ Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`)
`Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`
)
const prCommits = pullRequestsApi.filterCommits( const prCommits = pullRequestsApi.filterCommits(
commits, commits,
configuration.exclude_merge_branches configuration.exclude_merge_branches ?? DefaultConfiguration.exclude_merge_branches
? configuration.exclude_merge_branches
: DefaultConfiguration.exclude_merge_branches
) )
core.info( core.info(`️ Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`)
`Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`
)
const filteredPullRequests = [] const filteredPullRequests = []
const pullRequestsByNumber: {[key: number]: PullRequestInfo} = {} const pullRequestsByNumber: {[key: number]: PullRequestInfo} = {}
@@ -146,10 +143,10 @@ export class ReleaseNotes {
if (pullRequest) { if (pullRequest) {
filteredPullRequests.push(pullRequest) filteredPullRequests.push(pullRequest)
} else { } else {
core.warning(`${prRef} not found! Commit text: ${commit.summary}`) core.warning(`⚠️ ${prRef} not found! Commit text: ${commit.summary}`)
} }
} else { } else {
core.info(`${prRef} not in date range, excluding from changelog`) core.info(`${prRef} not in date range, excluding from changelog`)
} }
} }
+16 -23
View File
@@ -39,9 +39,7 @@ export class Tags {
} }
} }
core.info( core.info(`️ Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`)
`Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`
)
return tagsInfo return tagsInfo
} }
@@ -59,9 +57,7 @@ export class Tags {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (tags[i].name.toLowerCase() === tag.toLowerCase()) { if (tags[i].name.toLowerCase() === tag.toLowerCase()) {
if (ignorePreReleases) { if (ignorePreReleases) {
core.info( core.info(`️ Enabled 'ignorePreReleases', searching for the closest release`)
`Enabled 'ignorePreReleases', searching for the closest release`
)
for (let ii = i + 1; ii < length; ii++) { for (let ii = i + 1; ii < length; ii++) {
if (!tags[ii].name.includes('-')) { if (!tags[ii].name.includes('-')) {
return tags[ii] return tags[ii]
@@ -77,6 +73,20 @@ export class Tags {
} }
} }
/*
Sorts an array of tags as shown below:
2020.4.0
2020.4.0-rc02
2020.3.2
2020.3.1
2020.3.1-rc03
2020.3.1-rc02
2020.3.1-rc01
2020.3.1-b01
2020.3.1-a01
2020.3.0
*/
private sortTags(commits: TagInfo[]): TagInfo[] { private sortTags(commits: TagInfo[]): TagInfo[] {
commits.sort((b, a) => { commits.sort((b, a) => {
const partsA = a.name.replace(/^v/, '').split('-') const partsA = a.name.replace(/^v/, '').split('-')
@@ -97,20 +107,3 @@ export class Tags {
return commits return commits
} }
} }
/*
2020.3.2 ( should resolve 2020.3.1 )
2020.4.0
2020.4.0-rc02
2020.3.1
2020.3.1-rc03
2020.3.1-rc02
2020.3.1-rc01
2020.3.1-b01
2020.3.1-a01
2020.3.0
*/
+1 -1
View File
@@ -146,7 +146,7 @@ function validateTransfomers(
target: transformer.target target: transformer.target
} }
} catch (e) { } catch (e) {
core.warning(`Bad replacer regex: ${transformer.pattern}`) core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`)
return { return {
pattern: null, pattern: null,
target: '' target: ''