Skip to content
Open
31 changes: 26 additions & 5 deletions .github/workflows/02-tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,37 @@ jobs:
- name: "Checkout do código"
uses: actions/checkout@v4

# INSIRA AQUI A LÓGICA PARA RODAR OS TESTES E VERIFICAR A COBERTURA
###
###
###
- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: "Instalar dependências"
run: npm install

- name: "Extrair porcentagem de cobertura" # Esse step será validado pelo desafio, não altere o nome. No final, ele deve gerar o output "coverage" com a porcentagem de cobertura.
id: coverage
run: |
COVERAGE=$(npx nyc report --reporter=text-summary | grep -oP 'Statements\s*:\s*\K[0-9\.]+(?=%)' | head -1)
echo "Rodando testes..."
npm run tests

echo "Gerando relatório de coverage..."
COVERAGE=$(npx nyc report --reporter=text-summary | awk '/Statements/ {print $3}' | tr -d '%')

if [ -z "$COVERAGE" ]; then
echo "Erro ao capturar coverage"
exit 1
fi

echo "Coverage: $COVERAGE%"

if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "Coverage menor que 80%"
exit 1
else
echo "Coverage maior ou igual a 80%"
fi

echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT

generate-certificate: # DAQUI PARA BAIXO, NÃO ALTERAR
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Descomplicando GitHub Actions
Aluno: Leonardo Castilho

Se inscreva na aula ao vivo e gratuita: https://quiz.linuxtips.io/github-actions

Expand Down
Empty file added teste.txt
Empty file.