Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/02-tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
NODE_VERSION: '18'
CHALLENGE_LEVEL: 2
CHALLENGE_NAME: "testes-automatizados"
COVERAGE_MIN: 80 # Cobertura mínima exigida em porcentagem
COVERAGE_MIN: 99 # Cobertura mínima exigida em porcentagem

jobs:
tests-and-coverage:
Expand All @@ -20,18 +20,28 @@ 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@v5
with:
node-version: ${{env.NODE_VERSION}}

- name: "Instalar dependências"
run: npm ci
- name: "Executar testes"
run: npm run tests

- 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 "Coverage: $COVERAGE%"
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT


- name: "Validar se os testes passaram"
if: ${{steps.coverage.outputs.coverage < env.COVERAGE_MIN}}
run: |
echo "Cobertura mínima não atendida: Esperado - ${{ env.COVERAGE_MIN }}%. Atingido: ${{ steps.coverage.outputs.coverage }}%"
exit 1
generate-certificate: # DAQUI PARA BAIXO, NÃO ALTERAR
name: "Desafio Nível 2 - Certificado"
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"author": "LINUXtips",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5",
"helmet": "^7.0.0",
"dotenv": "^16.3.1",
"express": "^4.21.2",
"helmet": "^7.0.0",
"node-fetch": "^3.3.2"
},
"devDependencies": {
"jest": "^29.7.0",
"supertest": "^6.3.4",
"nyc": "^17.1.0"
"nyc": "^17.1.0",
"supertest": "^6.3.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down