mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-07 01:14:22 +02:00
Revert #1136 and use actionslib instead. revert chore: bump the module path to `/v3`, take the version from the VCS stamp (#1136) gitea can not consume the runner's api by version while it's version mismatches the module version: ``` go: gitea.com/gitea/runner@v3.0.1: invalid version: module contains a go.mod file, so module path must match major version ("gitea.com/gitea/runner/v3") ``` Fix that by bumping the module version now. The existing `v3.0.0` and `v3.0.1` tags stay unusable, so a new tag is needed after this lands. Also drop the version `-X` linker flags, which would otherwise have to repeat the new path in both `Makefile` and `.goreleaser.yaml`, where a stale path makes injection silently no-op. Go has recorded the module version in the build info since 1.24, so `Version()` reads it from there, keeping the variable as an override for builds without a VCS stamp. That part started as https://gitea.com/gitea/runner/pulls/1137 but belongs here: the stamp resolves against the tags that are legal for the module path, so without the `/v3` bump it would report `v1.0.9-0.<ts>-<sha>`. Since `release-nightly.yml` triggers on every push to `main`, splitting them would publish a nightly with a `v1` version. --------- Co-authored-by: bircni <bircni@icloud.com> Reviewed-on: https://gitea.com/gitea/runner/pulls/1136 Reviewed-by: techknowlogick <9+techknowlogick@noreply.gitea.com> Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/runner/pulls/1148 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package run
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"gitea.com/gitea/runner/act/model"
|
|
|
|
runnerv1 "gitea.dev/actions-proto-go/runner/v1"
|
|
"go.yaml.in/yaml/v4"
|
|
)
|
|
|
|
func generateWorkflow(task *runnerv1.Task) (*model.Workflow, string, error) {
|
|
workflow, err := model.ReadWorkflow(bytes.NewReader(task.WorkflowPayload))
|
|
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
|
|
}
|