From ee0e69702ef9bece78e502329dbe0212c0ebcfad Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 30 Apr 2024 01:03:39 -0700 Subject: [PATCH] Fix run URLs in CI comments --- .github/workflows/comment.yml | 2 +- packages/bun-internal-test/src/runner.node.mjs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index 44cdda3963..3c798e8fcc 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -37,7 +37,7 @@ jobs: else echo -e "✅ @${{ github.actor }}, all tests passed!" > comment.md fi - echo -e "\n**[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})**" >> comment.md + echo -e "\n**[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }})**" >> comment.md echo -e "" >> comment.md - name: Find Comment id: comment diff --git a/packages/bun-internal-test/src/runner.node.mjs b/packages/bun-internal-test/src/runner.node.mjs index 2cd2002c8c..9eba40bb8e 100644 --- a/packages/bun-internal-test/src/runner.node.mjs +++ b/packages/bun-internal-test/src/runner.node.mjs @@ -538,6 +538,13 @@ function mabeCapitalize(str) { } console.log("-> test-report.md, test-report.json"); +function linkify(text, url) { + if (url?.startsWith?.("https://")) { + return `[${text}](${url})`; + } + + return text; +} if (ci) { if (failing_tests.length > 0) { @@ -546,8 +553,11 @@ if (ci) { action.setOutput("failing_tests", failingTestDisplay); action.setOutput("failing_tests_count", failing_tests.length); if (failing_tests.length) { + const { env } = process; const tag = process.env.BUN_TAG || "unknown"; - let comment = `## ${emojiTag(tag)}${failing_tests.length} failing tests ${tag + const url = `${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}`; + + let comment = `## ${linkify(`${emojiTag(tag)}${failing_tests.length} failing tests`, url)} ${tag .split("-") .map(mabeCapitalize) .join(" ")}