Code Coverage Summary #9
This file contains 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: Code Coverage Summary | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: ['16', '18', '20'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
# Instalar una versión específica de pnpm dependiendo de la versión de Node.js | |
- name: Install pnpm | |
run: | | |
if [[ "${{ matrix.node-version }}" == "16" ]]; then | |
npm install -g pnpm@7 # Versión compatible con Node.js 16.x | |
else | |
npm install -g pnpm@9 # Para Node.js 18.x y superiores | |
fi | |
# Verificar si el archivo pnpm-lock.yaml existe, y manejar instalación dependiendo de su presencia | |
- name: Install Dependencies | |
run: | | |
if [ -f pnpm-lock.yaml ]; then | |
echo "pnpm-lock.yaml encontrado, ejecutando instalación con frozen lockfile" | |
pnpm install --prefer-frozen-lockfile || pnpm install | |
else | |
echo "pnpm-lock.yaml no encontrado, ejecutando instalación normal" | |
pnpm install | |
fi | |
# Ejecutar las pruebas con Jest | |
- name: Run Jest Tests with Coverage | |
run: pnpm test -- --coverage | |
# Generar reporte de cobertura de código | |
- name: Code Coverage Report | |
uses: irongut/[email protected] | |
with: | |
filename: "coverage/**/cobertura-coverage.xml" | |
badge: true | |
fail_below_min: true | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: true | |
indicators: true | |
output: both | |
thresholds: "60 80" | |
# Subir artefacto de cobertura | |
- name: Upload Coverage Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report-node-${{ matrix.node-version }} | |
path: coverage/ |