Skip to content
Merged
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
236 changes: 92 additions & 144 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
name: CI

# FASE: Desenvolvimento local
#
# Etapas ativas agora:
# ✅ lint — ESLint 10 sobre src/
# ✅ typecheck — TypeScript 6 strict sem emissão
# ✅ testes — Vitest (passará vazio até os primeiros testes serem criados)
#
# Etapas pendentes (comentadas abaixo):
# ⏳ testes-integracao — precisa de MongoDB + Redis via Docker services
# ⏳ testes-e2e — precisa do servidor Fastify em execução
# ⏳ cobertura — habilitar após cobertura mínima atingida (80%)

on:
push:
branches: [main]
Expand All @@ -21,7 +9,7 @@ on:
permissions: {}

jobs:
# Lint e Typecheck
# ─── Qualidade estática ────────────────────────────────────────────────────
qualidade:
name: Lint e Typecheck
runs-on: ubuntu-latest
Expand All @@ -47,8 +35,8 @@ jobs:
- name: Typecheck
run: pnpm typecheck

# Testes unitários
testes:
# ─── Testes unitários (sem serviços externos) ─────────────────────────────
testes-unitarios:
name: Testes Unitários
runs-on: ubuntu-latest
needs: qualidade
Expand All @@ -69,132 +57,92 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Testes unitários
run: pnpm test

# Testes de integração
# ⏳ PENDENTE — habilitar quando os primeiros repositórios MongoDB/Redis
# estiverem implementados em src/modulos/*/infra/repositorios/
#
# testes-integracao:
# name: Testes de Integração
# runs-on: ubuntu-latest
# needs: testes
#
# services:
# mongodb:
# image: mongo:8.0
# env:
# MONGO_INITDB_ROOT_USERNAME: usuario
# MONGO_INITDB_ROOT_PASSWORD: senha
# 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://usuario:senha@localhost:27017/bem-vindo-test
# REDIS_URL: redis://localhost:6379
# NODE_ENV: test
#
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 22
# cache: pnpm
# - name: Instalar dependências
# run: pnpm install --frozen-lockfile
# - name: Testes de integração
# run: pnpm exec vitest run src/testes/integracao

# Testes E2E
# ⏳ PENDENTE — habilitar quando as rotas Fastify estiverem implementadas
# e os testes em src/testes/e2e/ criados.
# Requer os mesmos services de MongoDB e Redis acima.
#
# testes-e2e:
# name: Testes E2E
# runs-on: ubuntu-latest
# needs: testes-integracao
#
# services:
# mongodb:
# image: mongo:8.0
# env:
# MONGO_INITDB_ROOT_USERNAME: usuario
# MONGO_INITDB_ROOT_PASSWORD: senha
# 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://usuario:senha@localhost:27017/bem-vindo-test
# REDIS_URL: redis://localhost:6379
# NODE_ENV: test
# JWT_SECRETO: secreto-de-teste-minimo-32-caracteres-aqui
#
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 22
# cache: pnpm
# - name: Instalar dependências
# run: pnpm install --frozen-lockfile
# - name: Testes E2E
# run: pnpm exec vitest run src/testes/e2e

# Cobertura
# ⏳ PENDENTE — habilitar após os testes unitários atingirem cobertura
# mínima de 80% (configurado em vitest.config.ts).
#
# cobertura:
# name: Cobertura de Testes
# runs-on: ubuntu-latest
# needs: testes
#
# steps:
# - uses: actions/checkout@v4
# - uses: pnpm/action-setup@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 22
# cache: pnpm
# - name: Instalar dependências
# run: pnpm install --frozen-lockfile
# - 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: true
run: pnpm exec vitest run src/testes/unitarios

# ─── Cobertura (unit only) ─────────────────────────────────────────────────
cobertura:
name: Cobertura de Testes
runs-on: ubuntu-latest
needs: testes-unitarios
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- 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

# ─── 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

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Instalar dependências
run: pnpm install --frozen-lockfile

- name: Testes E2E
run: pnpm exec vitest run src/testes/e2e
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
- name: Validar commits do PR
uses: wagoid/commitlint-github-action@v6
with:
configFile: commitlint.config.js
configFile: commitlint.config.cjs
failOnWarnings: false
helpURL: https://github.com/${{ github.repository }}/blob/main/.claude/rules/core/03-convencoes-git.md
2 changes: 1 addition & 1 deletion commitlint.config.js → commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('@commitlint/types').UserConfig} */
export default {
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
Expand Down
Loading