Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(gha-reporter): minimize only relevant comments (#35648)
Max Schmitt7bf770143ca0
diff --git a/packages/playwright-dashboard/src/ghaMarkdownReporter.ts b/packages/playwright-dashboard/src/ghaMarkdownReporter.tsindex f54767c65d..1c2865c0dc 100644--- a/packages/playwright-dashboard/src/ghaMarkdownReporter.ts+++ b/packages/playwright-dashboard/src/ghaMarkdownReporter.ts@@ -33,8 +33,6 @@ function getGithubToken() {const octokit = getOctokit(getGithubToken());-const magicComment = '<!-- Generated by Playwright markdown reporter -->';-class GHAMarkdownReporter extends MarkdownReporter {override async publishReport(report: string) {core.info('Publishing report to PR.');@@ -77,7 +75,7 @@ class GHAMarkdownReporter extends MarkdownReporter {const comments = data.repository.pullRequest?.comments.nodes?.filter(comment =>comment?.author?.__typename === 'Bot' &&comment?.author?.login === 'github-actions' &&- comment.body?.includes(magicComment));+ comment.body?.includes(this._magicComment()));const prId = data.repository.pullRequest?.id;if (!comments?.length)return prId;@@ -91,13 +89,27 @@ class GHAMarkdownReporter extends MarkdownReporter {return prId;}+ private _magicComment() {+ return `<!-- Generated by Playwright markdown reporter for ${this._workflowRunName()} -->`;+ }++ private _workflowRunName() {+ // When used via 'workflow_run' event.+ const workflowRunName = context.payload.workflow_run?.name;+ if (workflowRunName)+ return workflowRunName;+ // When used via 'pull_request'/'push' event.+ // This is the name of the workflow file, e.g. 'ci.yml' or name if set.+ return process.env.GITHUB_WORKFLOW;+ }+private async addNewReportComment(prNodeId: string, report: string) {const reportUrl = process.env.HTML_REPORT_URL;const mergeWorkflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;const body = formatComment([- magicComment,- `### [Test results](${reportUrl}) for "${context.payload.workflow_run?.name}"`,+ this._magicComment(),+ `### ${reportUrl ? `[Test results](${reportUrl})` : 'Test results'} for "${this._workflowRunName()}"`,report,'',`Merge [workflow run](${mergeWorkflowUrl}).`