From 85f37d2eaea43763576a3b49a93c3fbef2fc18c4 Mon Sep 17 00:00:00 2001 From: que01 Date: Mon, 12 Oct 2026 00:41:14 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=BB=BA=E7=AB=8B=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=A8=E7=A6=81=E6=B5=81=E6=B0=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 122 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 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 0000000..da0ba63 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,122 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + static: + name: Static checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9.15.0 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm check + - run: pnpm template:doctor + + build: + name: Production build + runs-on: ubuntu-latest + needs: [static] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9.15.0 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm build:admin:preview + - uses: actions/upload-artifact@v4 + with: + name: admin-dist + path: apps/admin/dist + retention-days: 7 + + api: + name: API integration + runs-on: ubuntu-latest + needs: [static] + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: personal_brand + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres -d personal_brand" + --health-interval 5s + --health-timeout 5s + --health-retries 12 + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9.15.0 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter @personal-brand/api test:integration + + browser: + name: Browser regression + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 9.15.0 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm --filter @personal-brand/taro exec playwright install --with-deps chromium + - run: pnpm --filter @personal-brand/api test:integration + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand + - name: Start API + run: pnpm --filter @personal-brand/api start > /tmp/api.log 2>&1 & + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/personal_brand + NODE_ENV: development + - name: Start mini program preview + run: pnpm --filter @personal-brand/taro dev:h5 > /tmp/taro.log 2>&1 & + env: + API_BASE_URL: http://localhost:3001 + BRAND_SLUG: default-brand + TEMPLATE_KEY: acheng-campus-food + - name: Start admin + run: pnpm --filter @personal-brand/admin dev > /tmp/admin.log 2>&1 & + env: + VITE_API_BASE_URL: /api + VITE_DEV_API_TARGET: http://localhost:3001 + VITE_TEMPLATE_PREVIEW_URL: http://localhost:3002 + - name: Wait for services + run: | + curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3001/health + curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3002 + curl --retry 30 --retry-delay 1 --retry-connrefused -fsS http://localhost:3000 + - run: pnpm --filter @personal-brand/taro exec playwright test --config=playwright.config.ts --reporter=line