From 2c4897094b74a9543d565634b4ae734ec21b80a5 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 17 Aug 2023 17:56:32 +0200 Subject: [PATCH] devops: hide previous Test results comments (#26516) There is no REST call for it, so we need to use GraphQL. References: - https://github.com/actions/github-script#run-custom-graphql-queries - https://docs.github.com/en/graphql/reference/mutations#minimizecomment - https://github.com/isaacs/github/issues/1480 --- .github/workflows/create_test_report.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/create_test_report.yml b/.github/workflows/create_test_report.yml index 2b4a57dc88..cee6645608 100644 --- a/.github/workflows/create_test_report.yml +++ b/.github/workflows/create_test_report.yml @@ -73,6 +73,24 @@ jobs: core.error('No pull request found for commit ' + context.sha + ' and workflow triggered by: ' + context.payload.workflow_run.event); return; } + { + // Mark previous comments as outdated by minimizing them. + const { data: comments } = await github.rest.issues.listComments({ + ...context.repo, + issue_number: prNumber, + }); + for (const comment of comments) { + if (comment.user.login === 'github-actions[bot]' && comment.body.includes('Test results')) { + await github.graphql(` + mutation { + minimizeComment(input: {subjectId: "${comment.node_id}", classifier: OUTDATED}) { + clientMutationId + } + } + `); + } + } + } const reportDir = 'run-${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}-${{ github.sha }}'; const reportUrl = `https://mspwblobreport.z1.web.core.windows.net/${reportDir}/index.html#?q=s%3Afailed%20s%3Aflaky`; core.notice('Report url: ' + reportUrl);