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
Add A.Run for running sub-tasks #116
Comments
@arnovanliere would this feature be helpful for you? Personally, I would use it in repositories containing multiple Go modules. However, multi-module repos are not popular, so I decided to not work on this feature so far. |
As a matter of fact, the repo I work on most (and in which we use goyek as well) is multi-module repo with microservices. We have a task which runs tests, |
Great. I have more confidence that it is a feature worth implementing. Do you want to implement it or are you OK waiting a few weeks or months until I find time to work on it? Do you want to review the code if I would implement it? |
I'm happy to wait a while for this feature to be available. I would certainly want to review your code. |
@arnovanliere See #179 |
I think this is not needed and would be overengineering. Here is an easy example how it could overcome: func SomeTask(tf *goyek.TF) {
input := []string { ".", "build", "tools" }
for _, in := range input {
func() {
tf.Logf("For %q:", in)
if err := exec1(in); err != nil {
tf.Error(err)
return
}
if err := exec2(in); err != nil {
tf.Error(err)
}
}()
}
} |
Reopening as together with |
import (
"github.com/goyek/goyek/v2"
"github.com/goyek/x/cmd"
)
var installMigrate = goyek.Define(goyek.Task{
Name: "install-migrate",
Usage: "install migrate",
Action: func(a *goyek.A) {
cmd.Exec(a, "migrate-installer")
},
})
func init() {
var migrateTasks goyek.Deps
dbs := []string{"staging-db-1", "staging-db-2"}
for _, db := range dbs {
migrateTasks = append(migrateTasks, goyek.Define(goyek.Task{
Name: "migrate-" + db,
Deps: goyek.Deps{installMigrate},
Parallel: true,
Action: func(a *goyek.A) {
cmd.Exec(a, "migrate "+db)
},
}))
}
goyek.Define(goyek.Task{
Name: "migrate",
Usage: "migrate",
Deps: migrateTasks,
})
} The advantages are:
|
Closing right now as YAGNI. I can consider reopening it in future. |
Why
Like testing package it would be very helpful to create something like sub-tasks.
Example use case: run
go test
for each Go Module within a repository.How
Implement
A.Run()
method which works similarly to the one in thetesting
package.We can also dogfood it e.g. to run
golangci-lint
for all Go modules within this repository.We could also support running a concrete subtask e.g
./goyek Task/Sub1
(separate PR).We could also try to support running tasks and subtasks using regex/wildcards (separate PR).
go test -run regex
takes regex . If we decide to take the same approach we wrap the regex with^ $
.The text was updated successfully, but these errors were encountered: