mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
This PR contains the following updates: | Package | Change | Age | Confidence | |---|---|---|---| | [code.forgejo.org/forgejo/act](https://code.forgejo.org/forgejo/act) | `v1.30.0` -> `v1.31.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>forgejo/act (code.forgejo.org/forgejo/act)</summary> ### [`v1.31.0`](https://code.forgejo.org/forgejo/act/compare/v1.30.0...v1.31.0) [Compare Source](https://code.forgejo.org/forgejo/act/compare/v1.30.0...v1.31.0) </details> --- ### Configuration 📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4zMi4xIiwidXBkYXRlZEluVmVyIjoiNDEuMzIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Earl Warren <contact@earl-warren.org> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/714 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: Renovate Bot <bot@kriese.eu> Co-committed-by: Renovate Bot <bot@kriese.eu>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package run
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
|
|
"github.com/nektos/act/pkg/model"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
func generateWorkflow(task *runnerv1.Task) (*model.Workflow, string, error) {
|
|
workflow, err := model.ReadWorkflow(bytes.NewReader(task.WorkflowPayload), true)
|
|
if err != nil {
|
|
return nil, "", err
|
|
}
|
|
|
|
jobIDs := workflow.GetJobIDs()
|
|
if len(jobIDs) != 1 {
|
|
return nil, "", fmt.Errorf("multiple jobs found: %v", jobIDs)
|
|
}
|
|
jobID := jobIDs[0]
|
|
|
|
needJobIDs := make([]string, 0, len(task.Needs))
|
|
for id, need := range task.Needs {
|
|
needJobIDs = append(needJobIDs, id)
|
|
needJob := &model.Job{
|
|
Outputs: need.Outputs,
|
|
Result: strings.ToLower(strings.TrimPrefix(need.Result.String(), "RESULT_")),
|
|
}
|
|
workflow.Jobs[id] = needJob
|
|
}
|
|
sort.Strings(needJobIDs)
|
|
|
|
rawNeeds := yaml.Node{
|
|
Kind: yaml.SequenceNode,
|
|
Content: make([]*yaml.Node, 0, len(needJobIDs)),
|
|
}
|
|
for _, id := range needJobIDs {
|
|
rawNeeds.Content = append(rawNeeds.Content, &yaml.Node{
|
|
Kind: yaml.ScalarNode,
|
|
Value: id,
|
|
})
|
|
}
|
|
|
|
workflow.Jobs[jobID].RawNeeds = rawNeeds
|
|
|
|
return workflow, jobID, nil
|
|
}
|