From d235d5ab28b48c8f46d1fb992008789c124a2124 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:24:31 -0300 Subject: [PATCH 01/13] Add CI for Linux/Windows/MacOS powered by GitHub Actions --- .github/workflows/test.yml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e3711b3f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: Test +on: [push] +jobs: + linux: + name: Linux + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build + run: go test -v . + + windows: + name: Windows + runs-on: windows-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build + run: go test -v . + + macos: + name: MacOS + runs-on: macOS-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build + run: go test -v . From 57db6865d28cfc96082c1c02325244ed4c3c6dd2 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:28:55 -0300 Subject: [PATCH 02/13] Build binary first and test all packages --- .github/workflows/test.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3711b3f..cb30b08c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go test -v . + run: go install -v ./cmd/task + + - name: Test + run: task ci windows: name: Windows @@ -31,7 +34,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go test -v . + run: go install -v ./cmd/task + + - name: Test + run: task ci macos: name: MacOS @@ -47,4 +53,7 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go test -v . + run: go install -v ./cmd/task + + - name: Test + run: task ci From fe6978b107a7a9c599fca68d9dffa9135c291dfe Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:32:45 -0300 Subject: [PATCH 03/13] Fix CI --- .github/workflows/test.yml | 12 ++++++------ .gitignore | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb30b08c..afa18b42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go install -v ./cmd/task + run: go build -o ./bin/task -v ./cmd/task - name: Test - run: task ci + run: ./bin/task ci windows: name: Windows @@ -34,10 +34,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go install -v ./cmd/task + run: go build -o ./bin/task -v ./cmd/task - name: Test - run: task ci + run: ./bin/task ci macos: name: MacOS @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go install -v ./cmd/task + run: go build -o ./bin/task -v ./cmd/task - name: Test - run: task ci + run: ./bin/task ci diff --git a/.gitignore b/.gitignore index c5de0bc5..4a1cc9a1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ dist/ # exuberant ctags tags + +/bin From fdff7f80a34f8743cfe8856ebd772bbb5d29dd41 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:35:29 -0300 Subject: [PATCH 04/13] Skip linting for now --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afa18b42..345a3a18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: run: go build -o ./bin/task -v ./cmd/task - name: Test - run: ./bin/task ci + run: ./bin/task test windows: name: Windows @@ -37,7 +37,7 @@ jobs: run: go build -o ./bin/task -v ./cmd/task - name: Test - run: ./bin/task ci + run: ./bin/task test macos: name: MacOS @@ -56,4 +56,4 @@ jobs: run: go build -o ./bin/task -v ./cmd/task - name: Test - run: ./bin/task ci + run: ./bin/task test From 3d56ea5ce50a37dcfb83a5e411d6536e9a0c7205 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:38:36 -0300 Subject: [PATCH 05/13] Fix binary calling on Windows --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 345a3a18..33b8a26b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: run: go build -o ./bin/task -v ./cmd/task - name: Test - run: ./bin/task test + run: bin/task test macos: name: MacOS From 690d3c27a2fe55877010107690a50486a97ad9ee Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:42:06 -0300 Subject: [PATCH 06/13] Do we need to use backslash here? --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33b8a26b..638001a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: run: go build -o ./bin/task -v ./cmd/task - name: Test - run: bin/task test + run: bin\task test macos: name: MacOS From afeefe82591dc86be48435027fe83ee94f8284cb Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:45:46 -0300 Subject: [PATCH 07/13] Build on the root directory --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 638001a9..ae63e1eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go build -o ./bin/task -v ./cmd/task + run: go build -o ./task -v ./cmd/task - name: Test - run: ./bin/task test + run: ./task test windows: name: Windows @@ -34,10 +34,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go build -o ./bin/task -v ./cmd/task + run: go build -o ./task -v ./cmd/task - name: Test - run: bin\task test + run: task test macos: name: MacOS @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go build -o ./bin/task -v ./cmd/task + run: go build -o ./task -v ./cmd/task - name: Test - run: ./bin/task test + run: ./task test From a1493687253545cd3f29368e598e343aaf78e266 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Aug 2019 22:50:28 -0300 Subject: [PATCH 08/13] Calling Go directly on Windows --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae63e1eb..bb5253be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,10 +34,10 @@ jobs: uses: actions/checkout@v1 - name: Build - run: go build -o ./task -v ./cmd/task + run: go install -v ./cmd/task - name: Test - run: task test + run: go test -v ./... macos: name: MacOS From 5285ec23ae849f9c79ec1211ea8471e91cfb28dd Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 1 Sep 2019 22:26:53 -0300 Subject: [PATCH 09/13] Fix summary test on Windows --- task_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/task_test.go b/task_test.go index 1b97fbb6..d34abf67 100644 --- a/task_test.go +++ b/task_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "testing" @@ -608,13 +609,16 @@ func TestSummary(t *testing.T) { } assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"})) - assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String()) -} -func readTestFixture(t *testing.T, dir string, file string) string { - b, err := ioutil.ReadFile(dir + "/" + file) - assert.NoError(t, err, "error reading text fixture") - return string(b) + data, err := ioutil.ReadFile(filepath.Join(dir, "task-with-summary.txt")) + assert.NoError(t, err) + + expectedOutput := string(data) + if runtime.GOOS == "windows" { + expectedOutput = strings.Replace(expectedOutput, "\r\n", "\n", -1) + } + + assert.Equal(t, expectedOutput, buff.String()) } func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) { From 52028fc3bc5c9a80d3974b2f74efa491229df075 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 7 Sep 2019 14:28:36 -0300 Subject: [PATCH 10/13] Ensure the $HOME env is being set on Windows --- cmd/task/task.go | 1 + internal/homefix/homefix.go | 5 +++++ internal/homefix/homefix_windows.go | 15 +++++++++++++++ task_test.go | 1 + 4 files changed, 22 insertions(+) create mode 100644 internal/homefix/homefix.go create mode 100644 internal/homefix/homefix_windows.go diff --git a/cmd/task/task.go b/cmd/task/task.go index b71023ac..2805489b 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -10,6 +10,7 @@ import ( "github.com/go-task/task/v2" "github.com/go-task/task/v2/internal/args" + _ "github.com/go-task/task/v2/internal/homefix" "github.com/spf13/pflag" ) diff --git a/internal/homefix/homefix.go b/internal/homefix/homefix.go new file mode 100644 index 00000000..180d01a9 --- /dev/null +++ b/internal/homefix/homefix.go @@ -0,0 +1,5 @@ +// Package homefix exists to address a bug where mvdan.cc/sh expects +// $HOME to be available in order to be able to expand "~". +// +// This should delete this package once this is fixed there. +package homefix diff --git a/internal/homefix/homefix_windows.go b/internal/homefix/homefix_windows.go new file mode 100644 index 00000000..28ed67fc --- /dev/null +++ b/internal/homefix/homefix_windows.go @@ -0,0 +1,15 @@ +package homefix + +import ( + "os" + + "github.com/mitchellh/go-homedir" +) + +func init() { + if os.Getenv("HOME") == "" { + if home, err := homedir.Dir(); err == nil { + os.Setenv("HOME", home) + } + } +} diff --git a/task_test.go b/task_test.go index d34abf67..24862dd1 100644 --- a/task_test.go +++ b/task_test.go @@ -12,6 +12,7 @@ import ( "testing" "github.com/go-task/task/v2" + _ "github.com/go-task/task/v2/internal/homefix" "github.com/go-task/task/v2/internal/taskfile" "github.com/mitchellh/go-homedir" From d8005b4cf6ced4f83e316b155f3a4f9e5d2563f9 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 7 Sep 2019 14:32:02 -0300 Subject: [PATCH 11/13] Fix typo --- internal/homefix/homefix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/homefix/homefix.go b/internal/homefix/homefix.go index 180d01a9..641ae79a 100644 --- a/internal/homefix/homefix.go +++ b/internal/homefix/homefix.go @@ -1,5 +1,5 @@ // Package homefix exists to address a bug where mvdan.cc/sh expects // $HOME to be available in order to be able to expand "~". // -// This should delete this package once this is fixed there. +// We should delete this package once this is fixed there. package homefix From b7785678f420b7a106cfe163d671f92b600dec76 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 7 Sep 2019 14:35:48 -0300 Subject: [PATCH 12/13] CI: Upgrade to Go 1.13 --- .github/workflows/test.yml | 12 ++++++------ .travis.yml | 2 +- go.mod | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb5253be..a69cf219 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,10 +5,10 @@ jobs: name: Linux runs-on: ubuntu-latest steps: - - name: Set up Go 1.12 + - name: Set up Go 1.13 uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.13 id: go - name: Check out code into the Go module directory @@ -24,10 +24,10 @@ jobs: name: Windows runs-on: windows-latest steps: - - name: Set up Go 1.12 + - name: Set up Go 1.13 uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.13 id: go - name: Check out code into the Go module directory @@ -43,10 +43,10 @@ jobs: name: MacOS runs-on: macOS-latest steps: - - name: Set up Go 1.12 + - name: Set up Go 1.13 uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.13 id: go - name: Check out code into the Go module directory diff --git a/.travis.yml b/.travis.yml index dabf2188..b8785210 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: go go: - - 1.11.x - 1.12.x + - 1.13.x addons: apt: diff --git a/go.mod b/go.mod index 1b479dd7..b5bf4580 100644 --- a/go.mod +++ b/go.mod @@ -21,3 +21,5 @@ require ( gopkg.in/yaml.v2 v2.2.1 mvdan.cc/sh v2.6.4+incompatible ) + +go 1.13 From 9be3666fe740a220ac8e3ac8bf83d0e7270b83d3 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 7 Sep 2019 14:40:39 -0300 Subject: [PATCH 13/13] Trying to fix Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b8785210..8a7a63cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ addons: - rpm script: - - go install github.com/go-task/task/cmd/task + - go install -v ./cmd/task - task ci deploy: