Skip to content

Commit

Permalink
fix: artifact.Path should filepath.ToSlash (#4117)
Browse files Browse the repository at this point in the history
this is needed when we run part of the pipeline on windows, and the rest
on linux, for example, the split build pro feature.

extracted from #3795 

+ added tests for relative path thing

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Jun 16, 2023
1 parent e5a0f66 commit ef3c42f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/artifact/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func (artifacts *Artifacts) Add(a *Artifact) {
a.Path = rel
}
}
a.Path = filepath.ToSlash(a.Path)
log.WithField("name", a.Name).
WithField("type", a.Type).
WithField("path", a.Path).
Expand Down
4 changes: 4 additions & 0 deletions internal/artifact/artifact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ var _ fmt.Stringer = Type(0)
func TestAdd(t *testing.T) {
var g errgroup.Group
artifacts := New()
wd, _ := os.Getwd()
for _, a := range []*Artifact{
{
Name: "foo",
Type: UploadableArchive,
Path: filepath.Join(wd, "/foo/bar.tgz"),
},
{
Name: "bar",
Expand All @@ -46,6 +48,8 @@ func TestAdd(t *testing.T) {
}
require.NoError(t, g.Wait())
require.Len(t, artifacts.List(), 4)
archives := artifacts.Filter(ByType(UploadableArchive)).List()
require.Len(t, archives, 1)
}

func TestFilter(t *testing.T) {
Expand Down

0 comments on commit ef3c42f

Please sign in to comment.