Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #237 from duck8823/maintenance/add_tip_build
Browse files Browse the repository at this point in the history
Add tip build
  • Loading branch information
duck8823 authored May 4, 2019
2 parents a5e4dd4 + ca45c35 commit 0800f70
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 53 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
os:
- linux
- osx
# - windows is still early access stage: https://travis-ci.community/c/windows
- windows

language: go
go:
- "1.11.x"
- "1.12.x"
- tip

matrix:
exclude:
allow_failures:
- go: tip
os: osx
- os: windows

env:
global:
Expand Down
18 changes: 9 additions & 9 deletions application/initialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/duck8823/duci/internal/container"
"github.com/labstack/gommon/random"
"os"
"path"
"path/filepath"
"testing"
)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions application/service/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/labstack/gommon/random"
"github.com/pkg/errors"
"os"
"path"
"path/filepath"
"testing"
"time"
)
Expand All @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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"),
}
Expand Down
6 changes: 3 additions & 3 deletions application/service/job/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/labstack/gommon/random"
"github.com/pkg/errors"
"os"
"path"
"path/filepath"
"testing"
"time"
)

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)
}()
Expand All @@ -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)
}()
Expand Down
4 changes: 2 additions & 2 deletions domain/model/job/target/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions domain/model/job/target/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
)

// Local is target with Local directory
Expand All @@ -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)
}
Expand All @@ -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 {
Expand Down
40 changes: 20 additions & 20 deletions domain/model/runner/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions domain/model/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
"io"
"os"
"path"
"path/filepath"
"testing"
"time"
)
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/archive/tar/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 0800f70

Please sign in to comment.