From 11c703eee931402321a9d99264bbe60c5cf881e2 Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 13:32:33 +0900 Subject: [PATCH 1/6] Add tip build --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 44beea79..499ce71d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,11 @@ language: go go: - "1.11.x" - "1.12.x" + - tip matrix: + allow_failures: + - go: tip exclude: - go: tip os: osx From 1cdd88586f4c8e252d0b8f5698fbe4d435d04e0a Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 13:45:13 +0900 Subject: [PATCH 2/6] Remove exclude matrix --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 499ce71d..4f59e4a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,6 @@ go: matrix: allow_failures: - go: tip - exclude: - - go: tip - os: osx env: global: From f34ff0179b4a3e2ffb43b7d86301f083bf4e8237 Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 13:46:57 +0900 Subject: [PATCH 3/6] Add windows build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f59e4a7..07d92fb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ os: - linux - osx -# - windows is still early access stage: https://travis-ci.community/c/windows + - windows language: go go: From b9b5c9fb13c86e0968482de4fdd487f5bad05e01 Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 14:25:52 +0900 Subject: [PATCH 4/6] s/path/filepath/g --- application/initialize_test.go | 18 ++++----- application/service/executor/executor_test.go | 10 ++--- application/service/job/service_test.go | 6 +-- domain/model/job/target/github.go | 4 +- domain/model/job/target/local.go | 8 ++-- domain/model/runner/helper_test.go | 40 +++++++++---------- domain/model/runner/runner_test.go | 8 ++-- infrastructure/job/data_source_test.go | 6 +-- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/application/initialize_test.go b/application/initialize_test.go index 25fa8cfd..2fa9a148 100644 --- a/application/initialize_test.go +++ b/application/initialize_test.go @@ -8,7 +8,7 @@ import ( "github.com/duck8823/duci/internal/container" "github.com/labstack/gommon/random" "os" - "path" + "path/filepath" "testing" ) @@ -19,7 +19,7 @@ func TestInitialize(t *testing.T) { sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = "" - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath @@ -57,18 +57,18 @@ func TestInitialize(t *testing.T) { t.Run("with correct ssh key path", func(t *testing.T) { // given - dir := path.Join(os.TempDir(), random.String(16)) + dir := filepath.Join(os.TempDir(), random.String(16)) if err := os.MkdirAll(dir, 0700); err != nil { t.Fatalf("error occur: %+v", err) } - keyPath := path.Join(dir, "id_rsa") + keyPath := filepath.Join(dir, "id_rsa") application.GenerateSSHKey(t, keyPath) // and sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = keyPath - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath @@ -109,7 +109,7 @@ func TestInitialize(t *testing.T) { sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = "/path/to/invalid/key/path" - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath @@ -133,7 +133,7 @@ func TestInitialize(t *testing.T) { sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = "" - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath @@ -157,7 +157,7 @@ func TestInitialize(t *testing.T) { sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = "" - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath @@ -181,7 +181,7 @@ func TestInitialize(t *testing.T) { sshKeyPath := application.Config.GitHub.SSHKeyPath databasePath := application.Config.Server.DatabasePath application.Config.GitHub.SSHKeyPath = "" - application.Config.Server.DatabasePath = path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + application.Config.Server.DatabasePath = filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { application.Config.GitHub.SSHKeyPath = sshKeyPath application.Config.Server.DatabasePath = databasePath diff --git a/application/service/executor/executor_test.go b/application/service/executor/executor_test.go index 4a3b24af..1c8a3955 100644 --- a/application/service/executor/executor_test.go +++ b/application/service/executor/executor_test.go @@ -10,7 +10,7 @@ import ( "github.com/labstack/gommon/random" "github.com/pkg/errors" "os" - "path" + "path/filepath" "testing" "time" ) @@ -20,7 +20,7 @@ func TestJobExecutor_Execute(t *testing.T) { // given ctx := context.Background() target := &executor.StubTarget{ - Dir: job.WorkDir(path.Join(os.TempDir(), random.String(16))), + Dir: job.WorkDir(filepath.Join(os.TempDir(), random.String(16))), Cleanup: func() {}, Err: nil, } @@ -79,7 +79,7 @@ func TestJobExecutor_Execute(t *testing.T) { // given ctx := context.Background() target := &executor.StubTarget{ - Dir: job.WorkDir(path.Join(os.TempDir(), random.String(16))), + Dir: job.WorkDir(filepath.Join(os.TempDir(), random.String(16))), Cleanup: func() {}, Err: nil, } @@ -148,7 +148,7 @@ func TestJobExecutor_Execute(t *testing.T) { // and ctx := context.Background() target := &executor.StubTarget{ - Dir: job.WorkDir(path.Join(os.TempDir(), random.String(16))), + Dir: job.WorkDir(filepath.Join(os.TempDir(), random.String(16))), Cleanup: func() {}, Err: nil, } @@ -210,7 +210,7 @@ func TestJobExecutor_Execute(t *testing.T) { // given ctx := context.Background() target := &executor.StubTarget{ - Dir: job.WorkDir(path.Join(os.TempDir(), random.String(16))), + Dir: job.WorkDir(filepath.Join(os.TempDir(), random.String(16))), Cleanup: func() {}, Err: errors.New("test error"), } diff --git a/application/service/job/service_test.go b/application/service/job/service_test.go index 0a588199..09f5ca7f 100644 --- a/application/service/job/service_test.go +++ b/application/service/job/service_test.go @@ -11,7 +11,7 @@ import ( "github.com/labstack/gommon/random" "github.com/pkg/errors" "os" - "path" + "path/filepath" "testing" "time" ) @@ -19,7 +19,7 @@ import ( func TestInitialize(t *testing.T) { t.Run("with temporary directory", func(t *testing.T) { // given - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { _ = os.RemoveAll(tmpDir) }() @@ -35,7 +35,7 @@ func TestInitialize(t *testing.T) { t.Run("with invalid directory", func(t *testing.T) { // given - tmpDir := path.Join("/path/to/invalid/dir") + tmpDir := filepath.Join("/path/to/invalid/dir") defer func() { _ = os.RemoveAll(tmpDir) }() diff --git a/domain/model/job/target/github.go b/domain/model/job/target/github.go index 3a93bfdf..78496760 100644 --- a/domain/model/job/target/github.go +++ b/domain/model/job/target/github.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "gopkg.in/src-d/go-git.v4/plumbing" "os" - "path" + "path/filepath" ) // GitHub is target with github repository @@ -20,7 +20,7 @@ type GitHub struct { // Prepare working directory func (g *GitHub) Prepare(ctx context.Context) (job.WorkDir, job.Cleanup, error) { - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric, random.Numeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric, random.Numeric)) if err := os.MkdirAll(tmpDir, 0700); err != nil { return "", cleanupFunc(tmpDir), errors.WithStack(err) } diff --git a/domain/model/job/target/local.go b/domain/model/job/target/local.go index c3f8b6bf..bf0f7dff 100644 --- a/domain/model/job/target/local.go +++ b/domain/model/job/target/local.go @@ -8,7 +8,7 @@ import ( "io" "io/ioutil" "os" - "path" + "path/filepath" ) // Local is target with Local directory @@ -18,7 +18,7 @@ type Local struct { // Prepare working directory func (l *Local) Prepare() (job.WorkDir, job.Cleanup, error) { - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric, random.Numeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric, random.Numeric)) if err := os.MkdirAll(tmpDir, 0700); err != nil { return "", nil, errors.WithStack(err) } @@ -37,8 +37,8 @@ func copyDir(dstDir string, srcDir string) error { } for _, entry := range entries { - dstPath := path.Join(dstDir, entry.Name()) - srcPath := path.Join(srcDir, entry.Name()) + dstPath := filepath.Join(dstDir, entry.Name()) + srcPath := filepath.Join(srcDir, entry.Name()) if entry.IsDir() { if err := os.MkdirAll(dstPath, 0700); err != nil { diff --git a/domain/model/runner/helper_test.go b/domain/model/runner/helper_test.go index f48c1485..62dd12c7 100644 --- a/domain/model/runner/helper_test.go +++ b/domain/model/runner/helper_test.go @@ -7,26 +7,26 @@ import ( "github.com/google/go-cmp/cmp" "github.com/labstack/gommon/random" "os" - "path" + "path/filepath" "testing" ) func TestCreateTarball(t *testing.T) { t.Run("with correct directory", func(t *testing.T) { // given - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) if err := os.MkdirAll(tmpDir, 0700); err != nil { t.Fatalf("error occur: %+v", err) } defer os.RemoveAll(tmpDir) - if _, err := os.Create(path.Join(tmpDir, "a")); err != nil { + if _, err := os.Create(filepath.Join(tmpDir, "a")); err != nil { t.Fatalf("error occur: %+v", err) } // and - want := path.Join(tmpDir, "duci.tar") + want := filepath.Join(tmpDir, "duci.tar") // when got, err := runner.CreateTarball(job.WorkDir(tmpDir)) @@ -45,7 +45,7 @@ func TestCreateTarball(t *testing.T) { t.Run("with invalid directory", func(t *testing.T) { // given - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) // when got, err := runner.CreateTarball(job.WorkDir(tmpDir)) @@ -76,7 +76,7 @@ func TestDockerfilePath(t *testing.T) { given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) if err := os.MkdirAll(tmpDir, 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -92,8 +92,8 @@ func TestDockerfilePath(t *testing.T) { given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) - if err := os.MkdirAll(path.Join(tmpDir, ".duci"), 0700); err != nil { + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + if err := os.MkdirAll(filepath.Join(tmpDir, ".duci"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -108,11 +108,11 @@ func TestDockerfilePath(t *testing.T) { given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) - if err := os.MkdirAll(path.Join(tmpDir, ".duci"), 0700); err != nil { + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + if err := os.MkdirAll(filepath.Join(tmpDir, ".duci"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } - if _, err := os.Create(path.Join(tmpDir, ".duci", "Dockerfile")); err != nil { + if _, err := os.Create(filepath.Join(tmpDir, ".duci", "Dockerfile")); err != nil { t.Fatalf("error occur: %+v", err) } @@ -157,7 +157,7 @@ func TestRuntimeOptions(t *testing.T) { given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) if err := os.MkdirAll(tmpDir, 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -174,12 +174,12 @@ func TestRuntimeOptions(t *testing.T) { given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) - if err := os.MkdirAll(path.Join(tmpDir, ".duci"), 0700); err != nil { + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + if err := os.MkdirAll(filepath.Join(tmpDir, ".duci"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } - file, err := os.OpenFile(path.Join(tmpDir, ".duci", "config.yml"), os.O_RDWR|os.O_CREATE, 0400) + file, err := os.OpenFile(filepath.Join(tmpDir, ".duci", "config.yml"), os.O_RDWR|os.O_CREATE, 0400) if err != nil { t.Fatalf("%+v", err) } @@ -204,8 +204,8 @@ volumes: given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) - if err := os.MkdirAll(path.Join(tmpDir, ".duci", "config.yml"), 0700); err != nil { + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + if err := os.MkdirAll(filepath.Join(tmpDir, ".duci", "config.yml"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -221,12 +221,12 @@ volumes: given: func(t *testing.T) (workDir job.WorkDir, cleanup func()) { t.Helper() - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) - if err := os.MkdirAll(path.Join(tmpDir, ".duci"), 0700); err != nil { + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + if err := os.MkdirAll(filepath.Join(tmpDir, ".duci"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } - file, err := os.OpenFile(path.Join(tmpDir, ".duci", "config.yml"), os.O_RDWR|os.O_CREATE, 0400) + file, err := os.OpenFile(filepath.Join(tmpDir, ".duci", "config.yml"), os.O_RDWR|os.O_CREATE, 0400) if err != nil { t.Fatalf("%+v", err) } diff --git a/domain/model/runner/runner_test.go b/domain/model/runner/runner_test.go index f6f2558c..9ce802e0 100644 --- a/domain/model/runner/runner_test.go +++ b/domain/model/runner/runner_test.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" "io" "os" - "path" + "path/filepath" "testing" "time" ) @@ -80,7 +80,7 @@ func TestDockerRunnerImpl_Run(t *testing.T) { cmd := docker.Command{"echo", "test"} // and - if err := os.MkdirAll(path.Join(dir.String(), "duci.tar"), 0700); err != nil { + if err := os.MkdirAll(filepath.Join(dir.String(), "duci.tar"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -117,7 +117,7 @@ func TestDockerRunnerImpl_Run(t *testing.T) { cmd := docker.Command{"echo", "test"} // and - if err := os.MkdirAll(path.Join(dir.String(), ".duci", "config.yml"), 0700); err != nil { + if err := os.MkdirAll(filepath.Join(dir.String(), ".duci", "config.yml"), 0700); err != nil { t.Fatalf("error occur: %+v", err) } @@ -431,7 +431,7 @@ func TestDockerRunnerImpl_Run(t *testing.T) { func tmpDir(t *testing.T) (workDir job.WorkDir, clean func()) { t.Helper() - dir := job.WorkDir(path.Join(os.TempDir(), random.String(16))) + dir := job.WorkDir(filepath.Join(os.TempDir(), random.String(16))) if err := os.MkdirAll(dir.String(), 0700); err != nil { t.Fatalf("error occur: %+v", err) } diff --git a/infrastructure/job/data_source_test.go b/infrastructure/job/data_source_test.go index 02b71805..dec863d7 100644 --- a/infrastructure/job/data_source_test.go +++ b/infrastructure/job/data_source_test.go @@ -12,7 +12,7 @@ import ( "github.com/pkg/errors" "github.com/syndtr/goleveldb/leveldb" "os" - "path" + "path/filepath" "testing" "time" ) @@ -20,7 +20,7 @@ import ( func TestNewDataSource(t *testing.T) { t.Run("with temporary path", func(t *testing.T) { // given - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { _ = os.RemoveAll(tmpDir) }() @@ -41,7 +41,7 @@ func TestNewDataSource(t *testing.T) { t.Run("with wrong path", func(t *testing.T) { // given - tmpDir := path.Join(os.TempDir(), random.String(16, random.Alphanumeric)) + tmpDir := filepath.Join(os.TempDir(), random.String(16, random.Alphanumeric)) defer func() { _ = os.RemoveAll(tmpDir) }() From 57803583f4730c8c5364793d1341e3cb259b8eba Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 15:58:37 +0900 Subject: [PATCH 5/6] Add skip statement --- infrastructure/archive/tar/tar_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infrastructure/archive/tar/tar_test.go b/infrastructure/archive/tar/tar_test.go index d7d6ea1b..47c54add 100644 --- a/infrastructure/archive/tar/tar_test.go +++ b/infrastructure/archive/tar/tar_test.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "reflect" + "runtime" "strings" "testing" "time" @@ -107,6 +108,9 @@ func TestCreate(t *testing.T) { if os.Getuid() == 0 { t.Skip("skip if root user") } + if runtime.GOOS == "windows" { + t.Skip("skip in windows") + } // setup testDir, remove := createTestDir(t) From ca45c3584e2a1729300c779906f230c2c51ec996 Mon Sep 17 00:00:00 2001 From: shunsuke maeda Date: Sat, 4 May 2019 22:14:32 +0900 Subject: [PATCH 6/6] Allow failures when os is windows --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 07d92fb7..b1cf2ab4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ go: matrix: allow_failures: - go: tip + - os: windows env: global: