mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-02 09:50:17 +00:00
feat: Support graceful job step cancellation (#69)
* for gh-act-runner * act-cli support as well * respecting always() and cancelled() of steps * setup-job, bug report, gh cli and watch wait call is cancelled early
This commit is contained in:
@@ -391,6 +391,8 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
||||
}
|
||||
|
||||
if ok, _ := cmd.Flags().GetBool("bug-report"); ok {
|
||||
ctx, cancel := common.EarlyCancelContext(ctx)
|
||||
defer cancel()
|
||||
return bugReport(ctx, cmd.Version)
|
||||
}
|
||||
if ok, _ := cmd.Flags().GetBool("man-page"); ok {
|
||||
@@ -430,6 +432,8 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
||||
_ = readEnvsEx(input.Secretfile(), secrets, true)
|
||||
|
||||
if _, hasGitHubToken := secrets["GITHUB_TOKEN"]; !hasGitHubToken {
|
||||
ctx, cancel := common.EarlyCancelContext(ctx)
|
||||
defer cancel()
|
||||
secrets["GITHUB_TOKEN"], _ = gh.GetToken(ctx, "")
|
||||
}
|
||||
|
||||
@@ -782,10 +786,13 @@ func watchAndRun(ctx context.Context, fn common.Executor) error {
|
||||
return err
|
||||
}
|
||||
|
||||
earlyCancelCtx, cancel := common.EarlyCancelContext(ctx)
|
||||
defer cancel()
|
||||
|
||||
for folderWatcher.IsRunning() {
|
||||
log.Debugf("Watching %s for changes", dir)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-earlyCancelCtx.Done():
|
||||
return nil
|
||||
case changes := <-folderWatcher.ChangeDetails():
|
||||
log.Debugf("%s", changes.String())
|
||||
|
||||
Reference in New Issue
Block a user