Releases: goyek/goyek
3.0.1
3.0.0
This major release improves the command-line interface and changes the A.Context behavior to match testing.T.Context.
Migration Guide from v2 to v3
Module Path Change
Update your import statements and go.mod.
// Before (v2)
import "github.com/goyek/goyek/v2"
// After (v3)
import "github.com/goyek/goyek/v3"Command Line Syntax Change
The recommended command line syntax changed from [flags] [--] [tasks] to
[tasks] [flags] [--] [args].
// Before (v2)
func main() {
flag.Parse()
goyek.Main(flag.Args())
}
// After (v3)
func main() {
tasks, rest := goyek.SplitTasks(os.Args[1:])
flag.CommandLine.Parse(rest)
goyek.Main(tasks)
}Context Behavior Change
A.Context is now canceled just before cleanup functions are called. If your cleanup functions depend on the context being active, they will continue to work. If your code depended on the context remaining active after cleanup, it will need adjustment.
// Before (v2): Context stayed active during cleanup.
goyek.Define(goyek.Task{
Name: "example",
Action: func(a *goyek.A) {
a.Cleanup(func() {
// Context was still active here.
})
},
})
// After (v3): Context cancels before cleanup (matches testing.T behavior).
goyek.Define(goyek.Task{
Name: "example",
Action: func(a *goyek.A) {
a.Cleanup(func() {
// Context is canceled here, allowing proper shutdown
// of resources that listen to context.Done().
})
},
})Added
- Add
SplitTasksfunction to split command line arguments into tasks and rest. This allows tasks to come before flags and usage of positional arguments.
Changed
- BREAKING: Change module path to
github.com/goyek/goyek/v3. - BREAKING: Change
A.Contextbehavior to be canceled just before cleanup functions are called, matchingtesting.T.Contextbehavior. The context still cancels when the original context is canceled (e.g. flow interruption). This ensures cleanup functions can wait for resources that shut down oncontext.Context.Donebefore the task action completes.
2.3.0
This release adds A.WithContext inspired by http.Request.WithContext and A.Chdir following testing.T.Chdir.
Added
- Add
A.WithContextthat creates a derivedAwith a changed context. Thanks to itAcan be reused to pass cancelation and values via context to the helper functions. - Add
A.Chdirthat changes the current working directory and during action cleanup restores it to its original value.
2.2.0
This release adds flow execution middlewares.
Added
- Add
Flow.UseExecutorto support flow execution interception using middlewares. - Add
middleware.ReportFlowflow execution middleware which reports the flow execution status.
Change
- Extract the flow result reporting from
Flow.Maintomiddleware.ReportFlow. Add the middleware usingFlow.UseExecutorto achieve a backward compatible behavior.
Removed
- Drop support for Go 1.11 and 1.12.
2.1.0
This release adds parallel task execution support.
Added
- Add
Task.Parallelto allow running tasks in parallel. - Add
middleware.BufferParallelthat helps in not getting mixed output from parallel tasks execution. - Add
Input.Parallelto allow middlewares to have special handling for parallel tasks.
2.0.0
This release contains many breaking changes that are necessary to improve usability, extensibility, and customization. You can also find new supplemental features in goyek/x.
Added
- Add
DefaultFlowwhich is the default flow. - Add the top-level functions such as
Define,Main, and so on which are wrappers for the methods ofFlowcalled forDefaultFlow. Flow.Mainnow exits on receiving the second SIGINT.- Add
Flow.Printfor printing the flow usage. Flow.MainandFlow.Executeallow passing execution options.- Add
NoDepsoption to skip processing of all dependencies. - Add
Skipoption to skip processing of given tasks. - Add
Flow.Usage,Flow.SetUsagefor getting and setting the function that is called when an error occurs while parsing the flow. - Add
NOOPstatus report for tasks that were intentionally not run to differentiate from being skipped during execution. - Add
Flow.Usemethod o support task run interception using middlewares. - Add
middlewarepackage withReportStatus,SilentNonFailed,DryRun,ReportLongRunmiddlewares. TF.Error,TF.Errorf,TF.Failmay be called simultaneously from multiple goroutines.- Add
NewRunnerwhich can be useful for testing and debugging task actions and middlewares. - Add
Flow.Undefineto unregister a task. - Add
DefinedTask.SetName,DefinedTask.SetUsage,DefinedTask.Action,DefinedTask.SetAction,DefinedTask.SetAction,DefinedTask.SetDepsto enable modifying the task after the initial definition. - Add
Flow.SetLoggerfor setting a custom log decorator that is used byAlogging methods. IfLoggerimplementsError,Errorf,Fatal,Fatalf,Skip,Skipf, they will be used by theAequivalent methods. - Add
Flow.Loggerfor getting the log decorator (CodeLineLoggerby default). - Add
CodeLineLoggerwhich is the default forFlow.Logger. - Add
FmtLoggerwhich is the default when usingNewRunner. - Add
A.HelperandCodeLineLogger.Helpermethods that work like the equivalent method in thetestingpackage. - Add
A.Cleanupmethod that registers an action's cleanup function. - Add
A.Setenvmethod that sets the environment variable and reverts the previous value during cleanup. - Add
A.TempDirmethod that creates a temporary directory and removes it during cleanup.
Changed
- Rename
TFtype toAas this is theActionparameter. This is the most impactful breaking change. This follows the convention used in thetestingpackage to name the parameter type as the first letter of the "function type". - Task status reporting is disabled by default. It can be enabled by calling
Flow.Use(middleware.ReportStatus). It reportsNOOPfor a task without an action. - Usually, the task does not call
panicdirectly.panicfailure message no longer contains a prefix with file and line information. The stack trace is printed instead. The behavior is based ontestingpackage. RegisteredTask.Depsreturns[]string(dependency names) for easier introspection.- Rename
Flow.RegistertoFlow.Define. - Change
Flow.RegisteredTasktoFlow.DefinedTask. DefinedTask.DepsreturnsDepsto facilitate reusing defined task's dependencies when creating a new one or redefining an existing one.- Change the
Flow.DefaultTaskfield toFlow.SetDefaultandFlow.Defaultmethods. - Change
Flow.Outputfield toFlow.SetOutputsetter andFlow.Outputgetter. - Change
Flow.RuntoFlow.Executeto reduce possible confusion withRunner. Flow.Executereturns an error instead of returning the exit code and does not print to output. It also has different arguments.Flow.Executeaccepts[]stringinstead of...stringto make the API forward compatible.
Removed
- Remove parameters API and out-of-the-box flags (
-v,-wd). - Remove
A.Cmd. Usegithub.com/goyek/goyek/x/cmdor your helper instead.
Fixed
- Fix panic handling so that
panic(nil)andruntime.Goexit()now cause task failure.
2.0.0-rc.12
Removed
- Remove
A.Cmd. Usegithub.com/goyek/goyek/x/cmdor your own helper instead.
2.0.0-rc.11
Changed
Flow.Mainno longer changes the working directory (undocumented behavior).
2.0.0-rc.10
This release adds helpers methods for type A that are commonly used in the testing package.
Added
- Add
A.Cleanupmethod that registers an action's cleanup function. - Add
A.Setenvmethod that sets the environment variable and reverts the previous value during cleanup. - Add
A.TempDirmethod that creates a temporary directory and removes it during cleanup.
2.0.0-rc.9
This release introduces a breaking change as it renames the heavily used TF type to A. This follows the convention used in testing package to name the parameter type as the first letter of the "function type".
Added
- Add
Status.Stringmethod for printingStatus.
Changed
- Rename
TFtype toAas this is theActionparameter.