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
devops(ci): collapse stale triage comments (#41827)
Simon Knottaa212a9b4a7a
diff --git a/.github/workflows/create_test_report.yml b/.github/workflows/create_test_report.ymlindex be985b4350..0bc76438da 100644--- a/.github/workflows/create_test_report.yml+++ b/.github/workflows/create_test_report.yml@@ -196,6 +196,9 @@ jobs:GH_TOKEN: ${{ github.token }}WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}steps:+ - name: Checkout+ uses: actions/checkout@v6+- name: Download triage outputuses: actions/download-artifact@v4with:@@ -203,6 +206,19 @@ jobs:path: output- name: Post triage comment- run: |- printf '\n\n<sub>Triaged by the Playwright bot - [agent run](%s)</sub>\n<!-- playwright-ci-triage -->\n' "$WORKFLOW_URL" >> output/triage.md- gh issue comment "$PR_NUMBER" --repo "${{ github.repository }}" --body-file output/triage.md+ uses: actions/github-script@v9+ with:+ script: |+ const fs = require('fs');+ const { collapsePreviousComments } = require('./tests/config/postReportComment');+ const sentinel = `<!-- playwright-ci-triage --><!-- ${context.payload.workflow_run.name} -->`;+ const prNumber = +process.env.PR_NUMBER;+ await collapsePreviousComments(github, context, prNumber, sentinel);++ const triage = fs.readFileSync('output/triage.md', 'utf8');+ const body = `${triage}\n\n<sub>Triaged by the Playwright bot - [agent run](${process.env.WORKFLOW_URL})</sub>\n${sentinel}\n`;+ await github.rest.issues.createComment({+ ...context.repo,+ issue_number: prNumber,+ body,+ });diff --git a/tests/config/postReportComment.js b/tests/config/postReportComment.jsindex 55378d3a18..29d95d67a0 100644--- a/tests/config/postReportComment.js+++ b/tests/config/postReportComment.js@@ -28,7 +28,7 @@ async function postReportComment({ github, context, core, reportFile, prNumber,const report = fs.readFileSync(path.resolve(process.cwd(), reportFile), 'utf8');core.info(`Posting comment to PR #${prNumber}`);- const prNodeId = await collapsePreviousComments(github, context, prNumber);+ const prNodeId = await collapsePreviousComments(github, context, prNumber, magicComment(context));if (!prNodeId) {core.warning(`No PR node ID found for #${prNumber}, skipping GHA comment.`);return;@@ -50,7 +50,7 @@ function magicComment(context) {return `<!-- Generated by Playwright markdown reporter for ${workflowRunName(context)} in job ${process.env.GITHUB_JOB} -->`;}-async function collapsePreviousComments(github, context, prNumber) {+async function collapsePreviousComments(github, context, prNumber, sentinel) {const { owner, repo } = context.repo;const data = await github.graphql(`query($owner: String!, $repo: String!, $prNumber: Int!) {@@ -74,7 +74,7 @@ async function collapsePreviousComments(github, context, prNumber) {const comments = data.repository.pullRequest?.comments.nodes?.filter(comment =>comment?.author?.__typename === 'Bot' &&comment?.author?.login === 'github-actions' &&- comment.body?.includes(magicComment(context)));+ comment.body?.includes(sentinel));const prId = data.repository.pullRequest?.id;if (!comments?.length)return prId;@@ -126,4 +126,4 @@ function formatComment(lines) {return body;}-module.exports = { postReportComment };+module.exports = { collapsePreviousComments, postReportComment };