feat: Support graceful job step cancellation (#2714)
* feat: Support graceful job step cancellation * for gh-act-runner * act-cli support as well * respecting always() and cancelled() of steps * change main * cancel startContainer / gh cli / bugreport early * add to watch as well --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -51,6 +51,7 @@ type RunContext struct {
|
||||
Masks []string
|
||||
cleanUpJobContainer common.Executor
|
||||
caller *caller // job calling this RunContext (reusable workflows)
|
||||
Cancelled bool
|
||||
nodeToolFullPath string
|
||||
}
|
||||
|
||||
@@ -435,6 +436,8 @@ func (rc *RunContext) execJobContainer(cmd []string, env map[string]string, user
|
||||
|
||||
func (rc *RunContext) InitializeNodeTool() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
ctx, cancel := common.EarlyCancelContext(ctx)
|
||||
defer cancel()
|
||||
rc.GetNodeToolFullPath(ctx)
|
||||
return nil
|
||||
}
|
||||
@@ -651,6 +654,8 @@ func (rc *RunContext) interpolateOutputs() common.Executor {
|
||||
|
||||
func (rc *RunContext) startContainer() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
ctx, cancel := common.EarlyCancelContext(ctx)
|
||||
defer cancel()
|
||||
if rc.IsHostEnv(ctx) {
|
||||
return rc.startHostEnvironment()(ctx)
|
||||
}
|
||||
@@ -845,10 +850,14 @@ func trimToLen(s string, l int) string {
|
||||
|
||||
func (rc *RunContext) getJobContext() *model.JobContext {
|
||||
jobStatus := "success"
|
||||
for _, stepStatus := range rc.StepResults {
|
||||
if stepStatus.Conclusion == model.StepStatusFailure {
|
||||
jobStatus = "failure"
|
||||
break
|
||||
if rc.Cancelled {
|
||||
jobStatus = "cancelled"
|
||||
} else {
|
||||
for _, stepStatus := range rc.StepResults {
|
||||
if stepStatus.Conclusion == model.StepStatusFailure {
|
||||
jobStatus = "failure"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return &model.JobContext{
|
||||
|
||||
Reference in New Issue
Block a user