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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- run: pnpm install --frozen-lockfile

- name: Lint
run: make lint
run: task lint

- name: Typecheck
run: make typecheck
run: task typecheck

- name: Integration Tests
run: make ci-test
run: task ci-test
126 changes: 126 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
version: '3'

vars:
DEV_COMPOSE: docker/docker-compose.dev.yml
PROD_COMPOSE: docker/docker-compose.prod.yml
TEST_COMPOSE: docker/docker-compose.test.yml
TREE_IGNORE: node_modules|.git|dist|*.env*

tasks:

# ─────────────────────────────────────────────
# Environment
# ─────────────────────────────────────────────

check-env:
cmds:
- |
if [ -z "$DATABASE_URL" ]; then
echo "❌ DATABASE_URL não definida"
exit 1
fi

# ─────────────────────────────────────────────
# Quality
# ─────────────────────────────────────────────

lint:
cmds:
- pnpm lint

typecheck:
cmds:
- pnpm tsc --noEmit

# ─────────────────────────────────────────────
# CI
# ─────────────────────────────────────────────

ci-test:
cmds:
- task test-reset
- task test-up
- task test-migrate
- pnpm jest
- task test-down

# ─────────────────────────────────────────────
# DEV
# ─────────────────────────────────────────────

dev-up:
cmds:
- echo "🚧 Subindo Postgres DEV"
- docker compose -f {{.DEV_COMPOSE}} up -d

dev-stop:
cmds:
- echo "⏹️ Parando containers DEV"
- docker compose -f {{.DEV_COMPOSE}} stop

dev-start:
cmds:
- echo "▶️ Iniciando containers DEV"
- docker compose -f {{.DEV_COMPOSE}} start

dev-down:
cmds:
- echo "⬇️ Removendo containers DEV (mantendo volumes)"
- docker compose -f {{.DEV_COMPOSE}} down

dev-reset:
cmds:
- echo "💥 Resetando ambiente DEV (containers + volumes)"
- docker compose -f {{.DEV_COMPOSE}} down -v

dev-migrate:
deps: [check-env]
cmds:
- npx ts-node src/infrastructure/scripts/migrate.ts

# ─────────────────────────────────────────────
# PROD
# ─────────────────────────────────────────────

prod-up:
cmds:
- echo "🚀 Subindo Postgres PROD"
- docker compose -f {{.PROD_COMPOSE}} up -d

prod-migrate:
deps: [check-env]
cmds:
- npx ts-node src/infrastructure/scripts/migrate.ts

# ─────────────────────────────────────────────
# TEST
# ─────────────────────────────────────────────

test-up:
cmds:
- echo "🧪 Subindo Postgres TEST"
- docker compose -f {{.TEST_COMPOSE}} up -d --wait

test-down:
cmds:
- echo "⬇️ Removendo containers TEST (mantendo volumes)"
- docker compose -f {{.TEST_COMPOSE}} down

test-reset:
cmds:
- echo "💥 Resetando ambiente TEST (containers + volumes)"
- docker compose -f {{.TEST_COMPOSE}} down -v

test-migrate:
deps: [check-env]
cmds:
- npx ts-node src/infrastructure/scripts/migrate.ts

# ─────────────────────────────────────────────
# Utils
# ─────────────────────────────────────────────

tree:
cmds:
- echo "🌳 Estrutura de pastas"
- tree -a -L 6 -I "{{.TREE_IGNORE}}" --prune
10 changes: 5 additions & 5 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ This guarantees test isolation and reproducibility.

---

## Makefile Test Commands
## Taskfile Test Commands

| Command | Description |
| ------------------- | ------------------------------- |
| `make test-up` | Start PostgreSQL test container |
| `make test-reset` | Drop and recreate schema |
| `make test-migrate` | Execute SQL migrations |
| `make test` | Run Jest test suite |
| `task test-reset` | Drop and recreate schema |
| `task test-up` | Start PostgreSQL test container |
| `task test-migrate` | Execute SQL migrations |
| `task test` | Run Jest test suite |

---

Expand Down
Loading