create-dwy 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/package.json +3 -2
  2. package/src/create.js +5 -2
  3. package/src/prompts/grouped-checkbox.js +223 -0
  4. package/src/sync.js +45 -19
  5. package/templates/claude-global/hooks/pre-git-commit-sensitive-check.sh +0 -0
  6. package/templates/claude-global/rules/dwy-android-core.md +1 -0
  7. package/templates/claude-global/rules/dwy-db-migration.md +1 -0
  8. package/templates/claude-global/rules/dwy-flutter-core.md +1 -0
  9. package/templates/claude-global/rules/dwy-flutter-network.md +1 -0
  10. package/templates/claude-global/rules/dwy-flutter-router.md +1 -0
  11. package/templates/claude-global/rules/dwy-flutter-testing.md +1 -0
  12. package/templates/claude-global/rules/dwy-postgres.md +1 -0
  13. package/templates/claude-global/rules/dwy-python-backend.md +44 -3
  14. package/templates/claude-global/rules/dwy-python-core.md +36 -2
  15. package/templates/claude-global/rules/dwy-python-testing.md +1 -0
  16. package/templates/claude-global/rules/dwy-redis.md +1 -0
  17. package/templates/claude-global/rules/dwy-tdd-development.md +1 -0
  18. package/templates/claude-global/rules/dwy-vue-core.md +3 -43
  19. package/templates/claude-global/rules/dwy-vue-pinia.md +1 -0
  20. package/templates/claude-global/rules/dwy-vue-testing.md +1 -0
  21. package/templates/claude-global/skills/dwy-cibuildwheel/SKILL.md +355 -0
  22. package/templates/claude-global/skills/dwy-cibuildwheel/references/release-workflow-template.yml +99 -0
  23. package/templates/claude-global/skills/dwy-deploy-audit/SKILL.md +1 -0
  24. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_base.sh +0 -0
  25. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_capacity.sh +0 -0
  26. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_db.sh +0 -0
  27. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_docker.sh +0 -0
  28. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_env.sh +0 -0
  29. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_https.sh +0 -0
  30. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_logs.sh +0 -0
  31. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_nginx.sh +0 -0
  32. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_resilience.sh +0 -0
  33. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_secrets.sh +0 -0
  34. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_services.sh +0 -0
  35. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_ssh.sh +0 -0
  36. package/templates/claude-global/skills/dwy-deploy-audit/scripts/run_all.sh +0 -0
  37. package/templates/claude-global/skills/dwy-dev-qa/SKILL.md +1 -0
  38. package/templates/claude-global/skills/dwy-docker/SKILL.md +1 -0
  39. package/templates/claude-global/skills/dwy-docker/scripts/query_dockerhub.py +0 -0
  40. package/templates/claude-global/skills/dwy-docker/scripts/scan_images.sh +0 -0
  41. package/templates/claude-global/skills/dwy-dolphindb/SKILL.md +123 -76
  42. package/templates/claude-global/skills/dwy-dolphindb/references/create-database-table.md +219 -0
  43. package/templates/claude-global/skills/dwy-dolphindb/references/crud-operations.md +281 -0
  44. package/templates/claude-global/skills/dwy-dolphindb/references/data-import.md +271 -0
  45. package/templates/claude-global/skills/dwy-dolphindb/references/docker-deployment.md +63 -0
  46. package/templates/claude-global/skills/dwy-dolphindb/references/performance-tuning.md +223 -0
  47. package/templates/claude-global/skills/dwy-dolphindb/references/pitfalls-and-best-practices.md +352 -0
  48. package/templates/claude-global/skills/dwy-dolphindb/references/python-api.md +306 -0
  49. package/templates/claude-global/skills/dwy-dolphindb/references/setup-and-connection.md +143 -0
  50. package/templates/claude-global/skills/dwy-dolphindb/references/sources.md +46 -0
  51. package/templates/claude-global/skills/dwy-dolphindb/references/sql-batch-compute.md +206 -0
  52. package/templates/claude-global/skills/dwy-eapi/SKILL.md +134 -402
  53. package/templates/claude-global/skills/dwy-ekit/SKILL.md +1 -0
  54. package/templates/claude-global/skills/dwy-eui/SKILL.md +1 -0
  55. package/templates/claude-global/skills/dwy-fullstack-scaffold/SKILL.md +14 -7
  56. package/templates/claude-global/skills/dwy-git-commit/SKILL.md +1 -0
  57. package/templates/claude-global/skills/dwy-mirror-source/SKILL.md +1 -0
  58. package/templates/claude-global/skills/dwy-mirror-source/scripts/apply_mirrors.py +0 -0
  59. package/templates/claude-global/skills/dwy-mirror-source/scripts/check_mirrors.py +0 -0
  60. package/templates/claude-global/skills/dwy-pentest/SKILL.md +1 -0
  61. package/templates/claude-global/skills/dwy-publish/SKILL.md +1 -0
  62. package/templates/claude-global/skills/dwy-tech-stack/SKILL.md +1 -0
  63. package/templates/project/fullstack-monorepo/CLAUDE.md.hbs +21 -9
  64. package/templates/project/fullstack-monorepo/backend/Dockerfile.prod +40 -0
  65. package/templates/project/fullstack-monorepo/backend/_env.example.hbs +26 -0
  66. package/templates/project/fullstack-monorepo/docker-compose.dev.yml.hbs +4 -4
  67. package/templates/project/fullstack-monorepo/docker-compose.prod.yml.hbs +116 -0
  68. package/templates/project/fullstack-monorepo/docs/.gitkeep +0 -0
  69. package/templates/project/fullstack-monorepo/frontend/_env.example.hbs +19 -0
  70. package/templates/project/fullstack-monorepo/{dev.sh.hbs → scripts/dev.sh.hbs} +2 -2
  71. package/templates/claude-global/skills/dwy-dolphindb/evals/evals.json +0 -67
  72. package/templates/claude-global/skills/dwy-dolphindb/references/dolphindb-rules.md +0 -441
  73. package/templates/claude-global/skills/dwy-eapi/references/health.md +0 -47
  74. package/templates/claude-global/skills/dwy-eapi/references/logger.md +0 -60
  75. package/templates/project/fullstack-monorepo/_env.example.hbs +0 -24
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Vue Vitest 测试规范(目录组织、技术栈、AAA 结构、打包隔离)
3
+ category: Vue
3
4
  paths:
4
5
  - "**/*.test.ts"
5
6
  - "**/*.spec.ts"
@@ -0,0 +1,355 @@
1
+ ---
2
+ name: dwy-cibuildwheel
3
+ description: "Python Cython SDK 用 GitHub Actions + cibuildwheel 跨平台 build wheel 并通过 PyPI Trusted Publisher (OIDC) 发布到 PyPI 的避坑指南。涵盖 PEP 639 license / cibuildwheel 版本 tag / YAML 冒号转义 / {package} 占位符 / 跨平台 shell 引号 / manylinux 镜像 / 测试阶段 binary 强制 / GitHub runner image 退役(macos-13 已死)等 8 类高频坑。触发条件:编辑或新建 .github/workflows/*.yml 含 cibuildwheel、pyproject.toml 含 Cython、用户说'发 PyPI'/'build wheel'/'cibuildwheel'/'跨平台打包'/'wheel build 失败'/'macos runner 一直 queued'/'发版到 PyPI' 时。"
4
+ category: 运维发布
5
+ ---
6
+
7
+ # dwy-cibuildwheel — Python Cython SDK 跨平台 PyPI 发布避坑
8
+
9
+ 适用场景:含 Cython 编译扩展的 Python 包、跨平台 wheel 分发(linux x86_64/aarch64 + macos x86_64/arm64 + windows AMD64)、GitHub Actions + cibuildwheel + PyPI Trusted Publisher OIDC 发版。
10
+
11
+ **实战来源**:quant-sdk (quantzone) 0.4.0 首发到 PyPI 过程中暴露的 8 类坑,全部沉淀于此。
12
+
13
+ ---
14
+
15
+ ## 8 个高频坑
16
+
17
+ ### 坑 1:PEP 639 license expression 触发 build env 依赖冲突
18
+
19
+ **症状**(任意平台 build 阶段):
20
+ ```
21
+ ImportError: Cannot import `packaging.licenses`.
22
+ Setuptools>=77.0.0 requires "packaging>=24.2" to work properly.
23
+ ```
24
+
25
+ **根因**:`pyproject.toml` 用了 PEP 639 字符串形式 `license = "MIT"`。setuptools 77+ 校验 license expression 时强依赖 `packaging>=24.2`,但跨平台 cibuildwheel 临时 build env 装到老 packaging 时直接撞死。
26
+
27
+ **修复**:在 `[build-system].requires` 显式锁两个下限:
28
+ ```toml
29
+ [build-system]
30
+ requires = [
31
+ "setuptools>=77",
32
+ "packaging>=24.2",
33
+ "wheel",
34
+ "Cython>=3.0.10",
35
+ ]
36
+ build-backend = "setuptools.build_meta"
37
+ ```
38
+
39
+ **例外**:还在用老语法 `license = {text = "MIT"}` / `license = {file = "LICENSE"}` 的项目不触发。但 PEP 639 是趋势,建议主动对齐 + 提前锁依赖。
40
+
41
+ ---
42
+
43
+ ### 坑 2:cibuildwheel action 必须用 minor 级或精确 tag
44
+
45
+ **症状**(workflow 启动几秒就 fail,错误页面提示):
46
+ ```
47
+ Unable to resolve action `pypa/cibuildwheel@v3`, unable to find version `v3`
48
+ ```
49
+
50
+ **根因**:不像 `actions/checkout@v4` 那种 major moving alias,`pypa/cibuildwheel` **只维护 minor 级 moving tag**(`v3.4`)和精确 patch tag(`v3.4.1`),**没有 `v3` 这种 major alias**。
51
+
52
+ **修复**:
53
+ ```yaml
54
+ - uses: pypa/cibuildwheel@v3.4 # minor moving,自动跟 v3.4.x patch(推荐)
55
+ # 或精确锁
56
+ - uses: pypa/cibuildwheel@v3.4.1
57
+ ```
58
+
59
+ **自检**:改 action 版本前先查实际存在的 tag:
60
+ ```bash
61
+ curl -sL https://api.github.com/repos/pypa/cibuildwheel/git/refs/tags \
62
+ | python3 -c "import sys,json; tags=[r['ref'].replace('refs/tags/','') for r in json.load(sys.stdin)]; print([t for t in tags if t.startswith('v3')][-10:])"
63
+ ```
64
+
65
+ 通用教训:**不要假设任何 GitHub Action 都有 `v<N>` major alias**,必须先查仓库 tag 列表。
66
+
67
+ ---
68
+
69
+ ### 坑 3:YAML 字符串含冒号必须加引号(静默杀手)
70
+
71
+ **症状**:workflow 触发后几秒 conclusion=failure,但 `gh run view <id> --json jobs` 显示 **jobs 数组为空**——一个 job 都没启动。
72
+
73
+ **根因**:GitHub Actions 在 yaml 解析失败时直接拒绝 workflow,不启动任何 job。最常见触发:
74
+ ```yaml
75
+ CIBW_BEFORE_TEST: pip install --only-binary=:all: pyarrow # 错!
76
+ ```
77
+ `:all:` 第二个冒号被 YAML 解析为 mapping value delimiter,整个文件解析失败。
78
+
79
+ **修复**:整行加引号:
80
+ ```yaml
81
+ CIBW_BEFORE_TEST: "pip install --only-binary=:all: pyarrow pandas"
82
+ ```
83
+
84
+ **强制自检**(改完任何 workflow 后必跑):
85
+ ```bash
86
+ python3 -c "import yaml; yaml.safe_load(open('.github/workflows/release.yml'))"
87
+ ```
88
+ 本地报错就修,不要 push 后等 GitHub 告诉你(GitHub 不给具体 yaml 错误行号,得自己查)。
89
+
90
+ **调试线索**:run conclusion=failure + jobs 为空 → 99% yaml 解析问题。
91
+
92
+ ---
93
+
94
+ ### 坑 4:CIBW_TEST_COMMAND 用 `{package}` 不要用 `{project}`
95
+
96
+ **症状**(monorepo + SDK 在子目录):
97
+ ```
98
+ ERROR: file or directory not found: /runner/work/<repo>/<repo>/tests
99
+ collected 0 items
100
+ ============================ no tests ran in 0.00s =============================
101
+ ```
102
+
103
+ **根因**:`{project}` 占位符替换为 cibuildwheel 调用的工作目录(**repo 根**),不是 `package-dir`。如果 SDK 在 `quant-sdk/` 子目录,测试在 `quant-sdk/tests/`,但 `{project}/tests` 会找 `<repo-root>/tests`,找不到。
104
+
105
+ **修复**:用 `{package}` 占位符:
106
+ ```yaml
107
+ - uses: pypa/cibuildwheel@v3.4
108
+ with:
109
+ package-dir: quant-sdk
110
+ env:
111
+ CIBW_TEST_COMMAND: 'pytest {package}/tests -v -k "not requires_server"'
112
+ ```
113
+
114
+ **占位符对照表**:
115
+
116
+ | 占位符 | 替换为 |
117
+ |---|---|
118
+ | `{project}` | cibuildwheel 调用的工作目录(repo 根) |
119
+ | `{package}` | `package-dir` 的绝对路径 |
120
+
121
+ **适用场景**:monorepo 必须用 `{package}`;单包仓库 `{project}` `{package}` 等价。习惯用 `{package}` 不会错。
122
+
123
+ ---
124
+
125
+ ### 坑 5:跨平台 shell 引号必须外单内双
126
+
127
+ **症状**(仅 Windows,linux/macos 正常):
128
+ ```
129
+ + pytest D:\a\repo\repo\quant-sdk/tests -v -k 'not requires_server'
130
+ ERROR: file or directory not found: requires_server'
131
+ collecting ... collected 0 items
132
+ ```
133
+
134
+ **根因**:Windows cmd **不解析单引号字符串**。`-k 'not requires_server'` 在 cmd 里被拆成两个独立参数 `'not` 和 `requires_server'`,pytest 把第二个当成目录路径。
135
+
136
+ **修复**:YAML value 外层用**单引号**,里面 shell 命令用**双引号**(双引号在 sh + cmd 都正常):
137
+ ```yaml
138
+ CIBW_TEST_COMMAND: 'pytest {package}/tests -v -k "not requires_server"'
139
+ ```
140
+
141
+ **反例**(外双内单 = Windows 必坏):
142
+ ```yaml
143
+ CIBW_TEST_COMMAND: "pytest {package}/tests -v -k 'not requires_server'" # 错!
144
+ ```
145
+
146
+ **通用原则**:跨平台跑的命令字符串里,shell 引号统一用双引号;YAML 引号统一用单引号。**永远不要在跨平台命令里用单引号包参数**。
147
+
148
+ ---
149
+
150
+ ### 坑 6:manylinux 镜像必须升到 `_2_28`
151
+
152
+ **症状**(仅 linux 容器内 pip install 阶段):
153
+ ```
154
+ ERROR: Could not find a version that satisfies the requirement pyarrow (from versions: none)
155
+ ERROR: No matching distribution found for pyarrow
156
+ ```
157
+
158
+ **根因**:`pyarrow` / `pandas` / `numpy` 等大型 C 扩展库**早已只发 `manylinux_2_28` wheel**(要求 glibc 2.28+,CentOS 8+ / Ubuntu 18.04+ / Debian 10+),**不再支持 `manylinux2014`**(glibc 2.17)。cibuildwheel 老配置默认起 `manylinux2014` 容器,容器内 pip 找不到任何匹配 wheel。
159
+
160
+ **修复**:
161
+ ```yaml
162
+ env:
163
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
164
+ CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
165
+ # musllinux 通常不用动
166
+ CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
167
+ CIBW_MUSLLINUX_AARCH64_IMAGE: musllinux_1_2
168
+ ```
169
+
170
+ **风险评估**:升 manylinux_2_28 提高了用户机器的 glibc 要求,但你的 SDK 既然依赖 pyarrow,用户本来就受这个约束,**所以不增加额外限制**。
171
+
172
+ **判断标准**:你的运行时依赖里有 pyarrow / pandas / numpy / scipy / lxml 等 → 必须 `manylinux_2_28`。
173
+
174
+ ---
175
+
176
+ ### 坑 7:测试阶段三方依赖必须强制 binary
177
+
178
+ **症状**(任意平台、最容易在 aarch64 触发):
179
+ ```
180
+ ERROR: Failed building wheel for libcst
181
+ error: can't find Rust compiler
182
+ ERROR: Failed to build 'pyarrow' when installing build dependencies for pyarrow
183
+ ```
184
+
185
+ **根因**:cibuildwheel 在 test 阶段 `pip install <built-wheel>` 时自动装 SDK 的 runtime deps。pip 默认 prefer binary 但**允许源码 fallback**——某些版本/架构组合下 pip 找不到合适 binary,回退源码 build pyarrow → pyarrow build dep 拉 libcst → libcst 需要 Rust → 容器内没装 → 整个链 fail。
186
+
187
+ **修复**:在 test 前预装大依赖,**强制只用 binary**:
188
+ ```yaml
189
+ env:
190
+ CIBW_TEST_REQUIRES: pytest pytest-asyncio respx
191
+ CIBW_BEFORE_TEST: "pip install --only-binary=:all: pyarrow pandas"
192
+ CIBW_TEST_COMMAND: 'pytest {package}/tests -v -k "not requires_server"'
193
+ ```
194
+
195
+ `--only-binary=:all:` 表示对**所有包**拒绝任何源码 build。找不到合适 wheel 直接 fail(快速明确),不会拉长得离谱的 build chain。
196
+
197
+ **关键**:必须搭配坑 6 的 `manylinux_2_28`,否则 pip 找不到 binary 直接报"No matching distribution"(参见坑 6 现象)。
198
+
199
+ ---
200
+
201
+ ### 坑 8:macos-13 runner 已退休(2025-12 起死等)
202
+
203
+ **症状**:workflow 长期卡在
204
+ ```
205
+ Requested labels: macos-13
206
+ Waiting for a runner to pick up this job...
207
+ ```
208
+ 小时级 queued,runner 永远不分配。其他 job 都成功,publish 因 `needs: build_wheels` 一直不启动。
209
+
210
+ **根因**:GitHub 已于 **2025-12-04** 正式退役 `macos-13` runner image。配 `runs-on: macos-13` 的 job 不是排队,是 **runner pool 已被删空**——永远等不到。GitHub 没有为这种 case 抛错,只让你 queued 着。
211
+
212
+ Apple 完全停 Intel + GitHub 计划 **2027 秋停所有 x86_64 macOS runner**,整个 Intel Mac runner 时代在落幕。
213
+
214
+ **修复**:根据是否需要 macOS x86_64 wheel 选一:
215
+
216
+ ```yaml
217
+ matrix:
218
+ include:
219
+ - { os: ubuntu-latest, archs: x86_64 }
220
+ - { os: ubuntu-24.04-arm, archs: aarch64 }
221
+ # 选项 A: 仍需 x86_64 wheel(开发者自己是 Intel Mac / 重要用户群有 Intel Mac)
222
+ - { os: macos-15-intel, archs: x86_64 } # ✅ 替代死掉的 macos-13(真 Intel runner)
223
+ # 选项 B: 不需要 x86_64,删掉上一行,Intel Mac 用户走 Rosetta 跑 arm64 wheel
224
+ - { os: macos-14, archs: arm64 }
225
+ - { os: windows-latest, archs: AMD64 }
226
+ ```
227
+
228
+ **其他可选替代 label**:
229
+
230
+ | label | 说明 |
231
+ |---|---|
232
+ | `macos-15-intel` | 真 Intel Mac runner(新引入,推荐) |
233
+ | `macos-14-large` / `macos-15-large` | Apple Silicon 上虚拟化跑 x86_64,贵且慢 |
234
+
235
+ **通用教训**:GitHub runner image 会按计划退役(macos-11/12/13 已退,macos-14 在用,macos-15 是新主力)。改 workflow 前去 https://github.com/actions/runner-images 看当前 supported labels;不要假设 stackoverflow 上的老 yaml 还能跑。
236
+
237
+ **自检**: 看 `Waiting for a runner` 卡超过 30 分钟,基本 100% 是 label 已死(而不是真排队)。
238
+
239
+ ---
240
+
241
+ ## 完整 workflow 模板
242
+
243
+ 直接复制 `references/release-workflow-template.yml` 到项目 `.github/workflows/release.yml`,只改两处:
244
+
245
+ 1. `package-dir: <PACKAGE_DIR>` → 实际 SDK 子目录(monorepo 必填)
246
+ 2. `CIBW_BUILD` 行的 Python 版本枚举(按需调整)
247
+
248
+ 模板已内置全部 7 项修复,开箱即用。
249
+
250
+ ---
251
+
252
+ ## Pre-flight checklist(发版前必跑)
253
+
254
+ ```bash
255
+ # 1. 工作树干净
256
+ git status
257
+
258
+ # 2. tag 必须 = pyproject 版本(避开 workflow version_check 失败)
259
+ grep '^version = ' <PACKAGE_DIR>/pyproject.toml
260
+ git tag -l 'v*'
261
+
262
+ # 3. PyPI 上无该版本(PyPI 版本号永久不可重用!)
263
+ curl -s https://pypi.org/pypi/<your-package>/json \
264
+ | python3 -c "import sys,json; print(list(json.load(sys.stdin).get('releases',{}).keys()))"
265
+
266
+ # 4. CHANGELOG 有新版本条目
267
+ head -20 <PACKAGE_DIR>/CHANGELOG.md
268
+
269
+ # 5. Trusted Publisher 已配(PyPI 网页 https://pypi.org/manage/account/publishing/ 确认)
270
+ # owner = GitHub org,repo = GitHub repo 名(仓库改过名要同步改 PyPI!)
271
+ # workflow = release.yml,environment = pypi
272
+
273
+ # 6. GitHub Environment "pypi" 存在
274
+ gh api repos/<owner>/<repo>/environments --jq '.environments[].name'
275
+
276
+ # 7. workflow yml 本地解析通过
277
+ python3 -c "import yaml; yaml.safe_load(open('.github/workflows/release.yml'))"
278
+ ```
279
+
280
+ ---
281
+
282
+ ## Build 失败后的安全重发流程
283
+
284
+ **前提**:PyPI 上还**没有 publish 成功**该版本号(PyPI 一旦 publish 成功,号码永久占用,必须 bump 下一个版本)。
285
+
286
+ ```bash
287
+ # 1. cancel 失败 run,节省 CI 额度
288
+ gh run cancel <run-id>
289
+
290
+ # 2. 修代码 + commit + push
291
+ git add <修改文件>
292
+ git commit -m "ci(sdk): 修复 xxx"
293
+ git push origin main
294
+
295
+ # 3. 删本地 + 远端 tag,重打指向新 commit
296
+ git push origin :refs/tags/v0.4.0
297
+ git tag -d v0.4.0
298
+ git tag v0.4.0
299
+ git push origin v0.4.0
300
+
301
+ # 4. 监控新 run
302
+ run_id=$(gh run list --workflow=release.yml --limit=1 --json databaseId --jq '.[0].databaseId')
303
+ gh run watch "$run_id" --exit-status
304
+ ```
305
+
306
+ ⚠️ **commit 前隔离 staging**:如果你边修边并行有其他文件改动,用 `git commit -- <specific-file>` 只 commit 指定文件,避免把不相关改动一起打包到"修复 commit"里污染历史。
307
+
308
+ ---
309
+
310
+ ## 调试技巧
311
+
312
+ | 场景 | 命令 |
313
+ |---|---|
314
+ | 看**进行中** job 的日志(`gh run view --log` 不让看 in-progress) | `gh api repos/<owner>/<repo>/actions/jobs/<job-id>/logs` |
315
+ | 拿失败 job ID 列表 | `gh run view <run-id> --json jobs --jq '.jobs[] \| select(.conclusion=="failure") \| "\(.databaseId) \| \(.name)"'` |
316
+ | 阻塞等待 run 完成(后台跑) | `gh run watch <run-id> --exit-status` |
317
+ | run 几秒 fail + jobs 为空 | 99% yaml 解析错误,本地跑 `python3 -c "import yaml; yaml.safe_load(...)"` |
318
+ | Filter 失败 job 关键错误 | `gh api .../jobs/<id>/logs \| grep -iE "error\|importerror\|cython\|setuptools\|packaging\|fatal\|not found"` |
319
+
320
+ ---
321
+
322
+ ## 仓库改名 / 迁移注意
323
+
324
+ GitHub repo 改名后:
325
+
326
+ - ✅ `Settings → Environments`(含 `pypi`)跟着 repo 保留,**不丢**
327
+ - ✅ Trusted Publisher 是绑 `owner/repo` 的,repo 改名后**必须**去 PyPI 改 publisher 配置(`https://pypi.org/manage/account/publishing/` → 找到 publisher → 改 repo 名),否则下次 publish 被 PyPI 拒绝
328
+ - ✅ 旧 repo URL 自动 301 redirect 一段时间,但建议立刻更新本地 `git remote set-url origin <新地址>`
329
+
330
+ ---
331
+
332
+ ## 不要做
333
+
334
+ - ❌ **不要在本地跑 `python -m build && twine upload`** —— 本地无法 build 跨平台 wheel,且容易绕过 Trusted Publisher 引入凭证管理风险
335
+ - ❌ **不要发 sdist 到 PyPI**(`pypa/gh-action-pypi-publish` 默认只发 wheel,保持这个行为)—— Cython 编译模块的 `.py` 源码会通过 sdist 完整泄漏,破坏混淆意义
336
+ - ❌ **不要假设 GitHub Action 的 `v<N>` major moving tag 一定存在**,先查仓库实际 tag 列表
337
+ - ❌ **workflow 改完不要直接 push**,先 `python3 -c "import yaml; yaml.safe_load(...)"` 本地验证
338
+ - ❌ **不要在 publish 前先发同版本号 sdist 占位** —— PyPI 同版本号占了就废,下次 publish 被拒
339
+ - ❌ **不要在 manylinux2014 容器里期望装上 pyarrow 24+ wheel** —— 必须 manylinux_2_28
340
+ - ❌ **跨平台命令里不要用单引号包参数** —— Windows cmd 不识别
341
+
342
+ ---
343
+
344
+ ## 违规检测清单
345
+
346
+ | 检查项 | 违规模式 | 严重程度 |
347
+ |--------|---------|---------|
348
+ | build-system 缺 packaging 锁 | 用 PEP 639 license 但 `[build-system].requires` 没列 `packaging>=24.2` | **致命 → 必坏** |
349
+ | YAML 含 `:` 未加引号 | env 值有 `=:all:` / `port:8080` 等冒号但整行未加引号 | **致命 → 必坏** |
350
+ | cibuildwheel 用 major alias | `pypa/cibuildwheel@v3`(不存在)/ `@v2`(不存在) | **致命 → 必坏** |
351
+ | TEST_COMMAND 用 `{project}` | monorepo 子目录 SDK 用 `{project}/tests` | 高 |
352
+ | TEST_COMMAND 外双内单 | `"... -k 'not xxx'"` Windows 必坏 | 高 |
353
+ | manylinux2014 + 大库依赖 | 依赖含 pyarrow/pandas/numpy 但 manylinux 镜像还是 2014 | 高 |
354
+ | 缺 CIBW_BEFORE_TEST binary 锁 | 大型 C 库依赖未预装 binary,源码 build 链失败 | 中 |
355
+ | 用了已退役 runner image | matrix 含 `macos-13` / `macos-12` / `macos-11` / `ubuntu-20.04` 等已下线 label | **致命 → 死等不报错** |
@@ -0,0 +1,99 @@
1
+ # Python Cython SDK 跨平台 wheel + PyPI Trusted Publisher 发版 workflow 模板
2
+ #
3
+ # 已内置 dwy-cibuildwheel skill 7 个避坑修复,开箱即用。
4
+ # 复制到项目 .github/workflows/release.yml,只改两处:
5
+ # 1. package-dir: <PACKAGE_DIR> —— 实际 SDK 子目录(monorepo 必填,单包仓库填 . 或省略)
6
+ # 2. CIBW_BUILD —— 按需调整 Python 版本枚举
7
+ #
8
+ # 配套要求(缺一不可):
9
+ # 1. <PACKAGE_DIR>/pyproject.toml 的 [build-system].requires 含:
10
+ # "setuptools>=77", "packaging>=24.2", "wheel", "Cython>=3.0.10"
11
+ # 2. PyPI Trusted Publisher 已配(owner/repo/workflow=release.yml/environment=pypi)
12
+ # 3. GitHub Settings → Environments 存在名为 "pypi" 的 environment
13
+
14
+ name: Release SDK to PyPI
15
+
16
+ on:
17
+ push:
18
+ tags: ["v*"]
19
+ workflow_dispatch:
20
+
21
+ jobs:
22
+ version_check:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - name: Verify tag matches pyproject version
27
+ if: startsWith(github.ref, 'refs/tags/v')
28
+ run: |
29
+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
30
+ PY_VERSION=$(grep '^version = ' <PACKAGE_DIR>/pyproject.toml | head -1 | cut -d'"' -f2)
31
+ if [ "$TAG_VERSION" != "$PY_VERSION" ]; then
32
+ echo "Tag $TAG_VERSION 不匹配 pyproject.toml $PY_VERSION"
33
+ exit 1
34
+ fi
35
+ echo "Version check OK: $TAG_VERSION"
36
+
37
+ build_wheels:
38
+ needs: version_check
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ include:
43
+ - { os: ubuntu-latest, archs: x86_64 }
44
+ - { os: ubuntu-24.04-arm, archs: aarch64 }
45
+ # 坑 8: macos-13 已于 2025-12-04 退休,用 macos-15-intel(真 Intel runner)替代
46
+ # 如果不需要 x86_64 wheel,删掉下一行,Intel Mac 用户走 Rosetta 跑 arm64 wheel
47
+ - { os: macos-15-intel, archs: x86_64 }
48
+ - { os: macos-14, archs: arm64 }
49
+ - { os: windows-latest, archs: AMD64 }
50
+ runs-on: ${{ matrix.os }}
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+
54
+ - name: Build wheels
55
+ # 坑 2: 不能用 @v3(major alias 不存在),用 minor 移动 tag 或精确版本
56
+ uses: pypa/cibuildwheel@v3.4
57
+ with:
58
+ package-dir: <PACKAGE_DIR>
59
+ output-dir: wheelhouse
60
+ env:
61
+ CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
62
+ CIBW_ARCHS: ${{ matrix.archs }}
63
+ # 坑 6: pyarrow/pandas 等只发 manylinux_2_28,不能用老 manylinux2014
64
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
65
+ CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
66
+ CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
67
+ CIBW_MUSLLINUX_AARCH64_IMAGE: musllinux_1_2
68
+ CIBW_TEST_REQUIRES: pytest pytest-asyncio respx
69
+ # 坑 3 + 坑 7: 整行加双引号避免 YAML 冒号歧义;强制 binary 防止源码 build 链
70
+ CIBW_BEFORE_TEST: "pip install --only-binary=:all: pyarrow pandas"
71
+ # 坑 4 + 坑 5: monorepo 用 {package} 而非 {project};外单内双跨平台兼容
72
+ CIBW_TEST_COMMAND: 'pytest {package}/tests -v -k "not requires_server"'
73
+
74
+ - uses: actions/upload-artifact@v4
75
+ with:
76
+ name: wheels-${{ matrix.os }}-${{ matrix.archs }}
77
+ path: ./wheelhouse/*.whl
78
+
79
+ publish:
80
+ needs: build_wheels
81
+ if: github.event_name == 'push'
82
+ runs-on: ubuntu-latest
83
+ environment: pypi
84
+ permissions:
85
+ id-token: write
86
+ steps:
87
+ - uses: actions/download-artifact@v4
88
+ with:
89
+ path: dist
90
+ merge-multiple: true
91
+
92
+ - name: List wheels to publish
93
+ run: ls -la dist/
94
+
95
+ # Trusted Publisher OIDC,无需 token
96
+ # 默认只发 wheel,不发 sdist(Cython 编译模块的 .py 源码不会泄漏)
97
+ - uses: pypa/gh-action-pypi-publish@release/v1
98
+ with:
99
+ packages-dir: dist/
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: dwy-deploy-audit
3
3
  description: "部署后线上环境基础安全巡检:远程 SSH 到目标服务器,逐项核对 SSH/Nginx/数据库/HTTPS/Docker/环境变量等基础环境配置,输出分级安全报告,只报告不修复。触发条件:用户说'部署巡检'、'上线检查'、'基础环境检查'、'部署审计'、'线上安全检查'、'生产环境审计' 时。"
4
+ category: 运维发布
4
5
  ---
5
6
 
6
7
  # 部署后基础环境巡检 (deploy-audit)
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: dwy-dev-qa
3
3
  description: "功能开发完成后的通用质量保障流程。触发条件:完成新功能、修复 bug、重构代码后,准备提交前。"
4
+ category: 开发流程
4
5
  ---
5
6
 
6
7
  # 开发完成后质量保障流程
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: dwy-docker
3
3
  description: "Docker 工程规范检查与镜像版本管理。触发场景:用户编辑/新建/粘贴 Dockerfile / docker-compose / k8s manifest / .github workflow / .gitlab-ci / .dockerignore / dev.sh 时;用户口头提到 docker / 容器 / compose / 镜像版本 / k8s 镜像时;用户说'扫描 latest' / '检查 docker' / '固定镜像版本' / 'docker 规范'。运作方式:问题驱动 — AI 检查合规性,合规则静默放行,违规才用 AskUserQuestion 让用户决策修复,禁止 AI 自行拍板修改。覆盖镜像版本(禁 latest / 浮动 tag、N-1 minor)、Dockerfile 工程(多阶段、non-root、.dockerignore)、compose 工程(dev/prod 分离、healthcheck、restart 策略)、一键启动 dev.sh。"
4
+ category: 运维发布
4
5
  ---
5
6
 
6
7
  # Docker 工程规范