feat: better Tux, removed githooks, updated README #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Suite | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Run tests in Docker | |
run: make test | |
env: | |
CI: true | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.node-version }} | |
path: | | |
test-results/ | |
coverage/ | |
- name: Upload coverage to Codecov | |
if: matrix.node-version == '20.x' | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage/lcov.info | |
flags: unittests | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
- name: Comment PR with results | |
if: github.event_name == 'pull_request' && matrix.node-version == '20.x' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
// Read test results | |
let testSummary = '## Test Results\n\n'; | |
try { | |
const results = JSON.parse(fs.readFileSync('test-results/results.json', 'utf8')); | |
testSummary += `✅ **${results.numPassedTests}** passed\n`; | |
if (results.numFailedTests > 0) { | |
testSummary += `❌ **${results.numFailedTests}** failed\n`; | |
} | |
testSummary += `⏱️ Duration: ${(results.testResults[0].duration / 1000).toFixed(2)}s\n`; | |
} catch (e) { | |
testSummary += '❌ Failed to parse test results\n'; | |
} | |
// Read coverage summary | |
testSummary += '\n## Coverage\n\n'; | |
try { | |
const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8')); | |
const total = coverage.total; | |
testSummary += `| Type | Coverage |\n`; | |
testSummary += `|------|----------|\n`; | |
testSummary += `| Lines | ${total.lines.pct}% |\n`; | |
testSummary += `| Statements | ${total.statements.pct}% |\n`; | |
testSummary += `| Functions | ${total.functions.pct}% |\n`; | |
testSummary += `| Branches | ${total.branches.pct}% |\n`; | |
} catch (e) { | |
testSummary += '❌ Failed to parse coverage results\n'; | |
} | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: testSummary | |
}); | |
- name: Check coverage thresholds | |
if: matrix.node-version == '20.x' | |
run: | | |
node -e " | |
const coverage = require('./coverage/coverage-summary.json'); | |
const total = coverage.total; | |
const threshold = 80; | |
const failed = []; | |
if (total.lines.pct < threshold) failed.push('lines'); | |
if (total.statements.pct < threshold) failed.push('statements'); | |
if (total.functions.pct < threshold) failed.push('functions'); | |
if (total.branches.pct < threshold) failed.push('branches'); | |
if (failed.length > 0) { | |
console.error('Coverage thresholds not met for:', failed.join(', ')); | |
process.exit(1); | |
} else { | |
console.log('All coverage thresholds met!'); | |
} | |
" |