Skip to content

ci: add SHA fallback when mirror checkout fails - #54

Merged
watney1024 merged 1 commit into
ScratchV-Compiler:mainfrom
FeelTheBeats:seven_fix_ci
Aug 27, 2026
Merged

ci: add SHA fallback when mirror checkout fails#54
watney1024 merged 1 commit into
ScratchV-Compiler:mainfrom
FeelTheBeats:seven_fix_ci

Conversation

@FeelTheBeats

Copy link
Copy Markdown
Contributor

The self-hosted runner's local mirror (/opt/ScratchV) may be stale, causing 'reference is not a tree' errors when checking out GITHUB_SHA. Add a fallback that fetches the exact SHA from origin and retries checkout, ensuring CI works even with an outdated mirror.

The self-hosted runner's local mirror (/opt/ScratchV) may be stale,
causing 'reference is not a tree' errors when checking out GITHUB_SHA.
Add a fallback that fetches the exact SHA from origin and retries
checkout, ensuring CI works even with an outdated mirror.

Signed-off-by: Seven Gao <799889633@qq.com>
@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

共审查 1 个变更文件

📁 .github/workflows/ci.yml

🟡 Suggestion: 重复代码 — 同一逻辑块出现在第 58 行和第 152 行(两处 job 中完全相同的 checkout + retry 逻辑)。如果未来需要修改该回退策略,必须同步修改两处。考虑提取为 git functions.sh 中的共享函数,或在 workflow 中使用 workflow_dispatch + composite action。

🟡 Suggestion: git fetch origin "$GITHUB_SHA" || true 吞掉错误信息 — 如果 fetch 本身失败(网络问题、权限问题),stderr 会输出但无法被后续逻辑捕获。最终错误信息只显示 "SHA not found",排障时缺少 fetch 是否成功的关键信号。建议在 fetch 失败时追加日志:

git fetch origin "$GITHUB_SHA" 2>&1 || echo "::warning::Direct fetch also failed"

💭 Nit: else 分支的 success notice 与外层嵌套 success notice 语义重叠else 分支(首次 checkout 成功)和内部 if 成功分支分别打印 "Checkout successful""Checkout successful after direct fetch",信息清晰。但如果首次 checkout 成功走 else,用户看到 "Checkout successful" 会疑惑上面为何有 "Checkout failed, fetching SHA directly" 的 warning。建议将 echo "::warning::..." 移到 inner if 成功后再打印,避免误报。


@watney1024
watney1024 merged commit 7356c4d into ScratchV-Compiler:main Aug 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants