- 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
+1 -3
View File
@@ -54,9 +54,7 @@ export class Commits {
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 => ({
sha: commit.sha,
summary: commit.commit.message.split('\n')[0],
+3 -3
View File
@@ -75,21 +75,21 @@ async function run(): Promise<void> {
}
if (!owner) {
core.error(`Missing or couldn't resolve 'owner'`)
core.error(`💥 Missing or couldn't resolve 'owner'`)
return
} else {
core.debug(`Resolved 'owner' as ${owner}`)
}
if (!repo) {
core.error(`Missing or couldn't resolve 'owner'`)
core.error(`💥 Missing or couldn't resolve 'owner'`)
return
} else {
core.debug(`Resolved 'repo' as ${repo}`)
}
if (!toTag) {
core.error(`Missing or couldn't resolve 'toTag'`)
core.error(`💥 Missing or couldn't resolve 'toTag'`)
return
} else {
core.debug(`Resolved 'toTag' as ${toTag}`)
+2 -2
View File
@@ -55,7 +55,7 @@ export class PullRequests {
})
}
} catch (e) {
core.warning(`Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`)
core.warning(`⚠️ Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`)
return null
}
}
@@ -108,7 +108,7 @@ export class PullRequests {
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
+21 -24
View File
@@ -26,6 +26,7 @@ export class ReleaseNotes {
const {owner, repo, toTag, ignorePreReleases, configuration} = this.options
if (!this.options.fromTag) {
core.startGroup(`:bookmark: Resolve 'fromTag'`)
core.debug(`fromTag undefined, trying to resolve via API`)
const tagsApi = new Tags(octokit)
@@ -38,41 +39,47 @@ export class ReleaseNotes {
DefaultConfiguration.max_tags_to_fetch
)
if (previousTag == null) {
core.error(`Unable to retrieve previous tag given ${toTag}`)
core.error(`💥 Unable to retrieve previous tag given ${toTag}`)
return (
configuration.empty_template ?? DefaultConfiguration.empty_template
)
}
this.options.fromTag = previousTag.name
core.debug(`fromTag resolved via previousTag as: ${previousTag.name}`)
core.endGroup()
}
core.startGroup(`🚀 Load pull requests`)
const mergedPullRequests = await this.getMergedPullRequests(octokit)
core.endGroup()
if (mergedPullRequests.length === 0) {
core.warning(`No pull requests found`)
core.warning(`⚠️ No pull requests found`)
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(
octokit: Octokit
): Promise<PullRequestInfo[]> {
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)
let commits: CommitInfo[]
try {
commits = await commitsApi.getDiff(owner, repo, fromTag!!, toTag)
} catch (error) {
core.error(`Failed to retrieve - Invalid tag? - Because of: ${error}`)
core.error(`💥 Failed to retrieve - Invalid tag? - Because of: ${error}`)
return []
}
if (commits.length === 0) {
core.warning(`No commits found between - ${fromTag}...${toTag}`)
core.warning(`💥 No commits found between - ${fromTag}...${toTag}`)
return []
}
@@ -86,13 +93,11 @@ export class ReleaseNotes {
DefaultConfiguration.max_back_track_time_days
const maxFromDate = toDate.clone().subtract(maxDays, 'days')
if (maxFromDate.isAfter(fromDate)) {
core.info(`Adjusted 'fromDate' to go max ${maxDays} back`)
core.info(`⚠️ Adjusted 'fromDate' to go max ${maxDays} back`)
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(octokit)
const pullRequests = await pullRequestsApi.getBetweenDates(
@@ -100,25 +105,17 @@ export class ReleaseNotes {
repo,
fromDate,
toDate,
configuration.max_pull_requests
? configuration.max_pull_requests
: DefaultConfiguration.max_pull_requests
configuration.max_pull_requests ?? DefaultConfiguration.max_pull_requests
)
core.info(
`Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`
)
core.info(`️ Retrieved ${pullRequests.length} merged PRs for ${owner}/${repo}`)
const prCommits = pullRequestsApi.filterCommits(
commits,
configuration.exclude_merge_branches
? configuration.exclude_merge_branches
: DefaultConfiguration.exclude_merge_branches
configuration.exclude_merge_branches ?? DefaultConfiguration.exclude_merge_branches
)
core.info(
`Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`
)
core.info(`️ Retrieved ${prCommits.length} PR merge commits for ${owner}/${repo}`)
const filteredPullRequests = []
const pullRequestsByNumber: {[key: number]: PullRequestInfo} = {}
@@ -146,10 +143,10 @@ export class ReleaseNotes {
if (pullRequest) {
filteredPullRequests.push(pullRequest)
} else {
core.warning(`${prRef} not found! Commit text: ${commit.summary}`)
core.warning(`⚠️ ${prRef} not found! Commit text: ${commit.summary}`)
}
} 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(
`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
}
@@ -59,9 +57,7 @@ export class Tags {
for (let i = 0; i < length; i++) {
if (tags[i].name.toLowerCase() === tag.toLowerCase()) {
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++) {
if (!tags[ii].name.includes('-')) {
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[] {
commits.sort((b, a) => {
const partsA = a.name.replace(/^v/, '').split('-')
@@ -97,20 +107,3 @@ export class Tags {
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
}
} catch (e) {
core.warning(`Bad replacer regex: ${transformer.pattern}`)
core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`)
return {
pattern: null,
target: ''