Skip to content

🔀 develop → main: 2025-07-07 #47

🔀 develop → main: 2025-07-07

🔀 develop → main: 2025-07-07 #47

Workflow file for this run

name: Test
on:
push:
branches: [main, develop]
# paths:
# - 'src/**'
pull_request:
branches: [main, develop]
# paths:
# - 'src/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessário para cobertura precisa
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: |
npx vitest run --reporter=verbose --coverage --outputFile=coverage/coverage-summary.json
# Garante que a pasta de relatório existe
mkdir -p coverage/lcov-report
- name: Generate Coverage Badge
if: success() && github.ref == 'refs/heads/main' # Só executa se os testes passarem na branch main
run: |
# Extrai a cobertura do relatório HTML
COVERAGE=$(grep -E "All files.+[0-9.]+%" coverage/lcov-report/index.html | awk '{print $NF}' || echo "unknown")
# COVERAGE=$(jq -r '.total.statements.pct' coverage/coverage-summary.json)
echo "{\"coverage\":\"$COVERAGE\"}" > coverage-badge.json
echo "✔️ Coverage: $COVERAGE"
- name: Upload artifacts
if: success() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage-badge.json
coverage/coverage-summary.json
coverage/lcov-report
retention-days: 3