Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
ensure ascii file names are used
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Jul 17, 2019
1 parent c49e646 commit 4b37f2d
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion engine/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/drone/runner-go/shell"

"github.com/dchest/uniuri"
"github.com/gosimple/slug"
)

// random generator function
Expand Down Expand Up @@ -194,7 +195,8 @@ func (c *Compiler) Compile(ctx context.Context) *engine.Spec {

// create steps
for _, src := range c.Pipeline.Steps {
buildpath := filepath.Join(spec.Root, "opt", src.Name+shell.Suffix)
buildslug := slug.Make(src.Name)
buildpath := filepath.Join(spec.Root, "opt", buildslug+shell.Suffix)
buildfile := shell.Script(src.Commands)

cmd, args := shell.Command()
Expand Down
7 changes: 7 additions & 0 deletions engine/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,15 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {

ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs", "Secrets")
if diff := cmp.Diff(got, want, ignore); len(diff) != 0 {
dump(got)
t.Errorf(diff)
}

return got
}

func dump(v interface{}) {
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(v)
}
6 changes: 3 additions & 3 deletions engine/compiler/testdata/graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/clone",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3RlcgoK"
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3Rlcgo="
}
],
"secrets": [],
Expand All @@ -55,7 +55,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"secrets": [],
Expand All @@ -75,7 +75,7 @@
{
"path": "/tmp/drone-random/opt/test",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cgo="
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
}
],
"secrets": [],
Expand Down
4 changes: 2 additions & 2 deletions engine/compiler/testdata/match.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"name": "build",
Expand All @@ -53,7 +53,7 @@
{
"path": "/tmp/drone-random/opt/test",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cgo="
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
}
],
"name": "test",
Expand Down
4 changes: 2 additions & 2 deletions engine/compiler/testdata/noclone_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"name": "build",
Expand All @@ -54,7 +54,7 @@
{
"path": "/tmp/drone-random/opt/test",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cgo="
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
}
],
"name": "test",
Expand Down
2 changes: 1 addition & 1 deletion engine/compiler/testdata/noclone_serial.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCmVjaG8gKyAiZ28gdGVzdCIKZ28gdGVzdAoK"
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCmVjaG8gKyAiZ28gdGVzdCIKZ28gdGVzdAo="
}
],
"name": "build",
Expand Down
2 changes: 1 addition & 1 deletion engine/compiler/testdata/run_always.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"name": "build",
Expand Down
2 changes: 1 addition & 1 deletion engine/compiler/testdata/run_failure.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"name": "build",
Expand Down
6 changes: 3 additions & 3 deletions engine/compiler/testdata/serial.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{
"path": "/tmp/drone-random/opt/clone",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3RlcgoK"
"data": "CnNldCAtZQoKZWNobyArICJnaXQgaW5pdCIKZ2l0IGluaXQKCmVjaG8gKyAiZ2l0IHJlbW90ZSBhZGQgb3JpZ2luICIKZ2l0IHJlbW90ZSBhZGQgb3JpZ2luIAoKZWNobyArICJnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6IgpnaXQgZmV0Y2ggIG9yaWdpbiArcmVmcy9oZWFkcy9tYXN0ZXI6CgplY2hvICsgImdpdCBjaGVja291dCAgLWIgbWFzdGVyIgpnaXQgY2hlY2tvdXQgIC1iIG1hc3Rlcgo="
}
],
"secrets": [],
Expand All @@ -55,7 +55,7 @@
{
"path": "/tmp/drone-random/opt/build",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQKCg=="
"data": "CnNldCAtZQoKZWNobyArICJnbyBidWlsZCIKZ28gYnVpbGQK"
}
],
"secrets": [],
Expand All @@ -75,7 +75,7 @@
{
"path": "/tmp/drone-random/opt/test",
"mode": 448,
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cgo="
"data": "CnNldCAtZQoKZWNobyArICJnbyB0ZXN0IgpnbyB0ZXN0Cg=="
}
],
"secrets": [],
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ require (
github.com/drone/signal v1.0.0
github.com/golang/mock v1.3.1
github.com/google/go-cmp v0.3.0
github.com/gosimple/slug v1.5.0
github.com/hashicorp/go-multierror v1.0.0
github.com/joho/godotenv v1.3.0
github.com/kardianos/service v1.0.0
github.com/kelseyhightower/envconfig v1.3.0
github.com/mattn/go-isatty v0.0.8
github.com/natessilva/dag v0.0.0-20180124060714-7194b8dcc5c4
github.com/orandin/lumberjackrus v1.0.1
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
github.com/sirupsen/logrus v1.4.2
golang.org/x/sync v0.0.0-20190423024810-112230192c58
gopkg.in/alecthomas/kingpin.v2 v2.2.6
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/gosimple/slug v1.5.0 h1:AIIjgCjHcLpX8LzM2NpG4QGW9kUfqv0OLiFRfPv/H3E=
github.com/gosimple/slug v1.5.0/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
Expand All @@ -166,6 +168,8 @@ github.com/natessilva/dag v0.0.0-20180124060714-7194b8dcc5c4/go.mod h1:cojhOHk1g
github.com/orandin/lumberjackrus v1.0.1 h1:7ysDQ0MHD79zIFN9/EiDHjUcgopNi5ehtxFDy8rUkWo=
github.com/orandin/lumberjackrus v1.0.1/go.mod h1:xYLt6H8W93pKnQgUQaxsApS0Eb4BwHLOkxk5DVzf5H0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
Expand Down

0 comments on commit 4b37f2d

Please sign in to comment.