From 39adee8bbb9b8296c0ea69571eb34e2135782b00 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 19:24:30 +0000 Subject: [PATCH] fix(api): resolve release workflow paths relative to project Co-Authored-By: Virgil --- pkg/api/provider.go | 3 +++ pkg/api/provider_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pkg/api/provider.go b/pkg/api/provider.go index e75480e..0d001e2 100644 --- a/pkg/api/provider.go +++ b/pkg/api/provider.go @@ -8,6 +8,7 @@ package api import ( "io/fs" "net/http" + "path/filepath" "dappco.re/go/core/api" "dappco.re/go/core/api/pkg/provider" @@ -531,6 +532,8 @@ func (p *BuildProvider) generateReleaseWorkflow(c *gin.Context) { path := req.Path if path == "" { path = build.ReleaseWorkflowPath(dir) + } else if !filepath.IsAbs(path) { + path = ax.Join(dir, path) } if err := build.WriteReleaseWorkflow(p.medium, path); err != nil { diff --git a/pkg/api/provider_test.go b/pkg/api/provider_test.go index 9d64127..cad9d0d 100644 --- a/pkg/api/provider_test.go +++ b/pkg/api/provider_test.go @@ -182,3 +182,27 @@ func TestProvider_GenerateReleaseWorkflow_Good(t *testing.T) { assert.Contains(t, content, "workflow_call:") assert.Contains(t, content, "workflow_dispatch:") } + +func TestProvider_GenerateReleaseWorkflow_CustomPath_Good(t *testing.T) { + gin.SetMode(gin.TestMode) + + projectDir := t.TempDir() + p := NewProvider(projectDir, nil) + + recorder := httptest.NewRecorder() + request := httptest.NewRequest(http.MethodPost, "/release/workflow", bytes.NewBufferString(`{"path":"ci/release.yml"}`)) + request.Header.Set("Content-Type", "application/json") + + ctx, _ := gin.CreateTestContext(recorder) + ctx.Request = request + + p.generateReleaseWorkflow(ctx) + + assert.Equal(t, http.StatusOK, recorder.Code) + + path := ax.Join(projectDir, "ci", "release.yml") + content, err := io.Local.Read(path) + require.NoError(t, err) + assert.Contains(t, content, "workflow_call:") + assert.Contains(t, content, "workflow_dispatch:") +}