From 2bf4d5b22dcfaa9227c3035bb6c2861cc5b4834a Mon Sep 17 00:00:00 2001 From: "Diego Ferreira L.G.Oliveira" Date: Thu, 4 Jun 2026 15:59:04 -0300 Subject: [PATCH] =?UTF-8?q?fix(ci):=20rodar=20cobertura=20com=20suite=20co?= =?UTF-8?q?mpleta=20ap=C3=B3s=20testes=20E2E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4880b3..c04d0b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,14 +59,48 @@ jobs: - name: Testes unitários run: pnpm exec vitest run src/testes/unitarios - # ─── Cobertura (unit only) ───────────────────────────────────────────────── - cobertura: - name: Cobertura de Testes + # ─── Testes E2E (MongoDB + Redis) ───────────────────────────────────────── + testes-e2e: + name: Testes E2E runs-on: ubuntu-latest needs: testes-unitarios permissions: contents: read + services: + mongodb: + image: mongo:8.0 + env: + MONGO_INITDB_ROOT_USERNAME: administrador + MONGO_INITDB_ROOT_PASSWORD: 1qaz2sx12 + ports: + - 27017:27017 + options: >- + --health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: redis:8 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + env: + MONGO_URI: mongodb://administrador:1qaz2sx12@localhost:27017/bem-vindo-testes?authSource=admin + REDIS_URL: redis://localhost:6379 + NODE_ENV: test + JWT_SECRETO: jwt-secreto-de-teste-com-pelo-menos-32-chars + JWT_EXPIRACAO_ACCESS: 1h + JWT_EXPIRACAO_REFRESH: 7d + PORTA: 3000 + TZ: America/Sao_Paulo + steps: - uses: actions/checkout@v4 @@ -80,20 +114,14 @@ jobs: - name: Instalar dependências run: pnpm install --frozen-lockfile - - name: Gerar relatório de cobertura - run: pnpm exec vitest run --coverage src/testes/unitarios - - - name: Publicar cobertura - uses: codecov/codecov-action@v4 - with: - files: ./coverage/lcov.info - fail_ci_if_error: false + - name: Testes E2E + run: pnpm exec vitest run src/testes/e2e - # ─── Testes E2E (MongoDB + Redis) ───────────────────────────────────────── - testes-e2e: - name: Testes E2E + # ─── Cobertura (suite completa: unitários + E2E) ─────────────────────────── + cobertura: + name: Cobertura de Testes runs-on: ubuntu-latest - needs: testes-unitarios + needs: testes-e2e permissions: contents: read @@ -144,5 +172,11 @@ jobs: - name: Instalar dependências run: pnpm install --frozen-lockfile - - name: Testes E2E - run: pnpm exec vitest run src/testes/e2e + - name: Gerar relatório de cobertura + run: pnpm test:coverage + + - name: Publicar cobertura + uses: codecov/codecov-action@v4 + with: + files: ./coverage/lcov.info + fail_ci_if_error: false