1
0
mirror of https://github.com/go-task/task.git synced 2025-07-17 01:43:07 +02:00

Merge pull request #102 from go-task/develop

v2.0.1
This commit is contained in:
Andrey Nering
2018-03-11 15:37:18 -03:00
committed by GitHub
8 changed files with 83 additions and 24 deletions

View File

@ -22,12 +22,35 @@ archive:
release:
draft: true
fpm:
snapshot:
name_template: "{{.Tag}}"
nfpm:
vendor: Task
homepage: https://github.com/go-task/task
maintainer: Andrey Nering <andrey.nering@gmail.com>
description: Simple task runner written in Go
license: MIT
conflicts:
- taskwarrior
formats:
- deb
- rpm
brew:
name: go-task
github:
owner: go-task
name: homebrew-tap
commit_author:
name: Andrey Nering
email: andrey.nering@gmail.com
folder: Formula
homepage: https://github.com/go-task/task
description: Task runner / simpler Make alternative written in Go
conflicts:
- taskwarrior
install: |
bin.install "task"
test: |
system "#{bin}/task", "--help"

View File

@ -1,10 +1,25 @@
language: go
go:
- '1.8'
- '1.9'
- '1.10'
addons:
apt:
packages:
- rpm
script:
- go install github.com/go-task/task/cmd/task
- task dl-deps
- task lint
- task test
deploy:
- provider: script
skip_cleanup: true
script: curl -sL http://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_OS_NAME = linux

26
RELEASING_TASK.md Normal file
View File

@ -0,0 +1,26 @@
# Releasing Task
The release process of Task is done is done with the help of
[GoReleaser][goreleaser]. You can test the release process locally by calling
the `test-release` task of the Taskfile.
The Travis CI should release automatically when a new
Git tag is pushed to master, either for the artifact uploading (raw executables
and DEB and RPM packages) and publishing of a new version in the
[Homebrew tap][homebrewtap].
# Snapcraft
The exception is the publishing of a new version of the
[snap package][snappackage]. This current require two steps after publishing
the binaries:
* Updating the current version on [snapcraft.yaml][snapcraftyaml];
* Moving either the `i386` and `amd64` new artifacts to the stable channel on
the [Snapscraft dashboard][snapcraftdashboard]
[goreleaser]: https://goreleaser.com/#continuous_integration
[homebrewtap]: https://github.com/go-task/homebrew-tap
[snappackage]: https://github.com/go-task/snap
[snapcraftyaml]: https://github.com/go-task/snap/blob/master/snap/snapcraft.yaml#L2
[snapcraftdashboard]: https://dashboard.snapcraft.io/

View File

@ -39,16 +39,10 @@ tasks:
cmds:
- go test {{.GO_PACKAGES}}
# https://github.com/goreleaser/goreleaser
release:
desc: Release Task
cmds:
- goreleaser
test-release:
desc: Tests release process without publishing
cmds:
- goreleaser --snapshot
- goreleaser --snapshot --rm-dist
todo:
desc: Prints TODO comments present in the code

View File

@ -98,7 +98,7 @@ func main() {
Stdout: os.Stdout,
Stderr: os.Stderr,
}
if err := e.ReadTaskfile(); err != nil {
if err := e.Setup(); err != nil {
log.Fatal(err)
}

11
task.go
View File

@ -52,10 +52,6 @@ type Executor struct {
// Run runs Task
func (e *Executor) Run(calls ...taskfile.Call) error {
if err := e.setup(); err != nil {
return err
}
// check if given tasks exist
for _, c := range calls {
if _, ok := e.Taskfile.Tasks[c.Task]; !ok {
@ -77,7 +73,12 @@ func (e *Executor) Run(calls ...taskfile.Call) error {
return nil
}
func (e *Executor) setup() error {
// Setup setups Executor's internal state
func (e *Executor) Setup() error {
if err := e.readTaskfile(); err != nil {
return err
}
v, err := semver.NewVersion(e.Taskfile.Version)
if err != nil {
return fmt.Errorf(`task: could not parse taskfile version "%s": %v`, e.Taskfile.Version, err)

View File

@ -38,7 +38,7 @@ func (fct fileContentTest) Run(t *testing.T) {
Stdout: ioutil.Discard,
Stderr: ioutil.Discard,
}
assert.NoError(t, e.ReadTaskfile(), "e.ReadTaskfile()")
assert.NoError(t, e.Setup(), "e.Setup()")
assert.NoError(t, e.Run(taskfile.Call{Task: fct.Target}), "e.Run(target)")
for name, expectContent := range fct.Files {
@ -176,7 +176,7 @@ func TestVarsInvalidTmpl(t *testing.T) {
Stdout: ioutil.Discard,
Stderr: ioutil.Discard,
}
assert.NoError(t, e.ReadTaskfile(), "e.ReadTaskfile()")
assert.NoError(t, e.Setup(), "e.Setup()")
assert.EqualError(t, e.Run(taskfile.Call{Task: target}), expectError, "e.Run(target)")
}
@ -228,7 +228,7 @@ func TestDeps(t *testing.T) {
Stdout: ioutil.Discard,
Stderr: ioutil.Discard,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "default"}))
for _, f := range files {
@ -256,7 +256,7 @@ func TestStatus(t *testing.T) {
Stderr: &buff,
Silent: true,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "gen-foo"}))
if _, err := os.Stat(file); err != nil {
@ -295,7 +295,7 @@ func TestGenerates(t *testing.T) {
Stdout: buff,
Stderr: buff,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
for _, theTask := range []string{relTask, absTask} {
var destFile = filepath.Join(dir, theTask)
@ -347,7 +347,7 @@ func TestStatusChecksum(t *testing.T) {
Stdout: &buff,
Stderr: &buff,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "build"}))
for _, f := range files {
@ -386,7 +386,7 @@ func TestCyclicDep(t *testing.T) {
Stdout: ioutil.Discard,
Stderr: ioutil.Discard,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
assert.IsType(t, &task.MaximumTaskCallExceededError{}, e.Run(taskfile.Call{Task: "task-1"}))
}
@ -406,7 +406,7 @@ func TestTaskVersion(t *testing.T) {
Stdout: ioutil.Discard,
Stderr: ioutil.Discard,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Setup())
assert.Equal(t, test.Version, e.Taskfile.Version)
assert.Equal(t, 2, len(e.Taskfile.Tasks))
})

View File

@ -12,8 +12,8 @@ import (
"gopkg.in/yaml.v2"
)
// ReadTaskfile parses Taskfile from the disk
func (e *Executor) ReadTaskfile() error {
// readTaskfile parses Taskfile from the disk
func (e *Executor) readTaskfile() error {
path := filepath.Join(e.Dir, TaskFilePath)
var err error