Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/pr-comment-stale-banner-via-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
43 changes: 25 additions & 18 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ jobs:
if: steps.find-comment.outputs.comment-id != ''
id: get-comment
uses: actions/github-script@v7
env:
STARTED_AT: ${{ github.run_started_at }}
with:
script: |
const fs = require('fs');
const comment = await github.rest.issues.getComment({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -49,7 +52,7 @@ jobs:
// Extract the results section (everything after the header and running message)
const body = comment.data.body;
// Remove any existing stale warning and running message
let resultsSection = body
const resultsSection = body
.replace(/<!-- benchmark-results -->\n## 📊 Benchmark Results\n\n> ⚠️ \*\*Results below are stale\*\*[^\n]*\n\n/g, '')
.replace(/<!-- benchmark-results -->\n## 📊 Benchmark Results\n\n/g, '')
.replace(/⏳ \*\*Benchmarks are running\.\.\.\*\*\n\n---\n_Started at:[^_]*_\n\n---\n\n/g, '')
Expand All @@ -58,8 +61,25 @@ jobs:

// If there's actual content left (benchmark tables), save it
if (resultsSection && resultsSection.includes('|')) {
// Write the full stale-banner message to disk and pass the
// path to the sticky-pull-request-comment action below.
// Inlining the previous results via `message:` blew past
// ARG_MAX once the benchmark tables grew large enough.
const startedAt = process.env.STARTED_AT;
const message =
'<!-- benchmark-results -->\n' +
'## 📊 Benchmark Results\n\n' +
'> ⚠️ **Results below are stale** and not from the latest commit. This comment will be updated when CI completes on the latest run.\n\n' +
'⏳ **Benchmarks are running...**\n\n' +
'---\n' +
`_Started at: ${startedAt}_\n\n` +
'---\n\n' +
resultsSection +
'\n';
const path = `${process.env.RUNNER_TEMP}/stale-comment.md`;
fs.writeFileSync(path, message);
core.setOutput('has-results', 'true');
core.setOutput('previous-results', resultsSection);
core.setOutput('stale-comment-path', path);
} else {
core.setOutput('has-results', 'false');
}
Expand All @@ -78,27 +98,14 @@ jobs:
This comment will be updated with the results when the benchmarks complete.

---
_Started at: ${{ github.event.pull_request.updated_at }}_
_Started at: ${{ github.run_started_at }}_

- name: Update existing benchmark comment with stale warning
if: steps.find-comment.outputs.comment-id != '' && steps.get-comment.outputs.has-results == 'true'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: benchmark-results
message: |
<!-- benchmark-results -->
## 📊 Benchmark Results

> ⚠️ **Results below are stale** and not from the latest commit. This comment will be updated when CI completes on the latest run.

⏳ **Benchmarks are running...**

---
_Started at: ${{ github.event.pull_request.updated_at }}_

---

${{ steps.get-comment.outputs.previous-results }}
path: ${{ steps.get-comment.outputs.stale-comment-path }}

- name: Update existing benchmark comment without results
if: steps.find-comment.outputs.comment-id != '' && steps.get-comment.outputs.has-results != 'true'
Expand All @@ -114,7 +121,7 @@ jobs:
This comment will be updated with the results when the benchmarks complete.

---
_Started at: ${{ github.event.pull_request.updated_at }}_
_Started at: ${{ github.run_started_at }}_

# Phase 1: Build all packages (not workbenches)
build:
Expand Down
43 changes: 25 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ jobs:
if: steps.find-comment.outputs.comment-id != ''
id: get-comment
uses: actions/github-script@v7
env:
STARTED_AT: ${{ github.run_started_at }}
with:
script: |
const fs = require('fs');
const comment = await github.rest.issues.getComment({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -49,15 +52,32 @@ jobs:
// Check if there are actual results (tables)
if (body.includes('|') && body.includes('Passed')) {
// Extract results section (everything after header)
let resultsSection = body
const resultsSection = body
.replace(/<!-- e2e-test-results -->\n## 🧪 E2E Test Results\n\n> ⚠️ \*\*Results below are stale\*\*[^\n]*\n\n/g, '')
.replace(/<!-- e2e-test-results -->\n## 🧪 E2E Test Results\n\n/g, '')
.replace(/⏳ \*\*Tests are running\.\.\.\*\*\n\n---\n_Started at:[^_]*_\n\n---\n\n/g, '')
.replace(/⏳ \*\*Tests are running\.\.\.\*\*\n\n---\n_Started at:[^_]*_/g, '')
.trim();
if (resultsSection && resultsSection.includes('|')) {
// Write the full stale-banner message to disk and pass the
// path to the sticky-pull-request-comment action below.
// Inlining the previous results via `message:` blew past
// ARG_MAX once the matrix doubled (snapshot + replay).
const startedAt = process.env.STARTED_AT;
const message =
'<!-- e2e-test-results -->\n' +
'## 🧪 E2E Test Results\n\n' +
'> ⚠️ **Results below are stale** and not from the latest commit. This comment will be updated when CI completes on the latest run.\n\n' +
'⏳ **Tests are running...**\n\n' +
'---\n' +
`_Started at: ${startedAt}_\n\n` +
'---\n\n' +
resultsSection +
'\n';
const path = `${process.env.RUNNER_TEMP}/stale-comment.md`;
fs.writeFileSync(path, message);
core.setOutput('has-results', 'true');
core.setOutput('previous-results', resultsSection);
core.setOutput('stale-comment-path', path);
} else {
core.setOutput('has-results', 'false');
}
Expand All @@ -79,27 +99,14 @@ jobs:
This comment will be updated with the results when the tests complete.

---
_Started at: ${{ github.event.pull_request.updated_at }}_
_Started at: ${{ github.run_started_at }}_

- name: Update existing test comment with stale warning
if: steps.find-comment.outputs.comment-id != '' && steps.get-comment.outputs.has-results == 'true'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: e2e-test-results
message: |
<!-- e2e-test-results -->
## 🧪 E2E Test Results

> ⚠️ **Results below are stale** and not from the latest commit. This comment will be updated when CI completes on the latest run.

⏳ **Tests are running...**

---
_Started at: ${{ github.event.pull_request.updated_at }}_

---

${{ steps.get-comment.outputs.previous-results }}
path: ${{ steps.get-comment.outputs.stale-comment-path }}

- name: Update existing test comment without results
if: steps.find-comment.outputs.comment-id != '' && steps.get-comment.outputs.has-results != 'true'
Expand All @@ -115,7 +122,7 @@ jobs:
This comment will be updated with the results when the tests complete.

---
_Started at: ${{ github.event.pull_request.updated_at }}_
_Started at: ${{ github.run_started_at }}_

unit:
name: Unit Tests (${{ matrix.os }})
Expand Down
Loading