Skip to content

Move to MUI

Move to MUI #5

Workflow file for this run

name: Tests & Coverage
on:
pull_request:
branches: [ master, main, develop ]
jobs:
tests:
name: Run Tests & Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: |
go mod download
cd frontend && npm ci
- name: Run Go tests with coverage
run: go test ./... -v -coverprofile=coverage.out -covermode=atomic
- name: Run frontend tests with coverage
working-directory: ./frontend
run: |
export NODE_OPTIONS="--max-old-space-size=4096 --no-warnings"
npm run test:coverage
env:
NODE_ENV: test
VITEST_MAX_THREADS: 1
VITEST_MIN_THREADS: 1
CI: true
- name: Upload Go coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: backend
fail_ci_if_error: false
verbose: true
- name: Upload frontend coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./frontend/coverage
flags: frontend
fail_ci_if_error: false
verbose: true
- name: Coverage Report Comment
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const fs = require('fs');
// Read Go coverage
let goCoverageText = 'Not available';
try {
const coverageOutput = await exec.exec('go', ['tool', 'cover', '-func=coverage.out'], {
silent: true,
listeners: {
stdout: (data) => { goCoverageText = data.toString(); }
}
});
} catch (e) {
console.log('Go coverage parsing failed:', e);
}
// Extract Go coverage percentage
const goMatch = goCoverageText.match(/total:\s+\(statements\)\s+([\d.]+)%/);
const goCoverage = goMatch ? goMatch[1] + '%' : 'Parse failed';
// Read Frontend coverage
let frontendCoverage = 'Not available';
try {
if (fs.existsSync('./frontend/coverage/coverage-summary.json')) {
const summary = JSON.parse(fs.readFileSync('./frontend/coverage/coverage-summary.json', 'utf8'));
frontendCoverage = summary.total.statements.pct + '%';
}
} catch (e) {
console.log('Frontend coverage parsing failed:', e);
}
const comment = `## 📊 Test Coverage Report
| Component | Coverage |
|-----------|----------|
| 🔧 Go Backend | ${goCoverage} |
| ⚛️ Frontend | ${frontendCoverage} |
Coverage reports are also uploaded to [Codecov](https://codecov.io/gh/daniel-sullivan/babel-bridge/pull/${context.issue.number}) for detailed analysis.
---
*Coverage generated by GitHub Actions*`;
// Find and update existing comment or create new one
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComment = comments.data.find(c => c.body.includes('📊 Test Coverage Report'));
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}