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 @@ -33,13 +33,13 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
run: task lint
run: pnpm lint

- name: Typecheck
run: task typecheck
run: pnpm typecheck

- name: Build
run: pnpm build

- name: Integration Tests
run: task ci-test
run: task test
150 changes: 36 additions & 114 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ dotenv:
- .env.{{.ENV | default "test"}}

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*
NODE_VERSION:
sh: cat .node-version
Expand All @@ -17,150 +14,75 @@ env:
tasks:

# ─────────────────────────────────────────────
# Environment
# Core helpers
# ─────────────────────────────────────────────

compose:
desc: Run docker compose for an environment
cmds:
- docker compose --env-file .env.{{.ENV}} -f docker/docker-compose.{{.ENV}}.yml {{.CMD}}

check-env:
dotenv:
- .env.{{.ENV | default "test"}}
desc: Ensure required env vars exist
cmds:
- |
if [ -z "$DATABASE_URL" ]; then
echo "❌ DATABASE_URL not defined in .env.{{.ENV | default "test"}}"
echo "❌ DATABASE_URL missing in .env.{{.ENV}}"
exit 1
fi

migrate:
deps: [check-env]
dotenv:
- .env.{{.ENV | default "test"}}
cmds:
- pnpm migrate

# ─────────────────────────────────────────────
# Helpers
# Docker environments
# ─────────────────────────────────────────────

compose:
dotenv:
- .env.{{.ENV | default "test"}}
up:
desc: Start environment containers
cmds:
- docker compose -f {{.FILE}} {{.CMD}}

# ─────────────────────────────────────────────
# Quality
# ─────────────────────────────────────────────
- task compose ENV={{.ENV | default "test"}} CMD="up -d {{.ARGS}}"

lint:
down:
desc: Stop environment containers
cmds:
- pnpm lint
- task compose ENV={{.ENV | default "test"}} CMD="down {{.ARGS}}"

typecheck:
stop:
desc: Stop containers without removing
cmds:
- pnpm tsc --noEmit

# ─────────────────────────────────────────────
# CI
# ─────────────────────────────────────────────
- task compose ENV={{.ENV | default "test"}} CMD="stop"

ci-test:
vars:
ENV: test
dotenv:
- .env.test
start:
desc: Start existing containers
cmds:
- task test-reset
- task test-up
- task migrate
- |
pnpm jest || (task test-down && exit 1)
- task test-down
- task compose ENV={{.ENV | default "test"}} CMD="start"

test-watch:
vars:
ENV: test
dotenv:
- .env.test
reset:
desc: Reset environment (remove volumes)
cmds:
- pnpm jest {{.FILES}} --runInBand
- task compose ENV={{.ENV | default "test"}} CMD="down -v"

# ─────────────────────────────────────────────
# DEV
# Testing
# ─────────────────────────────────────────────

dev-up:
vars:
ENV: dev
cmds:
- echo "🚧 Starting DEV Postgres"
- task compose FILE={{.DEV_COMPOSE}} CMD="up -d"

dev-stop:
vars:
ENV: dev
test:
desc: Run test suite
cmds:
- echo "⏹️ Stopping DEV containers"
- task compose FILE={{.DEV_COMPOSE}} CMD="stop"

dev-start:
vars:
ENV: dev
cmds:
- echo "▶️ Starting DEV containers"
- task compose FILE={{.DEV_COMPOSE}} CMD="start"

dev-down:
vars:
ENV: dev
cmds:
- echo "⬇️ Removing DEV containers (keeping volumes)"
- task compose FILE={{.DEV_COMPOSE}} CMD="down"

dev-reset:
vars:
ENV: dev
cmds:
- echo "💥 Resetting DEV environment (containers + volumes)"
- task compose FILE={{.DEV_COMPOSE}} CMD="down -v"


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

prod-up:
vars:
ENV: prod
cmds:
- echo "🚀 Starting PROD Postgres"
- task compose FILE={{.PROD_COMPOSE}} CMD="up -d"


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

test-up:
vars:
ENV: test
cmds:
- echo "🧪 Starting TEST Postgres"
- task compose FILE={{.TEST_COMPOSE}} CMD="up -d --wait"

test-down:
vars:
ENV: test
cmds:
- echo "⬇️ Removing TEST containers (keeping volumes)"
- task compose FILE={{.TEST_COMPOSE}} CMD="down"
- task reset ENV=test
- task up ENV=test ARGS="--wait"
- task migrate ENV=test
- |
pnpm jest || (task down ENV=test && exit 1)
- task down ENV=test

test-reset:
vars:
ENV: test
test-watch:
desc: Run tests in watch mode
cmds:
- echo "💥 Resetting TEST environment (containers + volumes)"
- task compose FILE={{.TEST_COMPOSE}} CMD="down -v"

- pnpm jest {{.FILES}} --runInBand

# ─────────────────────────────────────────────
# Utils
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"typecheck": "tsc --noEmit",
"migrate": "node dist/src/tools/migrate.js",
"start": "nest start",
"start:debug": "nest start --debug --watch",
Expand Down
Loading