mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-18 22:36:43 +09:00
refactor(actions): small cleanups across models, services and routers (#39722)
Collection of small, behaviour-preserving cleanups in the Actions code. - Fix log and error prefixes that named non-existent or wrong functions, and wrap errors with `%w` so `errors.Is` keeps working. - Remove unused code. - Rely on `ctx.ServerError` / `ctx.APIErrorAuto`, which already map `util.ErrNotExist` and friends, instead of equivalent hand-written switches. - Load runs referenced by commit statuses with one query instead of one per run (used on every PR view); the result order is now stable. - Encode an event's payload once instead of up to three times. - Share the duplicated runner-token "get or create" logic and the "notify and emit" call pair. - Simplify `ToActionArtifact` / `ToActionRunner` signatures. --------- Signed-off-by: bircni <bircni@icloud.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
26 files changed
+113
-223
No files matched your search
@@ -95,7 +95,6 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
||||
}
|
||||
results[id] = &JobResult{
|
||||
Needs: job.Needs(),
|
||||
Result: pc.jobResults[id],
|
||||
Outputs: nil, // resolved at expansion time, not at plan time
|
||||
}
|
||||
}
|
||||
@@ -129,7 +128,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
||||
// Keep accepting empty exclude mappings for workflow compatibility, although GitHub rejects them.
|
||||
matrixes, err := (&model.Job{Strategy: job.Strategy.actStrategy()}).MatrixCombinations()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getMatrixes: %w", err)
|
||||
return nil, fmt.Errorf("Parse: %w", err)
|
||||
}
|
||||
if combos, err = buildMatrixCombos(id, job, matrixes, pc.gitContext, results, pc.vars, pc.inputs); err != nil {
|
||||
return nil, err
|
||||
@@ -138,7 +137,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
||||
for _, combo := range combos {
|
||||
swf := workflow.CloneHeader()
|
||||
if err := swf.SetJob(id, combo); err != nil {
|
||||
return nil, fmt.Errorf("SetJob: %w", err)
|
||||
return nil, fmt.Errorf("Parse: %w", err)
|
||||
}
|
||||
ret = append(ret, swf)
|
||||
}
|
||||
@@ -170,7 +169,7 @@ func ExpandMatrixWithNeeds(jobID string, job *Job, gitCtx *model.GithubContext,
|
||||
}
|
||||
matrixes, err := (&model.Job{Strategy: job.Strategy.actStrategy()}).MatrixCombinations()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getMatrixes: %w", err)
|
||||
return nil, fmt.Errorf("ExpandMatrixWithNeeds: %w", err)
|
||||
}
|
||||
if len(matrixes) > maxCombinations {
|
||||
return nil, fmt.Errorf("matrix expands to %d combinations, exceeding the limit of %d", len(matrixes), maxCombinations)
|
||||
@@ -293,7 +292,6 @@ func WithInputs(inputs map[string]any) ParseOption {
|
||||
}
|
||||
|
||||
type parseContext struct {
|
||||
jobResults map[string]string
|
||||
gitContext *model.GithubContext
|
||||
vars map[string]string
|
||||
inputs map[string]any
|
||||
|
||||
@@ -310,10 +310,6 @@ func (evt *Event) Acts() map[string][]string {
|
||||
return evt.acts
|
||||
}
|
||||
|
||||
func (evt *Event) Schedules() []map[string]string {
|
||||
return evt.schedules
|
||||
}
|
||||
|
||||
func ReadWorkflowRawConcurrency(content []byte) (*model.RawConcurrency, error) {
|
||||
w, err := ReadWorkflow(content)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user