1
0
mirror of https://github.com/go-task/task.git synced 2024-12-14 10:52:43 +02:00

Merge pull request #239 from go-task/ci-using-github-actions

Add CI for Linux/Windows/MacOS powered by GitHub Actions
This commit is contained in:
Andrey Nering 2019-09-07 14:43:00 -03:00 committed by GitHub
commit 8f684ffa6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 97 additions and 8 deletions

59
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: Test
on: [push]
jobs:
linux:
name: Linux
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: go build -o ./task -v ./cmd/task
- name: Test
run: ./task test
windows:
name: Windows
runs-on: windows-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: go install -v ./cmd/task
- name: Test
run: go test -v ./...
macos:
name: MacOS
runs-on: macOS-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: go build -o ./task -v ./cmd/task
- name: Test
run: ./task test

2
.gitignore vendored
View File

@ -24,3 +24,5 @@ dist/
# exuberant ctags
tags
/bin

View File

@ -1,8 +1,8 @@
language: go
go:
- 1.11.x
- 1.12.x
- 1.13.x
addons:
apt:
@ -10,7 +10,7 @@ addons:
- rpm
script:
- go install github.com/go-task/task/cmd/task
- go install -v ./cmd/task
- task ci
deploy:

View File

@ -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"
)

2
go.mod
View File

@ -21,3 +21,5 @@ require (
gopkg.in/yaml.v2 v2.2.1
mvdan.cc/sh v2.6.4+incompatible
)
go 1.13

View File

@ -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 "~".
//
// We should delete this package once this is fixed there.
package homefix

View File

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

View File

@ -7,10 +7,12 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"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"
@ -608,13 +610,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) {