diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f6a74b8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Lint + run: bun run lint + continue-on-error: true # Pre-existing lint violations — non-blocking until cleanup + + - name: Type check + run: bun run build + + - name: Run tests + run: bun test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..33ecd32 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Release + +on: + push: + branches: + - main + tags: + - 'v*' + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Lint + run: bun run lint + continue-on-error: true + + - name: Type check + run: bun run build + + - name: Run tests + run: bun test + + docker: + needs: test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix= + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index df4946a..063d3a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM oven/bun:1 as frontend-builder WORKDIR /app/frontend # 拷贝前端的 package.json 和 lockfile -COPY frontend/package.json frontend/bun.lockb ./ +COPY frontend/package.json frontend/bun.lock* ./ # 安装前端依赖 RUN bun install --frozen-lockfile @@ -22,7 +22,7 @@ FROM oven/bun:1 as backend-builder WORKDIR /app # 拷贝后端的 package.json 和 lockfile -COPY package.json bun.lockb ./ +COPY package.json bun.lock* ./ # 只安装生产环境依赖 RUN bun install --frozen-lockfile --production diff --git a/bun.lock b/bun.lock index d8108e6..e2b4556 100644 --- a/bun.lock +++ b/bun.lock @@ -1,6 +1,5 @@ { "lockfileVersion": 1, - "configVersion": 0, "workspaces": { "": { "name": "ai-review", diff --git a/src/review/__tests__/file-review-store.test.ts b/src/review/__tests__/file-review-store.test.ts index 0cf3a28..8b936fd 100644 --- a/src/review/__tests__/file-review-store.test.ts +++ b/src/review/__tests__/file-review-store.test.ts @@ -351,7 +351,10 @@ describe('FileReviewStore', () => { const p3 = makePRPayload(); await store.createOrReuseRun(p1); + // Ensure distinct timestamps for sorting + await new Promise(r => setTimeout(r, 5)); await store.createOrReuseRun(p2); + await new Promise(r => setTimeout(r, 5)); await store.createOrReuseRun(p3); const runs = await store.listRuns(); diff --git a/tsconfig.json b/tsconfig.json index 9ee8c5f..c43e809 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -47,6 +47,8 @@ ], "exclude": [ "node_modules", - "dist" + "dist", + "src/**/__tests__/**", + "src/**/*.test.ts" ] }