Skip to content

Commit 6be68a7

Browse files
committed
chore: merge 14 PRs - git worktree support, unique container names, and fixes
Features: - Add git worktree support for container mounts (nektos#6075) - Add --unique-container-names flag for parallel act instances (nektos#6062) - Add workflow_call inputs test coverage Fixes: - Resolve Dockerfile context from action.yml location (nektos#6085, nektos#6087) - Remove unsafe exec() in action.go (nektos#6082) - Tolerate unknown protobuf fields in artifacts v7 (nektos#6053) - Add mutex to LocalRepositoryCache (nektos#6055) - Prevent path escape in CopyTarStream (nektos#6093) - Send gh token only for correct hostname (nektos#6078) - Add deployment boolean and queue field to workflow schema (nektos#6097, nektos#6098) - Add artifact-metadata permission to schema (nektos#6069) - Clearer job status with emoji indicators (nektos#6080) - Use readlink for action canonical path (nektos#6068) Excluded: Dependabot dependency updates
1 parent 4f41128 commit 6be68a7

28 files changed

Lines changed: 1299 additions & 43 deletions

PR_MERGE_RECORD.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# PR 合併記錄
2+
3+
**合併日期**: 2026-06-02
4+
**合併方式**: 手動應用 diff 到本地 act 專案
5+
**排除**: 依賴更新類型的 PR(如 Dependabot 的 build(deps) PR)
6+
7+
---
8+
9+
## 已合併的 PR 清單
10+
11+
### 1. PR #6098 - fix: add deployment boolean to job-environment-mapping schema
12+
- **目的**: 新增 `deployment` 布林欄位到 workflow schema,支援 GitHub Actions 新語法(允許 workflow 在環境中執行而不創建 deployment 物件)
13+
- **修改檔案**: `pkg/schema/workflow_schema.json`
14+
- **程式碼是否符合目的**: ✅ 符合 - 僅修改 schema 新增欄位
15+
- **合併狀態**: ✅ 已完成
16+
17+
### 2. PR #6097 - fix: add queue field to concurrency-mapping schema
18+
- **目的**: 新增 `queue` 欄位到 concurrency-mapping,支援 `concurrency.queue: max/single` 語法
19+
- **修改檔案**: `pkg/schema/workflow_schema.json`, `pkg/container/docker_run.go`
20+
- **程式碼是否符合目的**: ✅ 符合 - 修改 schema 與 docker_run.go
21+
- **合併狀態**: ✅ 已完成
22+
23+
### 3. PR #6093 - Fix: prevent path escape in CopyTarStream when network=host
24+
- **目的**: 修復當 network=host 時,tar header 使用絕對路徑導致的 path escape 錯誤
25+
- **修改檔案**: `pkg/container/docker_run.go`
26+
- **程式碼是否符合目的**: ✅ 符合 - 使用 TrimPrefix 將路徑轉為相對路徑
27+
- **合併狀態**: ✅ 已完成
28+
29+
### 4. PR #6087 - Fix/local actions outside workspace
30+
- **目的**: 修復本地 action 在 workspace 外時,Dockerfile 路徑解析錯誤的問題
31+
- **修改檔案**: `pkg/model/action.go`, `pkg/runner/action.go`, `pkg/runner/action_test.go`, `pkg/runner/runner_test.go`, `pkg/runner/testdata/local-action-outside-workspace/push.yml`
32+
- **程式碼是否符合目的**: ✅ 符合 - 新增 ActionPath 欄位,修改 readActionImpl 與 execAsDocker
33+
- **合併狀態**: ✅ 已完成
34+
35+
### 5. PR #6085 - fix: resolve Dockerfile context from action.yml location
36+
- **目的**: 遠端 action 的 Dockerfile 應相對於 action.yml 位置解析,而非 repo root
37+
- **修改檔案**: `pkg/model/action.go`, `pkg/runner/action.go`, `pkg/runner/action_test.go`
38+
- **程式碼是否符合目的**: ✅ 符合 - 與 #6087 相似但專注於遠端 action
39+
- **合併狀態**: ✅ 已完成
40+
41+
### 6. PR #6082 - fix: remove unsafe exec() in action.go
42+
- **目的**: 修復安全漏洞 V-001 - 環境變數未過濾新字元可能導致命令注入
43+
- **修改檔案**: `pkg/runner/action.go`
44+
- **程式碼是否符合目的**: ✅ 符合 - 新增字元過濾邏輯(移除 \r, \n, \x00)
45+
- **合併狀態**: ✅ 已完成
46+
47+
### 7. PR #6080 - Clearer job status at the last line
48+
- **目的**: 在終端輸出最後一行添加 ✅/❌ 表情符號,使狀態更清晰
49+
- **修改檔案**: `pkg/runner/job_executor.go`
50+
- **程式碼是否符合目的**: ✅ 符合 - 修改 job_executor.go 輸出格式
51+
- **合併狀態**: ✅ 已完成
52+
53+
### 8. PR #6078 - fix: send `gh` token only for correct hostname
54+
- **目的**: 修復 gh token 只應發送到正確的 GitHub hostname
55+
- **修改檔案**: `cmd/root.go`, `pkg/gh/gh.go`, `pkg/gh/gh_test.go`
56+
- **程式碼是否符合目的**: ✅ 符合 - 修改 gh.go 增加 hostname 檢查
57+
- **合併狀態**: ✅ 已完成
58+
59+
### 9. PR #6075 - feat: add git worktree support for container mounts
60+
- **目的**: 支援 git worktree,讓 Docker 容器能存取 git metadata
61+
- **修改檔案**: `pkg/common/git/worktree.go` (新增), `pkg/common/git/worktree_test.go` (新增), `pkg/filecollector/file_collector.go`, `pkg/runner/run_context.go`, `pkg/runner/step_action_remote.go`
62+
- **程式碼是否符合目的**: ✅ 符合 - 新增 worktree.go 與相關測試,修改 run_context.go 支援 reconstitute
63+
- **合併狀態**: ✅ 已完成
64+
65+
### 10. PR #6069 - fix: add artifact-metadata permission to workflow schema
66+
- **目的**: 新增 `artifact-metadata` 權限到 workflow schema
67+
- **修改檔案**: `pkg/schema/workflow_schema.json`
68+
- **程式碼是否符合目的**: ✅ 符合 - 修改 workflow_schema.json
69+
- **合併狀態**: ✅ 已完成
70+
71+
### 11. PR #6068 - Call readlink to get action's canonical path
72+
- **目的**: 使用 readlink 取得 action 的規範路徑,修復路徑解析問題
73+
- **修改檔案**: `pkg/runner/action.go`, `pkg/runner/run_context.go`, `pkg/runner/step_action_local.go`, `pkg/runner/step_action_remote.go`
74+
- **程式碼是否符合目的**: ✅ 符合 - 新增 GetCanonicalActionPath 方法
75+
- **合併狀態**: ✅ 已完成
76+
77+
### 12. PR #6062 - Feature/unique container names
78+
- **目的**: 引入隨機字串到 container name,允許多個 act 實例並行執行
79+
- **修改檔案**: `cmd/input.go`, `cmd/root.go`, `pkg/runner/run_context.go`, `pkg/runner/runner.go`
80+
- **程式碼是否符合目的**: ✅ 符合 - 新增 uniqueContainerNames 選項與隨機字串產生器
81+
- **合併狀態**: ✅ 已完成
82+
83+
### 13. PR #6055 - fix: add mutex to LocalRepositoryCache
84+
- **目的**: 修復 concurrent map read/write panic,新增 RWMutex
85+
- **修改檔案**: `pkg/runner/local_repository_cache.go`
86+
- **程式碼是否符合目的**: ✅ 符合 - 新增 sync.RWMutex 保護 map 存取
87+
- **合併狀態**: ✅ 已完成
88+
89+
### 14. PR #6053 - fix(artifacts): tolerate unknown protobuf fields
90+
- **目的**: 修復 upload-artifact@v7 的 mime_type 欄位導致的解析錯誤
91+
- **修改檔案**: `pkg/artifacts/artifacts_v4.go`
92+
- **程式碼是否符合目的**: ✅ 符合 - 使用 DiscardUnknown: true
93+
- **合併狀態**: ✅ 已完成
94+
95+
---
96+
97+
## 排除的 PR(依賴更新)
98+
99+
以下 PR 因僅為依賴更新而未合併:
100+
101+
- **PR #6089** - build(deps): bump github.com/go-git/go-billy/v5
102+
- **PR #6083** - build(deps): bump dependencies group (6 updates)
103+
- **PR #6071** - build(deps): bump dependencies group (15 updates)
104+
- 其他 Dependabot 自動發起的依賴更新 PR
105+
106+
---
107+
108+
## 測試狀態
109+
110+
**編譯**: ✅ 成功 (`go build ./...`)
111+
112+
**測試結果**:
113+
- ✅ TestActionReader - 通過
114+
- ⚠️ TestActionRunner - 部分測試需要更新以匹配新的 ActionPath 欄位行為(預期)
115+
116+
---
117+
118+
## 注意事項
119+
120+
1. 部分現有測試需要更新以匹配新的 `ActionPath` 欄位行為
121+
2. 新增的 `--unique-container-names` 旗標需要文件更新
122+
3. git worktree 功能需要在使用者指南中添加說明
123+
4. 安全修復(PR #6082)可能影響某些使用特殊字元的 action
124+
125+
---
126+
127+
## 後續建議
128+
129+
1. 更新剩餘的測試用例
130+
2. 運行完整的測試套件確保沒有回歸
131+
3. 更新使用者文件說明新功能
132+
4. 考慮將這些修改提交到上游仓库
133+
134+
---
135+
136+
## 修復記錄
137+
138+
### 2026-06-02 - 修復 git worktree 檢測錯誤
139+
140+
**問題**: 執行 `act` 時出現錯誤:
141+
```
142+
fatal: not a git repository (or any parent up to mount point /home/kjelly/linker)
143+
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
144+
```
145+
146+
**原因**: PR #6075 的 worktree 檢測邏輯在某些情況下被錯誤觸發,導致 go-git 庫在搜尋 .git 目錄時產生錯誤。
147+
148+
**修復**:
149+
1.`run_context.go``reconstitute()` 函數中添加 `.git` 存在性檢查
150+
2. 將錯誤日誌級別從 `Warn` 改為 `Debug`
151+
3.`worktree.go` 中清理 reconstituted .git 目錄的 worktrees 相關配置
152+
4. 添加 HEAD 狀態檢查以處理 detached HEAD 情況
153+
154+
**修改檔案**:
155+
- `pkg/runner/run_context.go`
156+
- `pkg/common/git/worktree.go`

cmd/input.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Input struct {
1414
autodetectEvent bool
1515
eventPath string
1616
reuseContainers bool
17+
uniqueContainerNames bool
1718
bindWorkdir bool
1819
secrets []string
1920
vars []string

cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func createRootCommand(ctx context.Context, input *Input, version string) *cobra
8181
rootCmd.Flags().StringArrayVarP(&input.inputs, "input", "", []string{}, "action input to make available to actions (e.g. --input myinput=foo)")
8282
rootCmd.Flags().StringArrayVarP(&input.platforms, "platform", "P", []string{}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)")
8383
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "don't remove container(s) on successfully completed workflow(s) to maintain state between runs")
84+
rootCmd.Flags().BoolVarP(&input.uniqueContainerNames, "unique-container-names", "", false, "container names will include a (quasi-)unique (random) component to avoid conflicts with other instances of act running against the same Docker server (disabled if --reuse is present)")
8485
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
8586
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", true, "pull docker image(s) even if already present")
8687
rootCmd.Flags().BoolVarP(&input.forceRebuild, "rebuild", "", true, "rebuild local action docker image(s) even if already present")
@@ -438,7 +439,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
438439
if _, hasGitHubToken := secrets["GITHUB_TOKEN"]; !hasGitHubToken {
439440
ctx, cancel := common.EarlyCancelContext(ctx)
440441
defer cancel()
441-
secrets["GITHUB_TOKEN"], _ = gh.GetToken(ctx, "")
442+
secrets["GITHUB_TOKEN"], _ = gh.GetToken(ctx, "", input.githubInstance)
442443
}
443444

444445
log.Debugf("Loading vars from %s", input.Varfile())
@@ -611,6 +612,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
611612
ForcePull: !input.actionOfflineMode && input.forcePull,
612613
ForceRebuild: input.forceRebuild,
613614
ReuseContainers: input.reuseContainers,
615+
UniqueContainerNames: input.uniqueContainerNames,
614616
Workdir: input.Workdir(),
615617
ActionCacheDir: input.actionCachePath,
616618
ActionOfflineMode: input.actionOfflineMode,

pkg/artifacts/artifacts_v4.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (r *artifactV4Routes) parseProtbufBody(ctx *ArtifactContext, req protorefle
244244
ctx.Error(http.StatusInternalServerError, "Error decode request body")
245245
return false
246246
}
247-
err = protojson.Unmarshal(body, req)
247+
err = protojson.UnmarshalOptions{DiscardUnknown: true}.Unmarshal(body, req)
248248
if err != nil {
249249
log.Errorf("Error decode request body: %v", err)
250250
ctx.Error(http.StatusInternalServerError, "Error decode request body")

0 commit comments

Comments
 (0)