From 9d48254d4461d34fffbfd071261f23facce4f688 Mon Sep 17 00:00:00 2001 From: KuaaMU <138859253+KuaaMU@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:12:39 +0800 Subject: [PATCH] ci: add GitHub Actions workflow for lint, typecheck, and tests Add a CI workflow that runs on pull requests and pushes to main: - lint: ESLint with max 0 warnings - typecheck: TypeScript compilation via tsc - test: Jest test suite with PostgreSQL 16 and Redis 7 service containers This ensures code quality checks run automatically on every PR, preventing regressions from being merged without validation. --- .github/workflows/ci.yml | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..447edc18c5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm run lint + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm run build + + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: "12345" + POSTGRES_DB: api_test + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis:7 + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + NODE_ENV: test + TYPEORM_HOST: localhost + TYPEORM_USERNAME: postgres + TYPEORM_PASSWORD: "12345" + TYPEORM_DATABASE: api_test + REDIS_HOST: localhost + REDIS_PORT: 6379 + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm run test