diff --git a/Dockerfile b/Dockerfile index 1a3abf7..4a36135 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM golang:1.16-alpine as builder WORKDIR /build COPY . . +# Make sure tests pass before building :) +RUN CGO_ENABLED=0 go test ./... RUN CGO_ENABLED=0 go build -a -o render-drawio ./cmd/render-drawio FROM rlespinasse/drawio-desktop-headless:1.0.1 diff --git a/pkg/render/render.go b/pkg/render/render.go index cc42ab7..50ef8f1 100644 --- a/pkg/render/render.go +++ b/pkg/render/render.go @@ -257,6 +257,13 @@ func GitHubActionSetFilesOutput(key, rootDir string, files []string) error { } } // Run the generic function - GitHubActionSetOutput(key, strings.Join(files, " ")) + GitHubActionSetOutput(key, joinQuotedStrings(files)) return nil } + +func joinQuotedStrings(strs []string) string { + for i := range strs { + strs[i] = fmt.Sprintf("%q", strs[i]) + } + return strings.Join(strs, " ") +} diff --git a/pkg/render/render_test.go b/pkg/render/render_test.go new file mode 100644 index 0000000..28653bf --- /dev/null +++ b/pkg/render/render_test.go @@ -0,0 +1,24 @@ +package render + +import "testing" + +func Test_joinQuotedStrings(t *testing.T) { + tests := []struct { + name string + strs []string + want string + }{ + { + name: "simple", + strs: []string{"foo bar", "bar baz"}, + want: `"foo bar" "bar baz"`, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := joinQuotedStrings(tt.strs); got != tt.want { + t.Errorf("joinQuotedStrings() = %v, want %v", got, tt.want) + } + }) + } +}