mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-06 21:07:06 +02:00
fix: Adjust the jobparser functionality
This commit is contained in:
1 parent
f2f4f60057
commit
cfcb78a948
3 files changed
+18
-15
No files matched your search
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"gitea.com/gitea/runner/act/exprparser"
|
"gitea.com/gitea/runner/act/exprparser"
|
||||||
"gitea.com/gitea/runner/act/model"
|
"gitea.com/gitea/runner/act/model"
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
"go.yaml.in/yaml/v4"
|
"go.yaml.in/yaml/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -88,10 +89,13 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
|||||||
// Create an evaluator with access to needs/outputs for matrix evaluation
|
// Create an evaluator with access to needs/outputs for matrix evaluation
|
||||||
matrixEvaluator := NewExpressionEvaluator(NewInterpeter(id, &evaluatedJob, nil, pc.gitContext, results, pc.vars, pc.inputs))
|
matrixEvaluator := NewExpressionEvaluator(NewInterpeter(id, &evaluatedJob, nil, pc.gitContext, results, pc.vars, pc.inputs))
|
||||||
|
|
||||||
// Evaluate the matrix before expanding it
|
// Evaluate the matrix before expanding it.
|
||||||
|
// If evaluation fails (e.g. expression references unresolved job outputs),
|
||||||
|
// continue with the unevaluated matrix — the job will be created as a
|
||||||
|
// placeholder and re-evaluated by ReEvaluateMatrixForJobWithNeeds later.
|
||||||
if evaluatedJob.Strategy != nil && evaluatedJob.Strategy.RawMatrix.Kind != 0 {
|
if evaluatedJob.Strategy != nil && evaluatedJob.Strategy.RawMatrix.Kind != 0 {
|
||||||
if err := matrixEvaluator.EvaluateYamlNode(&evaluatedJob.Strategy.RawMatrix); err != nil {
|
if err := matrixEvaluator.EvaluateYamlNode(&evaluatedJob.Strategy.RawMatrix); err != nil {
|
||||||
return nil, fmt.Errorf("error evaluating matrix for job %s: %w", id, err)
|
log.Debug("matrix evaluation deferred for job %s (unresolved expression): %v", id, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,8 +245,8 @@ func ReEvaluateMatrixForJobWithNeeds(ctx context.Context, job *actions_model.Act
|
|||||||
log.Warn("Skipped nil jobDef at index %d for job %d (JobID: %s)", i, job.ID, job.JobID)
|
log.Warn("Skipped nil jobDef at index %d for job %d (JobID: %s)", i, job.ID, job.JobID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if id == job.JobID {
|
if id != job.JobID {
|
||||||
// Skip the original placeholder — we only want the expanded matrix entries
|
// Skip dependency stubs — we only want matrix-expanded entries for the target job
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
needs := jobDef.Needs()
|
needs := jobDef.Needs()
|
||||||
@@ -266,7 +266,8 @@ func ReEvaluateMatrixForJobWithNeeds(ctx context.Context, job *actions_model.Act
|
|||||||
JobID: id,
|
JobID: id,
|
||||||
Needs: needs,
|
Needs: needs,
|
||||||
RunsOn: jobDef.RunsOn(),
|
RunsOn: jobDef.RunsOn(),
|
||||||
Status: actions_model.StatusBlocked,
|
// All dependency jobs are already done at this point; start as Waiting.
|
||||||
|
Status: actions_model.StatusWaiting,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package actions
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
lru "github.com/hashicorp/golang-lru/v2"
|
lru "github.com/hashicorp/golang-lru/v2"
|
||||||
@@ -50,14 +50,12 @@ func computeCacheKey(workflowYAML []byte, taskNeeds map[string]*TaskNeed) string
|
|||||||
h.Write(workflowYAML)
|
h.Write(workflowYAML)
|
||||||
|
|
||||||
// Add outputs in deterministic order (sorted by job ID)
|
// Add outputs in deterministic order (sorted by job ID)
|
||||||
if taskNeeds != nil {
|
for jobID, need := range taskNeeds {
|
||||||
for jobID, need := range taskNeeds {
|
h.Write([]byte(jobID))
|
||||||
h.Write([]byte(jobID))
|
if need.Outputs != nil {
|
||||||
if need.Outputs != nil {
|
for k, v := range need.Outputs {
|
||||||
for k, v := range need.Outputs {
|
h.Write([]byte(k))
|
||||||
h.Write([]byte(k))
|
h.Write([]byte(v))
|
||||||
h.Write([]byte(v))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +86,7 @@ func (c *WorkflowParseCache) Set(key string, value []byte) {
|
|||||||
// Stats returns cache statistics for monitoring
|
// Stats returns cache statistics for monitoring
|
||||||
func (c *WorkflowParseCache) Stats() (size int, err error) {
|
func (c *WorkflowParseCache) Stats() (size int, err error) {
|
||||||
if c == nil || c.cache == nil {
|
if c == nil || c.cache == nil {
|
||||||
return 0, fmt.Errorf("cache not initialized")
|
return 0, errors.New("cache not initialized")
|
||||||
}
|
}
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
|
|||||||
Reference in new issue
Block a user