Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit a05b8c4

Browse files
authored
Use github.com/goyek/x (#74)
1 parent edd1b12 commit a05b8c4

File tree

11 files changed

+35
-52
lines changed

11 files changed

+35
-52
lines changed

Diff for: .github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/[email protected]
1616
with:
1717
go-version: '1.19'
18-
- run: ./goyek.sh all diff
18+
- run: ./goyek.sh -v all diff
1919
- name: Upload HTML coverage
2020
uses: actions/[email protected]
2121
with:

Diff for: build/diff.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ import (
55
"strings"
66

77
"github.com/goyek/goyek/v2"
8+
"github.com/goyek/x/cmd"
89
)
910

1011
var _ = goyek.Define(goyek.Task{
1112
Name: "diff",
1213
Usage: "git diff",
1314
Action: func(tf *goyek.TF) {
14-
Exec(tf, dirRoot, "git diff --exit-code")
15+
cmd.Exec(tf, "git diff --exit-code")
1516

16-
tf.Log("Cmd: git status --porcelain")
17-
cmd := tf.Cmd("git", "status", "--porcelain")
1817
sb := &strings.Builder{}
19-
cmd.Stdout = io.MultiWriter(tf.Output(), sb)
20-
if err := cmd.Run(); err != nil {
21-
tf.Error(err)
22-
}
18+
out := io.MultiWriter(tf.Output(), sb)
19+
cmd.Exec(tf, "git status --porcelain", cmd.Stdout(out))
2320
if sb.Len() > 0 {
2421
tf.Error("git status --porcelain returned output")
2522
}

Diff for: build/exec.go

-25
This file was deleted.

Diff for: build/go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/client9/misspell v0.3.4
77
github.com/golangci/golangci-lint v1.50.1
88
github.com/goyek/goyek/v2 v2.0.0-rc.8
9-
github.com/mattn/go-shellwords v1.0.12
9+
github.com/goyek/x v0.1.0
1010
)
1111

1212
require (
@@ -98,6 +98,7 @@ require (
9898
github.com/mattn/go-colorable v0.1.13 // indirect
9999
github.com/mattn/go-isatty v0.0.16 // indirect
100100
github.com/mattn/go-runewidth v0.0.9 // indirect
101+
github.com/mattn/go-shellwords v1.0.12 // indirect
101102
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
102103
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
103104
github.com/mgechev/revive v1.2.4 // indirect

Diff for: build/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod
273273
github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY=
274274
github.com/goyek/goyek/v2 v2.0.0-rc.8 h1:C+NKVE1Gg61tJdGmU4yhyPvZNbyCd6Y6EcEZrwEYojU=
275275
github.com/goyek/goyek/v2 v2.0.0-rc.8/go.mod h1:qtHlK7t/dYs1Dw7mLXjEVmgE3nccNa7mQW/RmasOoYg=
276+
github.com/goyek/x v0.1.0 h1:/9HDwBqc7KG+4goVfbBZtZh0BYt+7ZEsJV42163TUsg=
277+
github.com/goyek/x v0.1.0/go.mod h1:5FhgNhbEC/3RAye/VLB4TO98Zr9rKA0ZWD0Z/kh+J8k=
276278
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
277279
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
278280
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=

Diff for: build/golint.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package main
22

3-
import "github.com/goyek/goyek/v2"
3+
import (
4+
"github.com/goyek/goyek/v2"
5+
"github.com/goyek/x/cmd"
6+
)
47

58
var golint = goyek.Define(goyek.Task{
69
Name: "golint",
710
Usage: "golangci-lint run --fix",
811
Action: func(tf *goyek.TF) {
9-
if !Exec(tf, dirBuild, "go install github.com/golangci/golangci-lint/cmd/golangci-lint") {
12+
if !cmd.Exec(tf, "go install github.com/golangci/golangci-lint/cmd/golangci-lint", cmd.Dir(dirBuild)) {
1013
return
1114
}
12-
Exec(tf, dirRoot, "golangci-lint run --fix")
13-
Exec(tf, dirBuild, "golangci-lint run --fix")
15+
cmd.Exec(tf, "golangci-lint run --fix", cmd.Dir(dirRoot))
16+
cmd.Exec(tf, "golangci-lint run --fix", cmd.Dir(dirBuild))
1417
},
1518
})

Diff for: build/main.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
package main
33

44
import (
5-
"os"
6-
75
"github.com/goyek/goyek/v2"
8-
"github.com/goyek/goyek/v2/middleware"
6+
"github.com/goyek/x/boot"
97
)
108

119
// Directories used in repository.
@@ -15,7 +13,6 @@ const (
1513
)
1614

1715
func main() {
18-
goyek.Use(middleware.ReportStatus)
1916
goyek.SetDefault(all)
20-
goyek.Main(os.Args[1:])
17+
boot.Main()
2118
}

Diff for: build/mdlint.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
"github.com/goyek/goyek/v2"
9+
"github.com/goyek/x/cmd"
910
)
1011

1112
var mdlint = goyek.Define(goyek.Task{
@@ -24,6 +25,6 @@ var mdlint = goyek.Define(goyek.Task{
2425
tf.Skip("no .md files")
2526
}
2627
dockerImage := "ghcr.io/igorshubovych/markdownlint-cli:v0.32.2"
27-
Exec(tf, dirRoot, "docker run --rm -v '"+curDir+":/workdir' "+dockerImage+" "+strings.Join(mdFiles, " "))
28+
cmd.Exec(tf, "docker run --rm -v '"+curDir+":/workdir' "+dockerImage+" "+strings.Join(mdFiles, " "))
2829
},
2930
})

Diff for: build/mod.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package main
22

3-
import "github.com/goyek/goyek/v2"
3+
import (
4+
"github.com/goyek/goyek/v2"
5+
"github.com/goyek/x/cmd"
6+
)
47

58
var mod = goyek.Define(goyek.Task{
69
Name: "mod",
710
Usage: "go mod tidy",
811
Action: func(tf *goyek.TF) {
9-
Exec(tf, dirRoot, "go mod tidy")
10-
Exec(tf, dirBuild, "go mod tidy")
12+
cmd.Exec(tf, "go mod tidy", cmd.Dir(dirRoot))
13+
cmd.Exec(tf, "go mod tidy", cmd.Dir(dirBuild))
1114
},
1215
})

Diff for: build/spell.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import (
44
"strings"
55

66
"github.com/goyek/goyek/v2"
7+
"github.com/goyek/x/cmd"
78
)
89

910
var spell = goyek.Define(goyek.Task{
1011
Name: "spell",
1112
Usage: "misspell",
1213
Action: func(tf *goyek.TF) {
13-
if !Exec(tf, dirBuild, "go install github.com/client9/misspell/cmd/misspell") {
14+
if !cmd.Exec(tf, "go install github.com/client9/misspell/cmd/misspell", cmd.Dir(dirBuild)) {
1415
return
1516
}
1617
mdFiles := find(tf, ".md")
1718
if len(mdFiles) == 0 {
1819
tf.Skip("no .md files")
1920
}
20-
Exec(tf, dirRoot, "misspell -error -locale=US -w "+strings.Join(mdFiles, " "))
21+
cmd.Exec(tf, "misspell -error -locale=US -w "+strings.Join(mdFiles, " "))
2122
},
2223
})

Diff for: build/test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package main
22

3-
import "github.com/goyek/goyek/v2"
3+
import (
4+
"github.com/goyek/goyek/v2"
5+
"github.com/goyek/x/cmd"
6+
)
47

58
var test = goyek.Define(goyek.Task{
69
Name: "test",
710
Usage: "go test",
811
Action: func(tf *goyek.TF) {
9-
if !Exec(tf, dirRoot, "go test -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... ./...") {
12+
if !cmd.Exec(tf, "go test -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... ./...") {
1013
return
1114
}
12-
Exec(tf, dirRoot, "go tool cover -html=coverage.out -o coverage.html")
15+
cmd.Exec(tf, "go tool cover -html=coverage.out -o coverage.html")
1316
},
1417
})

0 commit comments

Comments
 (0)