mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-07 15:50:28 +00:00
Support Simplified Concurrency (#139)
- update RawConcurrency struct to parse and serialize string-based concurrency notation - update EvaluateConcurrency to handle new RawConcurrency format Reviewed-on: https://gitea.com/gitea/act/pulls/139 Reviewed-by: Zettat123 <[email protected]> Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: ChristopherHX <[email protected]> Co-committed-by: ChristopherHX <[email protected]>
This commit is contained in:
1 parent
9924aea786
commit
39509e9ad0
2 files changed
+33
-3
No files matched your search
+15
-3
@@ -276,9 +276,21 @@ func EvaluateConcurrency(rc *model.RawConcurrency, jobID string, job *Job, gitCt
|
||||
}
|
||||
|
||||
evaluator := NewExpressionEvaluator(NewInterpeter(jobID, actJob, matrix, toGitContext(gitCtx), results, vars, inputs))
|
||||
group := evaluator.Interpolate(rc.Group)
|
||||
cancelInProgress := evaluator.Interpolate(rc.CancelInProgress)
|
||||
return group, cancelInProgress == "true", nil
|
||||
var node yaml.Node
|
||||
if err := node.Encode(rc); err != nil {
|
||||
return "", false, fmt.Errorf("failed to encode concurrency: %w", err)
|
||||
}
|
||||
if err := evaluator.EvaluateYamlNode(&node); err != nil {
|
||||
return "", false, fmt.Errorf("failed to evaluate concurrency: %w", err)
|
||||
}
|
||||
var evaluated model.RawConcurrency
|
||||
if err := node.Decode(&evaluated); err != nil {
|
||||
return "", false, fmt.Errorf("failed to unmarshal evaluated concurrency: %w", err)
|
||||
}
|
||||
if evaluated.RawExpression != "" {
|
||||
return evaluated.RawExpression, false, nil
|
||||
}
|
||||
return evaluated.Group, evaluated.CancelInProgress == "true", nil
|
||||
}
|
||||
|
||||
func toGitContext(input map[string]any) *model.GithubContext {
|
||||
|
||||
Reference in new issue
Block a user