Skip to content

Commit

Permalink
- add configuration to force new comments for each run, instead of up…
Browse files Browse the repository at this point in the history
…dating the existing
  • Loading branch information
mikepenz authored Aug 30, 2024
1 parent 5147ec6 commit 0c0ff35
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
| `detailed_summary` | Optional. Include table with all test results in the summary. Defaults to `false`. |
| `flaky_summary` | Optional. Include table with all falky results in the summary. Defaults to `false`. |
| `comment` | Optional. Enables a comment being added to the PR with the summary tables (Respects the summary configuration flags). Defaults to `false`. |
| `updateComment` | Optional. If a prior action run comment exists, it is updated. If disabled, new comments are creted for each run. Defaults to `true`. |
| `annotate_notice` | Optional. Annotate passed test results along with warning/failed ones. Defaults to `false`. (Changed in v3.5.0) |
| `follow_symlink` | Optional. Enables to follow symlinks when searching test files via the globber. Defaults to `false`. |
| `job_name` | Optional. Specify the name of a check to update |
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ inputs:
required: false
default: 'false'
comment:
description: 'Enables a comment being added to the PR with the summary tables (summary has to be enabled).'
description: 'Enables a comment being added to the PR with the summary tables (summary has to be enabled). Default: false'
required: false
default: 'false'
updateComment:
description: 'Enables updating the prior comment if one already exists. Default: true'
required: false
default: 'true'
annotate_notice:
description: 'Annotate passed tests along with warning and failed ones'
required: false
Expand Down
7 changes: 4 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/annotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function buildCommentIdentifier(checkName: string[]): string {
export async function attachComment(
octokit: InstanceType<typeof GitHub>,
checkName: string[],
updateComment: boolean,
table: SummaryTableRow[],
detailsTable: SummaryTableRow[],
flakySummary: SummaryTableRow[]
Expand All @@ -242,7 +243,7 @@ export async function attachComment(
}
comment += `\n\n${identifier}`

const priorComment = await findPriorComment(octokit, identifier)
const priorComment = updateComment ? await findPriorComment(octokit, identifier) : undefined
if (priorComment) {
await octokit.rest.issues.updateComment({
owner: context.repo.owner,
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export async function run(): Promise<void> {
const detailedSummary = core.getInput('detailed_summary') === 'true'
const flakySummary = core.getInput('flaky_summary') === 'true'
const comment = core.getInput('comment') === 'true'
const updateComment = core.getInput('updateComment') === 'true'
const jobName = core.getInput('job_name')

const reportPaths = core.getMultilineInput('report_paths')
Expand Down Expand Up @@ -154,7 +155,7 @@ export async function run(): Promise<void> {

if (comment) {
const octokit: InstanceType<typeof GitHub> = github.getOctokit(token)
attachComment(octokit, checkName, table, detailTable, flakyTable)
attachComment(octokit, checkName, updateComment, table, detailTable, flakyTable)
}

core.setOutput('summary', buildTable(table))
Expand Down

0 comments on commit 0c0ff35

Please sign in to comment.