From 5690b9f15b1a9acee4e5be8d33a6cea79998e2f2 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 22:42:28 +0000 Subject: [PATCH] fix(build): narrow workflow directory detection Co-Authored-By: Virgil --- pkg/build/workflow.go | 8 ++++++-- pkg/build/workflow_test.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/build/workflow.go b/pkg/build/workflow.go index e7185de..f3a8420 100644 --- a/pkg/build/workflow.go +++ b/pkg/build/workflow.go @@ -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, "/\\") } diff --git a/pkg/build/workflow_test.go b/pkg/build/workflow_test.go index 1b47dc7..397d3b7 100644 --- a/pkg/build/workflow_test.go +++ b/pkg/build/workflow_test.go @@ -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)