Repository navigation
ci: 部署时由 CI 写入 Worker 的 TABLE_PREFIX 绑定 (ONE-511) - #155
Merged
Merged
Conversation
- apps/worker/wrangler.toml 新增 [vars] TABLE_PREFIX 占位符,keep_vars 不变 - deploy.yml 把 Resolve TABLE_PREFIX 步移到 Inject 步之前,Inject 复用既有 sed 占位符替换机制写入已解析前缀(未配→hop、none→空字符串、其他原样), 既有 _PLACEHOLDER 残留 grep 自动覆盖 - test-deploy-checks.mjs 新增回归:直接执行 deploy.yml 里的 Inject 步脚本, 覆盖 SL / 默认 hop / none→空字符串三态且无占位符残留;Verify 比对覆盖 配置托管默认值、空字符串无前缀通过与不一致失败
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.
背景(规格 v1.1 §1,改动 A)
GitHub 变量
vars.TABLE_PREFIX此前只喂 CI 迁移与 Verify 期望值,没有任何一步给 Worker 本体写TABLE_PREFIX绑定。自定义前缀的全新安装时新 Worker 无绑定 → 运行时按默认hop解析,与按自定义前缀建的表对不上,Verify 必红。本 PR 让 CI 在部署时把 GitHub 变量作为单一真源写入 Worker 绑定。改动
apps/worker/wrangler.toml:新增[vars] TABLE_PREFIX = "TABLE_PREFIX_PLACEHOLDER";keep_vars = true不变。.github/workflows/deploy.ymlprefix)移到「Inject resource IDs」之前(该步只依赖vars.TABLE_PREFIX)。TABLE_PREFIX: ${{ steps.prefix.outputs.table_prefix }},并新增一行 sed 复用既有占位符替换机制:未配→默认hop;none→空字符串(toml 写"");其他→原值、大小写保留。既有「_PLACEHOLDER残留即失败」grep 自动覆盖新占位符。.github/scripts/resolve-table-prefix.mjs与verify-deployment.sh均未改动。.github/scripts/test-deploy-checks.mjs(改动 C 第 4、5 项)wrangler.toml副本上校验SL/ 未配默认hop/none→空字符串三态替换正确且无_PLACEHOLDER残留。wrangler.toml声明占位符且keep_vars = true;deploy.yml 中 Resolve 步在 Inject 步之前。hop、空字符串无前缀(TABLE_PREFIX: <none>)通过;绑定为空但期望hop、绑定hop但期望无前缀均失败。自测
node --test .github/scripts/test-d1-migrations.mjs .github/scripts/test-deploy-checks.mjs→ 37 tests, 37 passshellcheck .github/scripts/*.sh→ 通过pnpm check/pnpm typecheck/pnpm test(110 pass)/pnpm build→ 通过actionlint .github/workflows/deploy.yml→ 通过wrangler deploy --dry-run(注入后配置)确认env.TABLE_PREFIX以 Environment Variable 绑定出现;空字符串情形显示env.TABLE_PREFIX ("")不自行合并,交评审 + QA。