Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out test-go task #15

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var (
formatTasks goyek.Deps
generateTasks goyek.Deps
lintTasks goyek.Deps
testTasks goyek.Deps
)

// RegisterFormatTask adds a task that should be run during the format command.
Expand All @@ -22,3 +23,8 @@ func RegisterGenerateTask(task *goyek.DefinedTask) {
func RegisterLintTask(task *goyek.DefinedTask) {
lintTasks = append(lintTasks, task)
}

// RegisterTestTask adds a task that should be run during the test command.
func RegisterTestTask(task *goyek.DefinedTask) {
testTasks = append(testTasks, task)
}
24 changes: 16 additions & 8 deletions standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ func DefineTasks(opts ...Option) {
}))
}

if !conf.excluded("test-go") {
RegisterTestTask(goyek.Define(goyek.Task{
Name: "test-go",
Usage: "Runs Go unit tests.",
Action: func(a *goyek.A) {
if err := os.MkdirAll(conf.artifactsPath, 0o755); err != nil {
a.Errorf("failed to create out directory: %v", err)
return
}
cmd.Exec(a, fmt.Sprintf("go test -coverprofile=%s -covermode=atomic -v -timeout=20m ./...", filepath.Join(conf.artifactsPath, "coverage.txt")))
},
}))
}

goyek.Define(goyek.Task{
Name: "format",
Usage: "Format code in various languages.",
Expand All @@ -127,14 +141,8 @@ func DefineTasks(opts ...Option) {

test := goyek.Define(goyek.Task{
Name: "test",
Usage: "Runs unit tests.",
Action: func(a *goyek.A) {
if err := os.MkdirAll(conf.artifactsPath, 0o755); err != nil {
a.Errorf("failed to create out directory: %v", err)
return
}
cmd.Exec(a, fmt.Sprintf("go test -coverprofile=%s -covermode=atomic -v -timeout=20m ./...", filepath.Join(conf.artifactsPath, "coverage.txt")))
},
Usage: "Runs tests.",
Deps: testTasks,
})

goyek.Define(goyek.Task{
Expand Down