Compare commits

...

5 Commits

Author SHA1 Message Date
Andrey Nering
328e3725e5 Merge pull request #102 from go-task/develop
v2.0.1
2018-03-11 15:37:18 -03:00
Andrey Nering
2183e1e9f5 Improve release process and testing automatic release on new tag using Travis 2018-03-11 15:31:27 -03:00
Andrey Nering
120d0be84c Fixes panic on task --list
Fixes #99
2018-03-11 14:39:40 -03:00
Andrey Nering
5649f75a8d Merge pull request #97 from seblw/patch-1
Editorial changes in TASKFILE_VERSIONS.md
2018-03-08 08:07:31 -03:00
Sebastian Lawniczak
a209f7d6be Editorial changes in TASKFILE_VERSIONS.md 2018-03-08 10:18:27 +01:00
9 changed files with 85 additions and 26 deletions

View File

@@ -22,12 +22,35 @@ archive:
release: release:
draft: true draft: true
fpm: snapshot:
name_template: "{{.Tag}}"
nfpm:
vendor: Task vendor: Task
homepage: https://github.com/go-task/task homepage: https://github.com/go-task/task
maintainer: Andrey Nering <andrey.nering@gmail.com> maintainer: Andrey Nering <andrey.nering@gmail.com>
description: Simple task runner written in Go description: Simple task runner written in Go
license: MIT license: MIT
conflicts:
- taskwarrior
formats: formats:
- deb - deb
- rpm - 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 language: go
go: go:
- '1.8' - '1.8'
- '1.9' - '1.9'
- '1.10' - '1.10'
addons:
apt:
packages:
- rpm
script: script:
- go install github.com/go-task/task/cmd/task - go install github.com/go-task/task/cmd/task
- task dl-deps - task dl-deps
- task lint - task lint
- task test - 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

@@ -29,7 +29,7 @@ The variable priority order was also different:
1. Call variables 1. Call variables
2. Environment 2. Environment
3. Task variables 3. Task variables
4. `Taskvars.yml` veriables 4. `Taskvars.yml` variables
## Version 2.0 ## Version 2.0
@@ -46,7 +46,7 @@ tasks:
- echo "Hello, World!" - echo "Hello, World!"
``` ```
Version 2 not allows you to write global variables directly in the Taskfile, Version 2 allows you to write global variables directly in the Taskfile,
if you don't want to create a `Taskvars.yml`: if you don't want to create a `Taskvars.yml`:
```yml ```yml

View File

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

View File

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

11
task.go
View File

@@ -52,10 +52,6 @@ type Executor struct {
// Run runs Task // Run runs Task
func (e *Executor) Run(calls ...taskfile.Call) error { func (e *Executor) Run(calls ...taskfile.Call) error {
if err := e.setup(); err != nil {
return err
}
// check if given tasks exist // check if given tasks exist
for _, c := range calls { for _, c := range calls {
if _, ok := e.Taskfile.Tasks[c.Task]; !ok { if _, ok := e.Taskfile.Tasks[c.Task]; !ok {
@@ -77,7 +73,12 @@ func (e *Executor) Run(calls ...taskfile.Call) error {
return nil 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) v, err := semver.NewVersion(e.Taskfile.Version)
if err != nil { if err != nil {
return fmt.Errorf(`task: could not parse taskfile version "%s": %v`, e.Taskfile.Version, err) 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, Stdout: ioutil.Discard,
Stderr: 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)") assert.NoError(t, e.Run(taskfile.Call{Task: fct.Target}), "e.Run(target)")
for name, expectContent := range fct.Files { for name, expectContent := range fct.Files {
@@ -176,7 +176,7 @@ func TestVarsInvalidTmpl(t *testing.T) {
Stdout: ioutil.Discard, Stdout: ioutil.Discard,
Stderr: 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)") 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, Stdout: ioutil.Discard,
Stderr: ioutil.Discard, Stderr: ioutil.Discard,
} }
assert.NoError(t, e.ReadTaskfile()) assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "default"})) assert.NoError(t, e.Run(taskfile.Call{Task: "default"}))
for _, f := range files { for _, f := range files {
@@ -256,7 +256,7 @@ func TestStatus(t *testing.T) {
Stderr: &buff, Stderr: &buff,
Silent: true, Silent: true,
} }
assert.NoError(t, e.ReadTaskfile()) assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "gen-foo"})) assert.NoError(t, e.Run(taskfile.Call{Task: "gen-foo"}))
if _, err := os.Stat(file); err != nil { if _, err := os.Stat(file); err != nil {
@@ -295,7 +295,7 @@ func TestGenerates(t *testing.T) {
Stdout: buff, Stdout: buff,
Stderr: buff, Stderr: buff,
} }
assert.NoError(t, e.ReadTaskfile()) assert.NoError(t, e.Setup())
for _, theTask := range []string{relTask, absTask} { for _, theTask := range []string{relTask, absTask} {
var destFile = filepath.Join(dir, theTask) var destFile = filepath.Join(dir, theTask)
@@ -347,7 +347,7 @@ func TestStatusChecksum(t *testing.T) {
Stdout: &buff, Stdout: &buff,
Stderr: &buff, Stderr: &buff,
} }
assert.NoError(t, e.ReadTaskfile()) assert.NoError(t, e.Setup())
assert.NoError(t, e.Run(taskfile.Call{Task: "build"})) assert.NoError(t, e.Run(taskfile.Call{Task: "build"}))
for _, f := range files { for _, f := range files {
@@ -386,7 +386,7 @@ func TestCyclicDep(t *testing.T) {
Stdout: ioutil.Discard, Stdout: ioutil.Discard,
Stderr: 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"})) assert.IsType(t, &task.MaximumTaskCallExceededError{}, e.Run(taskfile.Call{Task: "task-1"}))
} }
@@ -406,7 +406,7 @@ func TestTaskVersion(t *testing.T) {
Stdout: ioutil.Discard, Stdout: ioutil.Discard,
Stderr: 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, test.Version, e.Taskfile.Version)
assert.Equal(t, 2, len(e.Taskfile.Tasks)) assert.Equal(t, 2, len(e.Taskfile.Tasks))
}) })

View File

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