refactor: move getContainerActionPaths into step interface (#13)

* allows to specialize local vs remote action implementation
* allow paths like ./.. for local action

Closes https://gitea.com/actions-oss/act-cli/issues/12

Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/13
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-committed-by: ChristopherHX <christopher.homberger@web.de>
This commit is contained in:
ChristopherHX
2025-12-19 16:24:48 +00:00
committed by ChristopherHX
parent ee2e0135d5
commit ce0890578a
11 changed files with 196 additions and 178 deletions

View File

@@ -345,3 +345,30 @@ func TestIsContinueOnError(t *testing.T) {
assertObject.False(continueOnError)
assertObject.NotNil(err)
}
func TestSymlinkJoin(t *testing.T) {
table := []struct {
from string
target string
root []string
result string
err string
}{
{"/some/file/somewhere/action.yml", "../../../", []string{"/"}, "/", ""},
{"/some/file/somewhere/action.yml", "../../../var/lib/act/action.yml", []string{"/some/file/somewhere", "/var/lib/act"}, "/var/lib/act/action.yml", ""},
{"/some/file/somewhere/action.yml", "../../../var/lib/act/action.yml", []string{"/"}, "/var/lib/act/action.yml", ""},
{"/some/file/somewhere/action.yml", "../../var/lib/act/action.yml", []string{"/some/file/somewhere", "/var/lib/act"}, "", "Not allowed"},
{"/some/file/somewhere/action.yml", "../../var/lib/act/action.yml", []string{"/some/file", "/var/lib/act"}, "", "Not allowed"},
{"/some/file/somewhere/action.yml", "../../var/lib/act/action.yml", []string{"/some/", "/var/lib/act"}, "/some/var/lib/act/action.yml", ""},
}
for _, entry := range table {
result, err := symlinkJoin(entry.from, entry.target, entry.root...)
if entry.err == "" {
assert.NoError(t, err)
} else {
assert.Error(t, err, entry.err)
}
assert.Equal(t, entry.result, result)
}
}