docs: add CI log retrieval methods and failure diagnosis to AGENTS.md

This commit is contained in:
Warren
2026-05-16 16:40:52 +08:00
parent 79e761082d
commit 87a3eea2c6

View File

@@ -510,7 +510,56 @@ curl http://localhost:11438/api/v2/tree/demo?mode=tree
```bash
act_runner list #查看 Runner狀態
act_runner daemon #啟動 Runner
````
```
###CI/CD日志查看方式
**方法1通過 Gitea Web UI查看推薦**
```
https://gitea.momentry.ddns.net/warren/markbase/actions
```
**方法2通過 API獲取詳細日志**
**步驟:**
1. **獲取所有 Actions Runs**
```bash
curl -H "Authorization: token c5e025496ebc3c7408a971d64a33bd56aac9186c" \
https://gitea.momentry.ddns.net/api/v1/repos/warren/markbase/actions/runs | jq '.workflow_runs[] | {id, status, conclusion}'
```
2. **獲取特定 Run的所有 Jobs**
```bash
curl -H "Authorization: token c5e025496ebc3c7408a971d64a33bd56aac9186c" \
https://gitea.momentry.ddns.net/api/v1/repos/warren/markbase/actions/runs/<RUN_ID>/jobs | jq '.jobs[] | {id, name, status, conclusion}'
```
3. **獲取 Job詳細日志**
```bash
curl -H "Authorization: token c5e025496ebc3c7408a971d64a33bd56aac9186c" \
https://gitea.momentry.ddns.net/api/v1/repos/warren/markbase/actions/jobs/<JOB_ID>/logs
```
**範例:查看 Run ID 6的 test job日志**
```bash
# Step 1: 獲取 jobs列表
curl -s -H "Authorization: token c5e025496ebc3c7408a971d64a33bd56aac9186c" \
https://gitea.momentry.ddns.net/api/v1/repos/warren/markbase/actions/runs/6/jobs | jq '.jobs[] | {id, name}'
# Step 2:獲取 job 11test job的完整日志
curl -s -H "Authorization: token c5e025496ebc3c7408a971d64a33bd56aac9186c" \
https://gitea.momentry.ddns.net/api/v1/repos/warren/markbase/actions/jobs/11/logs
```
**日志格式:**
- 每行以時間戳開頭:`2026-05-16T08:26:07.5859940Z`
- 包含完整執行過程、命令輸出、錯誤信息
- 錯誤行通常包含 `##[error]`標記
**常見錯誤診斷:**
- `conditional binary operator expected` → bash腳本語法問題
- `Process completed with exit code 2` →腳本執行失敗
- `Unable to pull refs/heads/v3` → Git clone問題通常可忽略`
---
@@ -538,17 +587,28 @@ act_runner daemon #啟動 Runner
###待解決問題
**CI失敗原因**
- 需訪問 Gitea Web UI查看詳細失敗日志
- URL: https://gitea.momentry.ddns.net/warren/markbase/actions/runs/4
- 可能原因CI環境配置問題
**CI失敗根本原因(已診斷)**
- **失敗位置:** Setup Rust步驟actions-rust-lang/setup-rust-toolchain@v1
- **錯誤信息:** `conditional binary operator expected`line 2
- **具體問題:** GitHub Action與Gitea Runner的bash環境不完全兼容
- **執行時間:** 5秒快速失敗早期階段錯誤
**下一步建議**
1. 檢查 Gitea Actions Web界面查看失敗詳細信息
2. 確認 CI環境是否缺少依賴如 SwitchAudioSource
3. 調整 workflow配置以適應 CI環境
**失敗統計**
- Run ID 1-6全部失敗6次CI失敗
- 執行時間5-74秒不等早期失敗
- 失敗步驟Setup Rustbash腳本兼容性問題
**解決方案:**
1. 替換 `actions-rust-lang/setup-rust-toolchain@v1`為原生rustup安裝
2. 使用更兼容的action如 dtolnay/rust-toolchain@stable
3. 直接執行 `curl | sh`安裝rustup
**下一步行動:**
- 修改 workflow文件使用原生安裝方式
- 提交並推送觸發新CI run
- 验证修復是否成功
---
**最後更新2026-05-16**
**版本1.1部署完成版)**
**版本1.2CI問題診斷完成版)**