Commit Graph
3 Commits
Author SHA1 Message Date
mashagua f6d1eccf70 fix(ci): switch pull_request_target workflows to pull_request (#432)
GitHub now restricts `pull_request_target` on public repositories by
default, causing `i18n Auto-Translate` (required `translate` check) and
`Auto-request Copilot review` to fail immediately with
`startup_failure`.

### Changes
- **`.github/workflows/i18n-translate.yml`**:
  - Switch trigger from `pull_request_target` to `pull_request`.
- Explicitly check out `github.base_ref` on `pull_request` and keep the
data-only overlay model (`skills/`, `manifest.json`, `categories.json`,
symlink removal) so untrusted PR scripts are never executed.
- Gate auto-translate, push, PR comment, and failure-label steps to
same-repo PRs (`github.event.pull_request.head.repo.full_name ==
github.repository`) so fork PRs (which receive read-only tokens under
`pull_request`) run `translate.py --check` and fail cleanly with local
translation instructions instead of crashing with 403.
- **`.github/workflows/auto-request-copilot-review.yml`**:
- Switch trigger from `pull_request_target` to `pull_request` (keeping
`opened`, `reopened`, `ready_for_review`).
- Guard the `request` job to non-draft same-repo PRs so fork PRs do not
fail with 403.
- **`scripts/catalog/test_review_workflow.py`**:
- Update assertions to require `pull_request` (and reject
`pull_request_target`) plus verify the non-draft & same-repo job guard
while preserving all no-checkout/no-code-execution assertions.

### Verification
- `uv run --offline --quiet scripts/catalog/test_review_workflow.py` —
passed
- `pytest scripts/catalog/test_tracked_updates.py -q` — 64 passed
- `uv run --offline --quiet scripts/i18n/validate-i18n.py` — passed
- `uv run --offline --quiet scripts/catalog/validate_catalog_metadata.py
--require-complete` — 0 errors
2026-12-03 21:19:29 +08:00
mashagua 61148f2e73 feat(market): 自动核验上游技能更新并记录审核证据 (#237)
## 问题与结果 / Problem and outcome

原流程每周检查上游并更新跟踪 Issue,更新候选的版本、来源和审核记录仍需人工准备。本 PR 增加以下处理:

| 项目 | 本 PR 的行为 |
| --- | --- |
| 1. 检查与候选 | 每天检查上游;每轮最多处理 5 个去重的 Skill 更新候选。自动核验仅接受固定 Git
快照,并要求旧快照已有许可和准入证据。 |
| 2. 核验范围 |
比较实际安装范围、根目录及嵌套许可证/Notice、结构化依赖、名称简介、兼容性声明和合集成员。包自身版本可以递增;依赖或脚本声明变化须人工复核。核验阶段不执行上游代码。
|
| 3. 核验通过 | 同步 entry 和 sidecar 的来源 ref、可确认的上游版本;写入机器审核身份、真实日期和
`upstream-audit.v1.json`,将证据绑定到来源 URL、新旧
ref、内容路径、许可摘要和检查结果。目录、本地化、翻译新鲜度及适用的合集校验通过后,才创建普通 PR。 |
| 4. 无法确认或校验失败 |
保留旧审核记录,创建带具体原因的草稿;不会将旧审核标记为新快照已通过。缺失版本不编造,版本回退被阻止,未知发布日期保持未知。 |
| 5. 重复与失败处理 | 保留已有更新 PR 和 hold 决策;同一快照已有关闭 PR 时不重复创建。提交、推送或 PR API
失败时保留覆盖报告,并以失败退出。所有更新均不自动合并。 |
| 6. 覆盖报告 | 为顶层 Skill、合集子项和内置内容输出更新状态或阻碍原因。当前 145 个顶层条目加 302 个子项,共 447
条库存记录;这不是 447 次运行验收。ZIP/Web 仅收录条目保持准入阻碍,缺新版发现依据时明确说明。 |

机器核验仅确认有限范围的来源、许可与结构化元数据一致性。非结构化依赖、行为变化、实际运行和安全性仍需结合差异人工复核;不代表上游背书。

The weekly issue-only check becomes a daily pipeline with at most five
deduplicated Skill candidates per run. Eligible immutable Git snapshots
receive bounded source/license/structured-metadata verification and
explicit machine receipts. Catalog and localization checks must pass
before a normal PR is created; blocked candidates remain drafts with the
old review intact. Existing proposals and holds are preserved, failures
retain coverage reports, and nothing auto-merges or claims
runtime/security certification.

## Copilot 审核邀请:改动与当前状态 / Copilot review invitation

1. **原失败原因**:旧邀请任务使用 `pull_request` 上下文,请求审核时返回 `403 Resource not
accessible by
integration`。[失败记录](https://github.com/desirecore/market/actions/runs/41067055993/job/124101102218)属于旧提交
`732cc2a`。
2. **本 PR 的改动**:邀请流程改用 `pull_request_target` 和受信任的 base 上下文,仅调用 PR 元数据
API,不检出或执行 PR 代码。返回 422 时,必须确认当前 head 已有 Copilot 审核记录,才能按已审核处理;其他错误仍失败。
3. **生效范围**:该流程监听 opened、reopened、ready_for_review,未监听
synchronize。邀请修正需合入默认分支后,再在适用事件上验证;本 PR 的推送不能证明新邀请流程已在线生效。
4. **当前实际审核状态**:截至下方验证快照,没有审核记录,也没有待处理审核邀请。`Wait for Copilot review`
运行成功,但日志显示等待约 8 分钟后超时,按现有规则放行,**不代表 Copilot 已审核**。该等待规则未在本 PR
中修改。[等待任务日志](https://github.com/desirecore/market/actions/runs/41309461885/job/124856608594)

The old invitation failed with HTTP 403. This PR moves metadata-only
invitation requests to the trusted base context and verifies a
current-head review before treating HTTP 422 as already reviewed. The
change still needs post-merge validation on a supported event. There are
currently no submitted or pending review requests; the green waiting job
reflects timeout fallback, not an actual Copilot review.

## 验证快照 / Validation snapshot

验证对应提交:`24183e240c945fd72cd0c8a6b10730b18db6d1f3`,2026-11-01。

- **已修复的 CI 错误**:`test_audit_skill_update.py` 曾向 `validate_sidecar`
传入空校验器字典,触发 `KeyError: 'skill'`。现加载真实 Skill client schema,并在两处调用中传入
`ClientEntryValidator`;原测试断言保持不变。
- **本地测试**:自动核验 15、候选发布 9、目录校验器 62、合集生成器 10、上游检查 47、审核邀请流程 1、i18n 校验器
19、Office launcher 11,共 **174 项通过**。
- **本地数据检查**:目录和 i18n 校验均为 0 errors、103 条既有 warnings;翻译新鲜度与 diff 空白检查通过。
- **GitHub CI**:[`i18n
Validate`](https://github.com/desirecore/market/actions/runs/41309461898)全部通过,包括目录、翻译新鲜度和联网合集检查;[`i18n
Auto-Translate`](https://github.com/desirecore/market/actions/runs/41309461185)成功;[`Wait
for Copilot
review`](https://github.com/desirecore/market/actions/runs/41309461885)成功,但属于上述超时放行。
- **合并状态**:GitHub 返回 `mergeable: true`、`mergeStateStatus:
CLEAN`;当前提交没有失败检查。PR 尚未合并。
- **尚未做的验证**:未触发真实定时更新批次、未批量创建新版 PR、未执行上游代码;新邀请流程权限和真实审核仍待验证。

All 174 local tests pass. Catalog/localization validation reports zero
errors and 103 existing warnings. Current-head CI is green, including
generated collection checks; GitHub reports CLEAN. Copilot review
itself, the revised invitation's online permissions, and a real
scheduled publication batch remain unverified.

## 发布前提与关联改动 / Operation and related changes

- Actions 自动创建 PR 需要仓库设置允许;本 PR 未调整仓库管理员设置。
- 默认 `GITHUB_TOKEN` 创建的 PR
通常不会触发其他工作流,因此发布候选前会执行目录和本地化检查;合并前仍需核对实际检查与审核结果。
- 客户端同版本内容交付及 Kimi
独立官方包维护:[desirecore#5526](https://github.com/desirecore/desirecore/pull/5526);关联文档:[desirecore-docs#864](https://github.com/desirecore/desirecore-docs/pull/864)。这些链接表示关联范围,不表示本
PR 合并即可发布客户端能力。
2026-11-05 16:56:29 +08:00
yige 9ee4c3a367 ci: 引入分支保护配套工作流(path 过滤 → detect-changes,AI review 自动化) (#5)
## Summary / 概要

为了让 `main` 分支保护规则在所有 PR 上稳定生效,调整两个现有 i18n workflow 并新增两个 AI review 配套
workflow。

### 已配置的 main ruleset(ID 16298003)

- 只允许 squash merge,禁止 force push / 删除
- 必需 status check:`validate`、`translate`,require
`strict_required_status_checks_policy=true`(必须 rebase 最新)
- PR
rule:`required_approving_review_count=0`、`required_review_thread_resolution=true`、`dismiss_stale_reviews_on_push=true`
- `bypass_actors=[]`:管理员也不能绕过

### 本 PR 改动

1. **i18n-validate / i18n-translate**:移除 `on.pull_request.paths`,把过滤下移到
job 内 `detect-changes` step。路径不相关时跳过实际逻辑但 job 仍 success,避免 required
check 因 path 过滤缺失而卡死非 i18n PR。
2. **auto-request-copilot-review** (新增):PR
opened/reopened/ready_for_review 时自动 `POST
/pulls/{n}/requested_reviewers` 加 Copilot 为 reviewer。
3. **wait-for-copilot-review** (新增):PR
opened/reopened/synchronize/ready_for_review 时启动,轮询 reviews API 等待
`copilot-pull-request-reviewer[bot]` 在当前 head SHA 提交 review。超时 8 分钟则
fail。
- 选择 polling 而不是 `pull_request_review` 事件触发是因为:Copilot bot 触发的
`pull_request_review` 事件被 GitHub 视为 first-time contributor,workflow run
会卡在 `action_required` 状态需 maintainer 在 web UI 手动批准,无法自动化。

合并后会再 PATCH ruleset 16298003,把 `wait-for-copilot-review` 加入 required
status checks 作为强制门槛。

## Test plan

- [x] `i18n-validate` 在本 PR 上跑出 success(PR 仅触及
`.github/workflows/`,relevant=false,走 skip 分支)
- [x] `i18n-translate` 同上
- [x] `auto-request-copilot-review` 跑出 success,Copilot 被自动加为 reviewer
- [x] `wait-for-copilot-review` 在 polling 窗口内捕获到 Copilot review 并 pass
- [ ] 解决 Copilot 提的 conversations 后能 squash merge
- [ ] 合并后用 PATCH ruleset 把 `wait-for-copilot-review` 加入 required checks
2026-05-13 00:21:51 +08:00