Repository navigation
Conversation
- build.yml 的构建步骤改为 pnpm run build,与 deploy.yml 的部署命令一致, 避免 CI 校验的产物与实际发布的产物不是同一条链路 - 新增 pnpm test:unit(node --import tsx --test "src/**/*.test.ts")作为单元测试入口, 并在 CI 构建任务里执行;playwright 的 testDir/testMatch 仍限定 CodeGroupManager.spec.ts, 单元测试不会被它发现,因此需要独立入口 - 首个单测覆盖 date-utils 的纯日期判定、YYYY-MM-DD 格式化守卫、动态日期与偏移量归一化
👷 Deploy request for demo-firefly pending review.Visit the deploys page to approve it
|
审阅者指南配置添加单元测试脚本,并更新 CI,使其在完整生产构建之前运行该脚本。
文档更新测试指南,说明新的基于 Node 的单元测试入口。
测试添加回归测试,覆盖仅日期检测、日期格式化和时区偏移规范化。
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板,以便:
获取帮助Original review guide in EnglishReviewer's GuideConfigurationAdd the unit-test script and update CI to run it before the full production build.
DocumentationUpdate testing guidance to document the new Node-based unit-test entrypoint.
TestsAdd regression tests for date-only detection, date formatting, and timezone-offset normalization.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嗨,我发现了 2 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/build.yml" line_range="70" />
<code_context>
+ run: pnpm test:unit
+
+ - name: Run Site Build
+ run: pnpm run build
- name: Install Chromium for code group tests
</code_context>
<issue_to_address>
**VNDB outages block CI builds**
When VNDB is enabled in static mode and its API is unavailable or stalls, `pnpm run build` runs `generate-vndb-covers.ts` before Astro; its VNDB list request has no timeout or catch, so a stalled request hangs the build and a failed request aborts it before site generation.
Add a timeout and handle VNDB list-fetch failures so the build can use cached data or skip cover generation.
</issue_to_address>
### Comment 2
<location path="package.json" line_range="26" />
<code_context>
"github-cards": "npx tsx scripts/generate-github-card-data.ts",
- "test:code-groups": "playwright test"
+ "test:code-groups": "playwright test",
+ "test:unit": "node --import tsx --test \"src/**/*.test.ts\""
},
"dependencies": {
</code_context>
<issue_to_address>
**Unit tests are now configured**
When the new unit-test script is present and CI runs it, `test:unit` invokes Node’s `node:test` runner, and CI executes that script, so the repository no longer matches the entry’s stated absence of a configured unit-test framework.
Update or remove the knowledge-base entry to reflect the configured Node test runner.
</issue_to_address>Sourcery 评估
等待批准。 请先处理 1 项发现。
阻塞性发现:.github/workflows/build.yml:70
Original comment in English
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/build.yml" line_range="70" />
<code_context>
+ run: pnpm test:unit
+
+ - name: Run Site Build
+ run: pnpm run build
- name: Install Chromium for code group tests
</code_context>
<issue_to_address>
**VNDB outages block CI builds**
When VNDB is enabled in static mode and its API is unavailable or stalls, `pnpm run build` runs `generate-vndb-covers.ts` before Astro; its VNDB list request has no timeout or catch, so a stalled request hangs the build and a failed request aborts it before site generation.
Add a timeout and handle VNDB list-fetch failures so the build can use cached data or skip cover generation.
</issue_to_address>
### Comment 2
<location path="package.json" line_range="26" />
<code_context>
"github-cards": "npx tsx scripts/generate-github-card-data.ts",
- "test:code-groups": "playwright test"
+ "test:code-groups": "playwright test",
+ "test:unit": "node --import tsx --test \"src/**/*.test.ts\""
},
"dependencies": {
</code_context>
<issue_to_address>
**Unit tests are now configured**
When the new unit-test script is present and CI runs it, `test:unit` invokes Node’s `node:test` runner, and CI executes that script, so the repository no longer matches the entry’s stated absence of a configured unit-test framework.
Update or remove the knowledge-base entry to reflect the configured Node test runner.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: .github/workflows/build.yml:70
| run: pnpm test:unit | ||
|
|
||
| - name: Run Site Build | ||
| run: pnpm run build |
There was a problem hiding this comment.
🟡 中 · VNDB 故障会阻塞 CI 构建
当静态模式启用了 VNDB,而其 API 不可用或响应停滞时,pnpm run build 会在运行 Astro 之前执行 generate-vndb-covers.ts;其中的 VNDB 列表请求没有超时设置或错误捕获,因此请求停滞会导致构建挂起,请求失败则会在生成站点之前中止构建。
请添加超时并处理 VNDB 列表获取失败的情况,以便构建可以使用缓存数据或跳过封面生成。
面向 AI 智能体的提示
在 `.github/workflows/build.yml` 第 70 行:
**VNDB 故障会阻塞 CI 构建**
当静态模式启用了 VNDB,而其 API 不可用或响应停滞时,`pnpm run build` 会在运行 Astro 之前执行 `generate-vndb-covers.ts`;其中的 VNDB 列表请求没有超时设置或错误捕获,因此请求停滞会导致构建挂起,请求失败则会在生成站点之前中止构建。
请添加超时并处理 VNDB 列表获取失败的情况,以便构建可以使用缓存数据或跳过封面生成。Original comment in English
🟡 Medium · VNDB outages block CI builds
When VNDB is enabled in static mode and its API is unavailable or stalls, pnpm run build runs generate-vndb-covers.ts before Astro; its VNDB list request has no timeout or catch, so a stalled request hangs the build and a failed request aborts it before site generation.
Add a timeout and handle VNDB list-fetch failures so the build can use cached data or skip cover generation.
Prompt for AI agents
In `.github/workflows/build.yml` at line 70:
**VNDB outages block CI builds**
When VNDB is enabled in static mode and its API is unavailable or stalls, `pnpm run build` runs `generate-vndb-covers.ts` before Astro; its VNDB list request has no timeout or catch, so a stalled request hangs the build and a failed request aborts it before site generation.
Add a timeout and handle VNDB list-fetch failures so the build can use cached data or skip cover generation.There was a problem hiding this comment.
已核对本 PR 的提交 a51ceaa894:它只把 pnpm test:unit 接入 .github/workflows/build.yml,并在 AGENTS.md 记录该命令;没有引入 VNDB 配置或缺省超时。你指出的 fetch 无 timeout、异常直接向上传播属于既有 external-data 行为,不在 FF-6/FF-12 的范围内;在本 PR 中一并修改会混合关注点。该 thread 保留给 maintainer 决定是否另开修复,暂不 resolve。
- AGENTS.md no longer claims there is no unit-test framework.
Finding IDs: FF-6, FF-12.
问题
1. CI 构建的和发布的不是同一条链路。
build.yml的构建任务跑pnpm astro build,而实际部署的deploy.yml跑pnpm run build。后者的build脚本还包含 GitHub 卡片数据、LQIP、VNDB 封面、astro build --force、PIO 资源裁剪、字体子集化、内联脚本压缩与 Pagefind 索引。CI 因此只覆盖了链路的第一段:scripts/里的任何一步在生产构建里报错,或产物(字体子集、pagefind 索引、裁剪后的 PIO 资源)发生变化,CI 全绿也发现不了。2. 仓库没有单元测试入口。 唯一可运行的测试是
pnpm test:code-groups(Playwright),而playwright.config.ts:7-8把testDir与testMatch限定为src/components/features/CodeGroupManager.spec.ts一个文件;src/utils下大量纯函数(日期、URL、schema、feed 等)没有任何回归测试,往src/任意位置放*.test.ts也不会被执行。变更
.github/workflows/build.yml:构建步骤改为pnpm run build,与部署命令对齐;步骤名相应改为Run Site Build。.github/workflows/build.yml:构建任务在装完依赖后新增pnpm test:unit步骤(Node 22 / 24 两个矩阵都跑)。package.json:新增"test:unit": "node --import tsx --test \"src/**/*.test.ts\"",复用仓库已有的tsx依赖,不引入新依赖、不改 Playwright 配置(Playwright 的testMatch保持只跑那个 spec,否则会把node:test文件当成 Playwright 用例)。src/utils/date-utils.test.ts:首个单元测试,用node:test+node:assert/strict,只断言与运行时区无关的分支,保证 CI 结果稳定:isDateOnly:"2026-11-29"/ 带空格同串为纯日期,"2026-11-29T08:00:00+08:00"与2026-11-29T00:00:01Z不是;formatDateToYYYYMMDD:纯日期输入不随运行时区倒退一天,空串与非法日期返回空串;formatDynamicDate:纯日期补00:00:00,带时刻的值按 UTC 输出,空串返回空串;formatTimezoneOffset:GMT+08:00 → UTC+8、GMT+05:30 → UTC+5:30(去掉前导零、保留半小时偏移)。验证
pnpm test:unit:tests 6 / suites 4 / pass 6 / fail 0,耗时约 0.35s。pnpm run check(astro check):Result (264 files): - 0 errors - 0 warnings - 0 hints。pnpm run type-check(tsc --noEmit --isolatedDeclarations):无报错。pnpm run build全链路本地跑通:PagefindIndexed 18 pages / 5211 words,Finished in 0.147 seconds,构建结束后工作区除本 PR 的三处改动外无产物文件被改写(src/constants/github-card-data.json未变动)。pnpm exec biome check ./src:仅仓库既有的biome.jsonschema 2.6.3 与 CLI 2.6.8 版本提示。需要留意的是:构建任务现在会执行需要访问外部接口的脚本(GitHub API、VNDB)。这些脚本对失败是宽容的——单个仓库拉取失败会回落到已缓存数据并打印
[GITHUB-CARD] Failed to refresh ...,VNDB 封面失败也只console.warn,因此不会把 CI 变红,只是相应数据保持上一次的值。Sourcery 摘要
在 CI 中验证完整的生产构建,并添加可复用的单元测试入口,初步覆盖日期工具函数。
新功能:
src下的 TypeScript 测试。改进:
CI:
pnpm run build。测试:
Original summary in English
Sourcery 总结
在 CI 中验证生产构建,并建立可复用的单元测试工作流,初步覆盖日期工具函数。
新功能:
src下的 TypeScript 测试添加可复用的基于 Node 的单元测试入口。改进:
CI:
文档:
测试:
Original summary in English
Summary by Sourcery
Validate the production build in CI and establish a reusable unit-testing workflow with initial date utility coverage.
New Features:
src.Enhancements:
CI:
Documentation:
Tests: