Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.

Report Status

Report Status #1

Workflow file for this run

name: Report Status
on:
workflow_run:
workflows: ["CI/CD Pipeline"]
types:
- completed
jobs:
report:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
issues: write
pull-requests: write
steps:
- name: Download all test results
uses: actions/download-artifact@v4
with:
name: test-results-${{ matrix.node-version }}
path: test-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Combine and post comment
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const path = require('path');
const pr = github.event.workflow_run.pull_requests[0];
if (!pr) {
console.log('No PR associated with this workflow run.');
return;
}
const issue_number = pr.number;
const testResultsDir = 'test-results';
let commentBody = '## Test Results Summary\n\n';
let overallStatus = '✅ All tests passed across all Node.js versions.';
let hasFailures = false;
const files = fs.readdirSync(testResultsDir);
for (const file of files) {
if (file.startsWith('test-results-') && file.endsWith('.json')) {
const nodeVersion = file.replace('test-results-', '').replace('.json', '');
const filePath = path.join(testResultsDir, file);
const results = JSON.parse(fs.readFileSync(filePath, 'utf8'));
commentBody += `### Node.js ${nodeVersion}\n`;
if (results.stats.failures > 0) {
hasFailures = true;
commentBody += `❌ **${results.stats.failures} of ${results.stats.tests} tests failed.**\n`;
overallStatus = '❌ Some tests failed. Please review the logs for details.';
} else {
commentBody += `✅ **All ${results.stats.tests} tests passed.**\n`;
}
for (const test of results.tests) {
commentBody += `- ${test.state === 'passed' ? '✅' : (test.state === 'failed' ? '❌' : '➖')} ${test.fullTitle}\n`; if (test.state === 'failed' && test.err) {
commentBody += ` \`\`\`\n ${test.err.message}\n \`\`\`\n`;
}
}
commentBody += '\n';
}
}
commentBody = `${overallStatus}\n\n${commentBody}`;
const owner = context.repo.owner;
const repo = context.repo.repo;
github.rest.issues.createComment({
owner,
repo,
issue_number,
body: commentBody
});