Skip to content

GFE Promise.all Problem #49

GFE Promise.all Problem

GFE Promise.all Problem #49

Workflow file for this run

name: Run Tests
on:
pull_request:
branches: [main, develop]
paths:
- '**.js'
- '**.ts'
- 'package.json'
- 'package-lock.json'
- 'vitest.config.ts'
- '.github/workflows/test.yml'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
checks: write
jobs:
test:
runs-on: ubuntu-latest
name: Run Vitest Tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run test:coverage
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 30
- name: Comment PR with test results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
let coverageSummary = 'Coverage report not available';
try {
// Try to read coverage summary
const coverageFile = 'coverage/coverage-summary.json';
if (fs.existsSync(coverageFile)) {
const coverage = JSON.parse(fs.readFileSync(coverageFile, 'utf8'));
const total = coverage.total;
coverageSummary = `
## 📊 Coverage Summary
| Metric | Coverage |
|--------|----------|
| Statements | ${total.statements.pct}% |
| Branches | ${total.branches.pct}% |
| Functions | ${total.functions.pct}% |
| Lines | ${total.lines.pct}% |
`;
}
} catch (e) {
console.log('Could not read coverage summary:', e.message);
}
const comment = `## ✅ Test Results
Tests have been executed for this pull request.
${coverageSummary}
Check the workflow logs for detailed test output.
`;
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('Test Results')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}