fix(build): narrow workflow directory detection
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
e7c991ed36
commit
5690b9f15b
2 changed files with 16 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ package build
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"strings"
|
||||
|
||||
"dappco.re/go/core/build/internal/ax"
|
||||
io_interface "dappco.re/go/core/io"
|
||||
|
|
@ -188,10 +189,13 @@ func isWorkflowDirectoryPath(path string) bool {
|
|||
|
||||
// isWorkflowDirectoryInput reports whether a workflow input should be treated
|
||||
// as a directory target. This includes explicit directory paths and bare names
|
||||
// without a file extension.
|
||||
// without path separators or a file extension.
|
||||
func isWorkflowDirectoryInput(path string) bool {
|
||||
if isWorkflowDirectoryPath(path) {
|
||||
return true
|
||||
}
|
||||
return path != "" && ax.Ext(path) == ""
|
||||
if path == "" || ax.Ext(path) != "" {
|
||||
return false
|
||||
}
|
||||
return !strings.ContainsAny(path, "/\\")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,10 @@ func TestWorkflow_ResolveReleaseWorkflowPath_Good(t *testing.T) {
|
|||
assert.Equal(t, "/tmp/project/ci/release.yml", ResolveReleaseWorkflowPath("/tmp/project", "ci"))
|
||||
})
|
||||
|
||||
t.Run("keeps nested extensionless paths as files", func(t *testing.T) {
|
||||
assert.Equal(t, "/tmp/project/ci/release", ResolveReleaseWorkflowPath("/tmp/project", "ci/release"))
|
||||
})
|
||||
|
||||
t.Run("treats the current directory as a workflow directory", func(t *testing.T) {
|
||||
assert.Equal(t, "/tmp/project/release.yml", ResolveReleaseWorkflowPath("/tmp/project", "."))
|
||||
})
|
||||
|
|
@ -160,6 +164,12 @@ func TestWorkflow_ResolveReleaseWorkflowInputPath_Good(t *testing.T) {
|
|||
assert.Equal(t, "/tmp/project/ci/release.yml", path)
|
||||
})
|
||||
|
||||
t.Run("keeps nested extensionless paths as files", func(t *testing.T) {
|
||||
path, err := ResolveReleaseWorkflowInputPath("/tmp/project", "ci/release", "")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "/tmp/project/ci/release", path)
|
||||
})
|
||||
|
||||
t.Run("accepts the current directory as the primary input", func(t *testing.T) {
|
||||
path, err := ResolveReleaseWorkflowInputPath("/tmp/project", ".", "")
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue