fix: preserve symlinked Node action entrypoints (#1202)

Node resolves an ESM main to its realpath but leaves `process.argv[1]` as passed. `/var/run/act` reaches the action through the `/var/run` -> `/run` symlink most images ship, so the two disagree and actions comparing them skip their own `run()`. Passing `--preserve-symlinks-main` makes them match.

Trade-off: an action whose `runs.main` is a symlink now resolves dependencies from the link's directory rather than the target's.

Fixes https://gitea.com/gitea/runner/issues/1201
Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1202
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
Co-authored-by: bircni <bircni@noreply.gitea.com>
This commit is contained in:
bircni
2026-08-31 13:06:49 +00:00
committed by silverwind
parent 6c77065295
commit b9018aca31
4 changed files with 43 additions and 7 deletions
+2 -1
View File
@@ -254,7 +254,8 @@ func TestStepActionLocalPost(t *testing.T) {
if tt.mocks.exec {
suffixMatcher := func(suffix string) any {
return mock.MatchedBy(func(array []string) bool {
return strings.HasSuffix(array[1], suffix)
return len(array) == 3 && array[0] == "node" && array[1] == "--preserve-symlinks-main" &&
strings.HasSuffix(array[2], suffix)
})
}
cm.On("Exec", suffixMatcher("runner/local/action/post.js"), sal.env, "", "").Return(func(ctx context.Context) error { return tt.err })