Skip to content

Commit 20ae64c

Browse files
committed
ci: 修复 Docker 测试依赖遗漏并检查双架构构建
1 parent 06a456c commit 20ae64c

6 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎.dockerignore‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ config/tts-cache/
4040
# 构建阶段运行单元/集成测试;最终 standalone 镜像不复制测试目录
4141
coverage
4242

43-
# E2E 与外部测试、性能脚本
44-
e2e
43+
# 保留单元测试复用的 E2E 支持模块,排除浏览器用例与测试产物
44+
e2e/*
45+
!e2e/support
4546
playwright.config.ts
4647
playwright-report
4748
test-results

‎.github/workflows/ci.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,39 @@ jobs:
167167
- name: Build application
168168
run: npm run build
169169

170+
docker-build-check:
171+
name: Docker Build Check (${{ matrix.arch }})
172+
needs: publication-check
173+
if: "!startsWith(github.ref, 'refs/tags/')"
174+
timeout-minutes: 30
175+
strategy:
176+
fail-fast: false
177+
matrix:
178+
include:
179+
- arch: amd64
180+
platform: linux/amd64
181+
os: ubuntu-24.04
182+
- arch: arm64
183+
platform: linux/arm64
184+
os: ubuntu-24.04-arm
185+
runs-on: ${{ matrix.os }}
186+
steps:
187+
- name: Checkout repository
188+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
189+
190+
- name: Set up Docker Buildx
191+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
192+
193+
# 使用正式 Dockerfile 验证构建上下文、Alpine 测试及生产构建
194+
- name: Build Docker image without publishing
195+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
196+
with:
197+
context: .
198+
platforms: ${{ matrix.platform }}
199+
push: false
200+
cache-from: type=gha,scope=docker-${{ matrix.arch }}
201+
cache-to: type=gha,scope=docker-${{ matrix.arch }},mode=max
202+
170203
e2e-test:
171204
runs-on: ubuntu-latest
172205
name: E2E Tests

‎README.en.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ npm run test:e2e # Isolated app, migrated test database and local AI
505505
bash scripts/ci.sh # Full CI (Node.js 22+, Python 3, includes production build)
506506
```
507507

508+
GitHub CI for `main` and pull requests also uses the production Dockerfile to run tests and production builds on native amd64 and arm64 runners, without publishing images. `.dockerignore` keeps the `e2e/support` modules reused by unit tests while excluding browser test cases and test output from the build context.
509+
508510
The E2E launcher copies the app and dependencies into a system temporary directory, applies migrations, creates test accounts and builds the production app. Browser tests use fixed responses from a local AI service, with separate configuration and a temporary SQLite database. Reports are printed at the end. Filter cases with `npm run test:e2e -- --grep E2E-M01`. See the [E2E design and acceptance criteria](doc/E2E_MOCK_AI_TEST_DESIGN.md).
509511

510512
After changing `prisma/schema.prisma`, create a migration with `npx prisma migrate dev --name <name>` and commit it; migrations must be compatible with existing data. See [AGENTS.md](AGENTS.md) for more development conventions.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ npm run test:e2e # 隔离应用、正式迁移测试库与本地模
503503
bash scripts/ci.sh # 完整 CI(Node.js 22+、Python 3,含生产构建)
504504
```
505505

506+
GitHub 的 `main` 与 PR CI 还会使用正式 Dockerfile,在原生 amd64、arm64 环境中验证镜像内的测试和生产构建,检查通过后不推送镜像。`.dockerignore` 保留单元测试复用的 `e2e/support` 模块;浏览器用例和测试产物仍排除在构建上下文外。
507+
506508
E2E 启动器会在系统临时目录复制应用和依赖、执行正式迁移、生成测试账号并完成生产构建,随后使用本地固定模型响应运行浏览器用例。不会读取现有应用配置、复用开发服务器或访问外部模型。报告路径在命令结束时输出;可用 `npm run test:e2e -- --grep E2E-M01` 筛选用例。用例与运行边界见 [E2E 设计与验收](doc/E2E_MOCK_AI_TEST_DESIGN.md)。
507509

508510
修改 `prisma/schema.prisma` 后使用 `npx prisma migrate dev --name <名称>` 生成正式迁移并提交;迁移须兼容已有数据。更多开发约定见 [AGENTS.md](AGENTS.md)。

‎doc/wiki/Development.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ npm run test:e2e
4343

4444
CI 会运行 `npm run lint`,出现任何 ESLint 错误或警告都会失败。
4545

46+
`main` 与 PR CI 还会在原生 amd64、arm64 环境中使用正式 Dockerfile 完整构建镜像,验证 Alpine 内的 Vitest、脚本语法检查、数据库初始化与生产构建,检查过程不推送镜像。`.dockerignore` 须保留单元测试复用的 `e2e/support` 模块,浏览器用例及测试产物仍排除在构建上下文外。
47+
4648
`npm run test:coverage` 统计 `src/lib` 与 `src/app/api` 的测试覆盖率,低于 `vitest.config.mts` 中的阈值时失败;CI 会在任务摘要中显示覆盖率并上传报告。
4749

4850
`npm test` 运行全部 Vitest 测试。E2E 的环境要求与启动方式以仓库中的 [`playwright.config.ts`](https://github.com/margrop/wrong-notebook/blob/main/playwright.config.ts) 为准。

‎doc/wiki/en/Development-en.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Run `npm run test:e2e` to prepare an isolated production app, a migrated tempora
4343

4444
CI runs `npm run lint` and fails on any ESLint error or warning.
4545

46+
CI for `main` and pull requests also builds the complete image with the production Dockerfile on native amd64 and arm64 runners, covering Vitest in Alpine, script syntax checks, database initialization and the production build without publishing images. `.dockerignore` must keep the `e2e/support` modules reused by unit tests while excluding browser test cases and test output from the build context.
47+
4648
`npm run test:coverage` measures test coverage of `src/lib` and `src/app/api` and fails below the thresholds in `vitest.config.mts`; CI shows the coverage in the job summary and uploads the report.
4749

4850
`npm test` runs all Vitest tests. The E2E environment and startup are defined in the repository's [`playwright.config.ts`](https://github.com/margrop/wrong-notebook/blob/main/playwright.config.ts).

0 commit comments

Comments
 (0)