Repository navigation
test: 加四个真 build fixture、三层校验与仓库自身 dogfood - #1
Merged
Merged
Conversation
- tests/fixtures/ 四个最小项目,覆盖 Strategy A(python/node/go)与 C(node+postgres) - tests/validate-fixtures.sh 25 条静态断言,不需要 Docker - tests/check-fixture-refs.mjs 静态解析 compose build 引用,拦下"忘了写 Dockerfile" - tests/ci-run-fixture.sh + CI build-fixtures matrix job,真起容器跑 verify.sh - 仓库自身 .devcontainer/,容器启动即跑两套校验 - 修 templates/docker-compose.yml 缺 command: sleep infinity 导致容器秒退 - SKILL.md Strategy C 明确要求同时生成 Dockerfile - .gitattributes 覆盖 mjs/json/py/go/mod/txt/Dockerfile,.gitignore 加 pytest 缓存与原子写锁
CI 第一次真 build 抓到两条问题: 1. templates/node.jsonc 与 templates/deno.jsonc 用 typescript-node:22 却写 remoteUser: "vscode",该镜像只有 node 用户,容器启动即失败: unable to find user vscode: no matching entries in passwd file 镜像实际用户已逐个核对 devcontainer.metadata label: typescript-node/javascript-node -> node,universal -> codespace, 其余 devcontainers/* -> vscode。 2. node-postgres 的 compose build 失败: additional privileges requested: pass "--allow=fs.read=.../Dockerfile-with-features" Compose >= v2.39 默认走 bake,Buildx >= v0.37.2 拒绝 context 之外的 Dockerfile(devcontainers/cli#1320)。CI 设 BUILDX_BAKE_ENTITLEMENTS_FS=0。 把这条规则变成静态校验,避免同类问题再靠 CI 才发现: - tests/image-user.mjs:镜像到用户的映射表,供两处校验共用 - tests/check-template-user.mjs:13 个模板的 remoteUser 必须匹配 - tests/check-fixture-user.mjs:fixture 无 image 字段时回落到 Dockerfile 的 FROM - tests/parse-jsonc.mjs:带注释的 JSONC 解析,模板可以写说明性注释 模板断言 33 -> 46 条,fixture 断言 24 -> 25 条。 顺带:node-postgres 的 DATABASE_URL 测试在宿主机上跳过(变量只在容器里 注入,verify.sh 已单独断言它存在),避免本地跑测试时误报。
参考 shadcn/ui、zed、vite、astro、ghostty、bun、supabase 的 README, 把它们共有的结构搬过来: - 英雄区:居中标题 + 一句话定位 + 一行 · 分隔的导航锚点 - 代码先行:用一段对话示例代替段落描述「它做什么」 - 覆盖范围收成三行表格,完整镜像映射折进 <details>,不再铺 13 行 - 新增「状态」表:诚实列出做到的与没做到的(Kotlin/Scala/Swift/Deno 只有静态断言、MySQL/MongoDB 只做了 config 校验、CI 只跑 Linux、 没有生成结果的端到端冒烟) - 坑位清单从 12 条补到 13 条,加入 unable to find user vscode 和 Compose >= v2.39 的 bake 报错 - 删除原「目录」段(导航已在英雄区),删除重复的三策略文字说明 353 行 -> 282 行,信息量不减,保留三张 mermaid 图作为差异化。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 PR 做了什么
补上 P0 剩下的两条:真实 build 测试 和 仓库自身 dogfood。
之前所有校验都是静态的 —— 能证明模板文件格式正确,证明不了「按这个模板生成的配置真的能起容器」。
三层校验
bash tests/validate-templates.shbash tests/validate-fixtures.sh.sshbash tests/ci-run-fixture.sh tests/fixtures/<name>devcontainer up起容器,在里面跑该 fixture 的verify.sh四个 fixture
python-pippip install --user在非 root 下可写、pytest 能跑node-npmnpm ci走 lockfile、真装了依赖、workspace 可写go-modgo mod download/go vet/go test容器内全绿node-postgresDATABASE_URL注入、workspaceFolder挂载、容器内连得到 dbtests/check-fixture-refs.mjs把「Strategy C 忘了写 Dockerfile」这个 bug class 机器化拦截:静态解析 compose 的
build.dockerfile和context,逐个stat,不用付docker build的代价。三种改坏方式都能拦住(已实测,之后已还原):
CI
新增
build-fixturesjob,matrix 并发跑四个 fixture,每个走devcontainer up→devcontainer exec bash verify.sh。原validatejob 里加了validate-fixtures.sh。dogfood
.devcontainer/devcontainer.json里postCreateCommand是两套校验串起来 —— 容器一起来就自检,生成的配置坏了开发环境自己先叫。顺带修掉的真问题
templates/docker-compose.yml缺command: sleep infinity—— app 服务进程结束容器就退出。npm ci根本不创建node_modules,test -d node_modules会假失败,而如果去掉它,npm ci完全没跑也照样 PASS。已给两个 node fixture 加了真依赖[email protected]。go.mod写go 1.26本地跑不了 —— Go 会尝试下载对应 toolchain。改成go 1.23,容器实际版本由verify.sh单独断言。已知局限
本机没有 Docker,第三层(真 build)一次都没在本地跑过。
ci-run-fixture.sh只验证到前置检查正确报错退出。这个 PR 的 CI 就是它第一次真跑 —— 挂了在这个 PR 里修。本地验证