Skip to content

Commit 8f684ff

Browse files
authored
Merge pull request #239 from go-task/ci-using-github-actions
Add CI for Linux/Windows/MacOS powered by GitHub Actions
2 parents ad569a8 + 9be3666 commit 8f684ff

File tree

8 files changed

+97
-8
lines changed

8 files changed

+97
-8
lines changed

.github/workflows/test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test
2+
on: [push]
3+
jobs:
4+
linux:
5+
name: Linux
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Set up Go 1.13
9+
uses: actions/setup-go@v1
10+
with:
11+
go-version: 1.13
12+
id: go
13+
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v1
16+
17+
- name: Build
18+
run: go build -o ./task -v ./cmd/task
19+
20+
- name: Test
21+
run: ./task test
22+
23+
windows:
24+
name: Windows
25+
runs-on: windows-latest
26+
steps:
27+
- name: Set up Go 1.13
28+
uses: actions/setup-go@v1
29+
with:
30+
go-version: 1.13
31+
id: go
32+
33+
- name: Check out code into the Go module directory
34+
uses: actions/checkout@v1
35+
36+
- name: Build
37+
run: go install -v ./cmd/task
38+
39+
- name: Test
40+
run: go test -v ./...
41+
42+
macos:
43+
name: MacOS
44+
runs-on: macOS-latest
45+
steps:
46+
- name: Set up Go 1.13
47+
uses: actions/setup-go@v1
48+
with:
49+
go-version: 1.13
50+
id: go
51+
52+
- name: Check out code into the Go module directory
53+
uses: actions/checkout@v1
54+
55+
- name: Build
56+
run: go build -o ./task -v ./cmd/task
57+
58+
- name: Test
59+
run: ./task test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ dist/
2424

2525
# exuberant ctags
2626
tags
27+
28+
/bin

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
language: go
22

33
go:
4-
- 1.11.x
54
- 1.12.x
5+
- 1.13.x
66

77
addons:
88
apt:
99
packages:
1010
- rpm
1111

1212
script:
13-
- go install github.com/go-task/task/cmd/task
13+
- go install -v ./cmd/task
1414
- task ci
1515

1616
deploy:

cmd/task/task.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/go-task/task/v2"
1212
"github.com/go-task/task/v2/internal/args"
13+
_ "github.com/go-task/task/v2/internal/homefix"
1314

1415
"github.com/spf13/pflag"
1516
)

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ require (
2121
gopkg.in/yaml.v2 v2.2.1
2222
mvdan.cc/sh v2.6.4+incompatible
2323
)
24+
25+
go 1.13

internal/homefix/homefix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Package homefix exists to address a bug where mvdan.cc/sh expects
2+
// $HOME to be available in order to be able to expand "~".
3+
//
4+
// We should delete this package once this is fixed there.
5+
package homefix
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package homefix
2+
3+
import (
4+
"os"
5+
6+
"github.com/mitchellh/go-homedir"
7+
)
8+
9+
func init() {
10+
if os.Getenv("HOME") == "" {
11+
if home, err := homedir.Dir(); err == nil {
12+
os.Setenv("HOME", home)
13+
}
14+
}
15+
}

task_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import (
77
"io/ioutil"
88
"os"
99
"path/filepath"
10+
"runtime"
1011
"strings"
1112
"testing"
1213

1314
"github.com/go-task/task/v2"
15+
_ "github.com/go-task/task/v2/internal/homefix"
1416
"github.com/go-task/task/v2/internal/taskfile"
1517

1618
"github.com/mitchellh/go-homedir"
@@ -608,13 +610,16 @@ func TestSummary(t *testing.T) {
608610
}
609611
assert.NoError(t, e.Setup())
610612
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"}))
611-
assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String())
612-
}
613613

614-
func readTestFixture(t *testing.T, dir string, file string) string {
615-
b, err := ioutil.ReadFile(dir + "/" + file)
616-
assert.NoError(t, err, "error reading text fixture")
617-
return string(b)
614+
data, err := ioutil.ReadFile(filepath.Join(dir, "task-with-summary.txt"))
615+
assert.NoError(t, err)
616+
617+
expectedOutput := string(data)
618+
if runtime.GOOS == "windows" {
619+
expectedOutput = strings.Replace(expectedOutput, "\r\n", "\n", -1)
620+
}
621+
622+
assert.Equal(t, expectedOutput, buff.String())
618623
}
619624

620625
func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {

0 commit comments

Comments
 (0)