From a9ca38dcd74208f96454b30005ed61ffed885b30 Mon Sep 17 00:00:00 2001 From: 9aoy Date: Tue, 24 Dec 2024 11:11:55 +0800 Subject: [PATCH] chore(ci): remove update-comment (#9) --- .../workflows/ecosystem-ci-from-commit.yml | 63 --------------- .github/workflows/ecosystem-ci-from-pr.yml | 76 ------------------- 2 files changed, 139 deletions(-) diff --git a/.github/workflows/ecosystem-ci-from-commit.yml b/.github/workflows/ecosystem-ci-from-commit.yml index c960389..340156f 100644 --- a/.github/workflows/ecosystem-ci-from-commit.yml +++ b/.github/workflows/ecosystem-ci-from-commit.yml @@ -101,66 +101,3 @@ jobs: pnpm tsx ecosystem-ci.ts run-suites ${{ matrix.suite }} - - update-comment: - runs-on: ubuntu-latest - needs: [execute-selected-suite, execute-all] - if: inputs.updateComment == true && always() - steps: - - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} - script: | - const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.runId, - per_page: 100 - }); - - const selectedSuite = context.payload.inputs.suite - let result - if (selectedSuite !== "-") { - const { conclusion, html_url } = jobs.find(job => job.name === "execute-selected-suite") - result = [{ suite: `${selectedSuite} ${context.payload.inputs.suiteRefType} ${context.payload.inputs.suiteRef}`, conclusion, link: html_url }] - } else { - result = jobs - .filter(job => job.name.startsWith('execute-all ')) - .map(job => { - const suite = job.name.replace(/^execute-all \(([^)]+)\)$/, "$1") - return { suite, conclusion: job.conclusion, link: job.html_url } - }) - } - - const allSuccess = result.every(r => r.conclusion === 'success'); - - if (allSuccess) { - // only update commit when suite failed - return; - } - - const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` - const urlLink = `[Open](${url})` - - const conclusionEmoji = { - success: ":white_check_mark:", - failure: ":x:", - cancelled: ":stop_button:" - } - - const body = ` - 📝 Ran ecosystem CI: ${urlLink} - - | suite | result | - |-------|--------| - ${result.map(r => `| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion]} ${r.conclusion} |`).join("\n")} - ` - - await github.rest.repos.createCommitComment({ - commit_sha: context.payload.inputs.commitSHA, - owner: 'web-infra-dev', - repo: 'rsbuild', - body - }) - - console.log(`https://github.com/web-infra-dev/rsbuild/commit/${context.payload.inputs.commitSHA}#comments`) diff --git a/.github/workflows/ecosystem-ci-from-pr.yml b/.github/workflows/ecosystem-ci-from-pr.yml index 72faaa3..b1de91a 100644 --- a/.github/workflows/ecosystem-ci-from-pr.yml +++ b/.github/workflows/ecosystem-ci-from-pr.yml @@ -51,28 +51,6 @@ on: default: "precoded" jobs: - create-comment: - runs-on: ubuntu-latest - outputs: - comment-id: ${{ steps.create-comment.outputs.result }} - steps: - - id: create-comment - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} - result-encoding: string - script: | - const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` - const urlLink = `[Open](${url})` - - const { data: comment } = await github.rest.issues.createComment({ - issue_number: context.payload.inputs.prNumber, - owner: 'web-infra-dev', - repo: 'rsbuild', - body: `⏳ Triggered ecosystem CI: ${urlLink}` - }) - return comment.id - execute-selected-suite: runs-on: ubuntu-latest if: "inputs.suite != '-'" @@ -122,57 +100,3 @@ jobs: pnpm tsx ecosystem-ci.ts run-suites ${{ matrix.suite }} - - update-comment: - runs-on: ubuntu-latest - needs: [create-comment, execute-selected-suite, execute-all] - if: always() - steps: - - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }} - script: | - const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.runId, - per_page: 100 - }); - - const selectedSuite = context.payload.inputs.suite - let result - if (selectedSuite !== "-") { - const { conclusion, html_url } = jobs.find(job => job.name === "execute-selected-suite") - result = [{ suite: `${selectedSuite} ${context.payload.inputs.suiteRefType} ${context.payload.inputs.suiteRef}`, conclusion, link: html_url }] - } else { - result = jobs - .filter(job => job.name.startsWith('execute-all ')) - .map(job => { - const suite = job.name.replace(/^execute-all \(([^)]+)\)$/, "$1") - return { suite, conclusion: job.conclusion, link: job.html_url } - }) - } - - const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` - const urlLink = `[Open](${url})` - - const conclusionEmoji = { - success: ":white_check_mark:", - failure: ":x:", - cancelled: ":stop_button:" - } - - const body = ` - 📝 Ran ecosystem CI: ${urlLink} - - | suite | result | - |-------|--------| - ${result.map(r => `| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion]} ${r.conclusion} |`).join("\n")} - ` - - await github.rest.issues.updateComment({ - owner: 'web-infra-dev', - repo: 'rsbuild', - comment_id: ${{ needs.create-comment.outputs.comment-id }}, - body - })