Skip to content

Commit

Permalink
chore(ci): remove update-comment (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Dec 24, 2024
1 parent 845b51e commit a9ca38d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 139 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/ecosystem-ci-from-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
76 changes: 0 additions & 76 deletions .github/workflows/ecosystem-ci-from-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '-'"
Expand Down Expand Up @@ -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
})

0 comments on commit a9ca38d

Please sign in to comment.