From a31b6107883a5955f1ec31a75b1554d620ea1320 Mon Sep 17 00:00:00 2001 From: Heitor Rosa Date: Mon, 2 Mar 2026 15:04:23 -0300 Subject: [PATCH] chore: replace Makefile with Taskfile chore: remove unused test target from Taskfile --- .github/workflows/ci.yml | 6 +- Taskfile.yml | 126 +++++++++++++++++++++++++++++++++++++++ docs/testing.md | 10 ++-- 3 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 Taskfile.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5596b9..f80db50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..cd915ec --- /dev/null +++ b/Taskfile.yml @@ -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 diff --git a/docs/testing.md b/docs/testing.md index f3eba4b..15597c0 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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 | ---