Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cdf1e5788 | ||
|
|
ab381649da | ||
|
|
38e7e9e939 | ||
|
|
2ab806053c | ||
|
|
6a090f67e5 |
@@ -172,10 +172,20 @@ type RunDefaults struct {
|
|||||||
WorkingDirectory string `yaml:"working-directory,omitempty"`
|
WorkingDirectory string `yaml:"working-directory,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WorkflowDispatchInput struct {
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
Description string `yaml:"description"`
|
||||||
|
Required bool `yaml:"required"`
|
||||||
|
Default string `yaml:"default"`
|
||||||
|
Type string `yaml:"type"`
|
||||||
|
Options []string `yaml:"options"`
|
||||||
|
}
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Name string
|
Name string
|
||||||
acts map[string][]string
|
acts map[string][]string
|
||||||
schedules []map[string]string
|
schedules []map[string]string
|
||||||
|
inputs []WorkflowDispatchInput
|
||||||
}
|
}
|
||||||
|
|
||||||
func (evt *Event) IsSchedule() bool {
|
func (evt *Event) IsSchedule() bool {
|
||||||
@@ -190,6 +200,47 @@ func (evt *Event) Schedules() []map[string]string {
|
|||||||
return evt.schedules
|
return evt.schedules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (evt *Event) Inputs() []WorkflowDispatchInput {
|
||||||
|
return evt.inputs
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseWorkflowDispatchInputs(inputs map[string]interface{}) ([]WorkflowDispatchInput, error) {
|
||||||
|
var results []WorkflowDispatchInput
|
||||||
|
for name, input := range inputs {
|
||||||
|
inputMap, ok := input.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid input: %v", input)
|
||||||
|
}
|
||||||
|
input := WorkflowDispatchInput{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
if desc, ok := inputMap["description"].(string); ok {
|
||||||
|
input.Description = desc
|
||||||
|
}
|
||||||
|
if required, ok := inputMap["required"].(bool); ok {
|
||||||
|
input.Required = required
|
||||||
|
}
|
||||||
|
if defaultVal, ok := inputMap["default"].(string); ok {
|
||||||
|
input.Default = defaultVal
|
||||||
|
}
|
||||||
|
if inputType, ok := inputMap["type"].(string); ok {
|
||||||
|
input.Type = inputType
|
||||||
|
}
|
||||||
|
if options, ok := inputMap["options"].([]string); ok {
|
||||||
|
input.Options = options
|
||||||
|
} else if options, ok := inputMap["options"].([]interface{}); ok {
|
||||||
|
for _, option := range options {
|
||||||
|
if opt, ok := option.(string); ok {
|
||||||
|
input.Options = append(input.Options, opt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
results = append(results, input)
|
||||||
|
}
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
|
func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
|
||||||
switch rawOn.Kind {
|
switch rawOn.Kind {
|
||||||
case yaml.ScalarNode:
|
case yaml.ScalarNode:
|
||||||
@@ -218,79 +269,119 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
|
|||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
case yaml.MappingNode:
|
case yaml.MappingNode:
|
||||||
events, triggers, err := parseMappingNode[interface{}](rawOn)
|
events, triggers, err := parseMappingNode[yaml.Node](rawOn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
res := make([]*Event, 0, len(events))
|
res := make([]*Event, 0, len(events))
|
||||||
for i, k := range events {
|
for i, k := range events {
|
||||||
v := triggers[i]
|
v := triggers[i]
|
||||||
if v == nil {
|
switch v.Kind {
|
||||||
|
case yaml.ScalarNode:
|
||||||
res = append(res, &Event{
|
res = append(res, &Event{
|
||||||
Name: k,
|
Name: k,
|
||||||
acts: map[string][]string{},
|
|
||||||
})
|
})
|
||||||
continue
|
case yaml.SequenceNode:
|
||||||
}
|
var t []interface{}
|
||||||
switch t := v.(type) {
|
err := v.Decode(&t)
|
||||||
case string:
|
if err != nil {
|
||||||
res = append(res, &Event{
|
return nil, err
|
||||||
Name: k,
|
|
||||||
acts: map[string][]string{},
|
|
||||||
})
|
|
||||||
case []string:
|
|
||||||
res = append(res, &Event{
|
|
||||||
Name: k,
|
|
||||||
acts: map[string][]string{},
|
|
||||||
})
|
|
||||||
case map[string]interface{}:
|
|
||||||
acts := make(map[string][]string, len(t))
|
|
||||||
for act, branches := range t {
|
|
||||||
switch b := branches.(type) {
|
|
||||||
case string:
|
|
||||||
acts[act] = []string{b}
|
|
||||||
case []string:
|
|
||||||
acts[act] = b
|
|
||||||
case []interface{}:
|
|
||||||
acts[act] = make([]string, len(b))
|
|
||||||
for i, v := range b {
|
|
||||||
var ok bool
|
|
||||||
if acts[act][i], ok = v.(string); !ok {
|
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", branches)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", branches)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res = append(res, &Event{
|
|
||||||
Name: k,
|
|
||||||
acts: acts,
|
|
||||||
})
|
|
||||||
case []interface{}:
|
|
||||||
if k != "schedule" {
|
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", v)
|
|
||||||
}
|
}
|
||||||
schedules := make([]map[string]string, len(t))
|
schedules := make([]map[string]string, len(t))
|
||||||
|
if k == "schedule" {
|
||||||
for i, tt := range t {
|
for i, tt := range t {
|
||||||
vv, ok := tt.(map[string]interface{})
|
vv, ok := tt.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", v)
|
return nil, fmt.Errorf("unknown on type(schedule): %#v", v)
|
||||||
}
|
}
|
||||||
schedules[i] = make(map[string]string, len(vv))
|
schedules[i] = make(map[string]string, len(vv))
|
||||||
for k, vvv := range vv {
|
for k, vvv := range vv {
|
||||||
var ok bool
|
var ok bool
|
||||||
if schedules[i][k], ok = vvv.(string); !ok {
|
if schedules[i][k], ok = vvv.(string); !ok {
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", v)
|
return nil, fmt.Errorf("unknown on type(schedule): %#v", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(schedules) == 0 {
|
||||||
|
schedules = nil
|
||||||
|
}
|
||||||
res = append(res, &Event{
|
res = append(res, &Event{
|
||||||
Name: k,
|
Name: k,
|
||||||
schedules: schedules,
|
schedules: schedules,
|
||||||
})
|
})
|
||||||
|
case yaml.MappingNode:
|
||||||
|
acts := make(map[string][]string, len(v.Content)/2)
|
||||||
|
var inputs []WorkflowDispatchInput
|
||||||
|
expectedKey := true
|
||||||
|
var act string
|
||||||
|
for _, content := range v.Content {
|
||||||
|
if expectedKey {
|
||||||
|
if content.Kind != yaml.ScalarNode {
|
||||||
|
return nil, fmt.Errorf("key type not string: %#v", content)
|
||||||
|
}
|
||||||
|
act = ""
|
||||||
|
err := content.Decode(&act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch content.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
var t []string
|
||||||
|
err := content.Decode(&t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
acts[act] = t
|
||||||
|
case yaml.MappingNode:
|
||||||
|
if k != "workflow_dispatch" || act != "inputs" {
|
||||||
|
return nil, fmt.Errorf("map should only for workflow_dispatch but %s: %#v", act, content)
|
||||||
|
}
|
||||||
|
|
||||||
|
var key string
|
||||||
|
for i, vv := range content.Content {
|
||||||
|
if i%2 == 0 {
|
||||||
|
if vv.Kind != yaml.ScalarNode {
|
||||||
|
return nil, fmt.Errorf("key type not string: %#v", vv)
|
||||||
|
}
|
||||||
|
key = ""
|
||||||
|
if err := vv.Decode(&key); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if vv.Kind != yaml.MappingNode {
|
||||||
|
return nil, fmt.Errorf("key type not map(%s): %#v", key, vv)
|
||||||
|
}
|
||||||
|
|
||||||
|
input := WorkflowDispatchInput{}
|
||||||
|
if err := vv.Decode(&input); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
input.Name = key
|
||||||
|
inputs = append(inputs, input)
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown on type: %#v", v)
|
return nil, fmt.Errorf("unknown on type: %#v", content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expectedKey = !expectedKey
|
||||||
|
}
|
||||||
|
if len(inputs) == 0 {
|
||||||
|
inputs = nil
|
||||||
|
}
|
||||||
|
if len(acts) == 0 {
|
||||||
|
acts = nil
|
||||||
|
}
|
||||||
|
res = append(res, &Event{
|
||||||
|
Name: k,
|
||||||
|
acts: acts,
|
||||||
|
inputs: inputs,
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown on type: %v", v.Kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
|||||||
@@ -186,6 +186,60 @@ func TestParseRawOn(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: `on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
logLevel:
|
||||||
|
description: 'Log level'
|
||||||
|
required: true
|
||||||
|
default: 'warning'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- info
|
||||||
|
- warning
|
||||||
|
- debug
|
||||||
|
tags:
|
||||||
|
description: 'Test scenario tags'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
environment:
|
||||||
|
description: 'Environment to run tests against'
|
||||||
|
type: environment
|
||||||
|
required: true
|
||||||
|
push:
|
||||||
|
`,
|
||||||
|
result: []*Event{
|
||||||
|
{
|
||||||
|
Name: "workflow_dispatch",
|
||||||
|
inputs: []WorkflowDispatchInput{
|
||||||
|
{
|
||||||
|
Name: "logLevel",
|
||||||
|
Description: "Log level",
|
||||||
|
Required: true,
|
||||||
|
Default: "warning",
|
||||||
|
Type: "choice",
|
||||||
|
Options: []string{"info", "warning", "debug"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "tags",
|
||||||
|
Description: "Test scenario tags",
|
||||||
|
Required: false,
|
||||||
|
Type: "boolean",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "environment",
|
||||||
|
Description: "Environment to run tests against",
|
||||||
|
Type: "environment",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "push",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, kase := range kases {
|
for _, kase := range kases {
|
||||||
t.Run(kase.input, func(t *testing.T) {
|
t.Run(kase.input, func(t *testing.T) {
|
||||||
@@ -230,8 +284,7 @@ func TestParseMappingNode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
input: "on:\n push:\n branches:\n - master",
|
input: "on:\n push:\n branches:\n - master",
|
||||||
scalars: []string{"push"},
|
scalars: []string{"push"},
|
||||||
datas: []interface {
|
datas: []interface{}{
|
||||||
}{
|
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"branches": []interface{}{"master"},
|
"branches": []interface{}{"master"},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -8,9 +9,10 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/common"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"github.com/nektos/act/pkg/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Workflow is the structure of the files in .github/workflows
|
// Workflow is the structure of the files in .github/workflows
|
||||||
@@ -716,6 +718,12 @@ func (s *Step) Type() StepType {
|
|||||||
return StepTypeUsesActionRemote
|
return StepTypeUsesActionRemote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UsesHash returns a hash of the uses string.
|
||||||
|
// For Gitea.
|
||||||
|
func (s *Step) UsesHash() string {
|
||||||
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(s.Uses)))
|
||||||
|
}
|
||||||
|
|
||||||
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
||||||
func ReadWorkflow(in io.Reader) (*Workflow, error) {
|
func ReadWorkflow(in io.Reader) (*Workflow, error) {
|
||||||
w := new(Workflow)
|
w := new(Workflow)
|
||||||
|
|||||||
@@ -603,3 +603,37 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
Type: "choice",
|
Type: "choice",
|
||||||
}, workflowDispatch.Inputs["logLevel"])
|
}, workflowDispatch.Inputs["logLevel"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStep_UsesHash(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Uses string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "regular",
|
||||||
|
fields: fields{
|
||||||
|
Uses: "https://gitea.com/testa/testb@v3",
|
||||||
|
},
|
||||||
|
want: "ae437878e9f285bd7518c58664f9fabbb12d05feddd7169c01702a2a14322aa8",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
fields: fields{
|
||||||
|
Uses: "",
|
||||||
|
},
|
||||||
|
want: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
s := &Step{
|
||||||
|
Uses: tt.fields.Uses,
|
||||||
|
}
|
||||||
|
assert.Equalf(t, tt.want, s.UsesHash(), "UsesHash()")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ func runPreStep(step actionStep) common.Executor {
|
|||||||
var actionPath string
|
var actionPath string
|
||||||
if _, ok := step.(*stepActionRemote); ok {
|
if _, ok := step.(*stepActionRemote); ok {
|
||||||
actionPath = newRemoteAction(stepModel.Uses).Path
|
actionPath = newRemoteAction(stepModel.Uses).Path
|
||||||
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(stepModel.Uses))
|
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), stepModel.UsesHash())
|
||||||
} else {
|
} else {
|
||||||
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
||||||
actionPath = ""
|
actionPath = ""
|
||||||
@@ -579,7 +579,7 @@ func runPreStep(step actionStep) common.Executor {
|
|||||||
var actionPath string
|
var actionPath string
|
||||||
if _, ok := step.(*stepActionRemote); ok {
|
if _, ok := step.(*stepActionRemote); ok {
|
||||||
actionPath = newRemoteAction(stepModel.Uses).Path
|
actionPath = newRemoteAction(stepModel.Uses).Path
|
||||||
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(stepModel.Uses))
|
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), stepModel.UsesHash())
|
||||||
} else {
|
} else {
|
||||||
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
||||||
actionPath = ""
|
actionPath = ""
|
||||||
@@ -665,7 +665,7 @@ func runPostStep(step actionStep) common.Executor {
|
|||||||
var actionPath string
|
var actionPath string
|
||||||
if _, ok := step.(*stepActionRemote); ok {
|
if _, ok := step.(*stepActionRemote); ok {
|
||||||
actionPath = newRemoteAction(stepModel.Uses).Path
|
actionPath = newRemoteAction(stepModel.Uses).Path
|
||||||
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(stepModel.Uses))
|
actionDir = fmt.Sprintf("%s/%s", rc.ActionCacheDir(), stepModel.UsesHash())
|
||||||
} else {
|
} else {
|
||||||
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
actionDir = filepath.Join(rc.Config.Workdir, stepModel.Uses)
|
||||||
actionPath = ""
|
actionPath = ""
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
|||||||
|
|
||||||
preExec := step.pre()
|
preExec := step.pre()
|
||||||
preSteps = append(preSteps, useStepLogger(rc, stepModel, stepStagePre, func(ctx context.Context) error {
|
preSteps = append(preSteps, useStepLogger(rc, stepModel, stepStagePre, func(ctx context.Context) error {
|
||||||
|
if rc.caller != nil { // For Gitea
|
||||||
|
rc.caller.reusedWorkflowJobResults[rc.JobName] = "pending"
|
||||||
|
}
|
||||||
|
|
||||||
logger := common.Logger(ctx)
|
logger := common.Logger(ctx)
|
||||||
preErr := preExec(ctx)
|
preErr := preExec(ctx)
|
||||||
if preErr != nil {
|
if preErr != nil {
|
||||||
@@ -185,7 +189,35 @@ func setJobResult(ctx context.Context, info jobInfo, rc *RunContext, success boo
|
|||||||
info.result(jobResult)
|
info.result(jobResult)
|
||||||
if rc.caller != nil {
|
if rc.caller != nil {
|
||||||
// set reusable workflow job result
|
// set reusable workflow job result
|
||||||
rc.caller.runContext.result(jobResult)
|
|
||||||
|
rc.caller.updateResultLock.Lock()
|
||||||
|
rc.caller.reusedWorkflowJobResults[rc.JobName] = jobResult
|
||||||
|
|
||||||
|
allJobDone := true
|
||||||
|
hasFailure := false
|
||||||
|
for _, result := range rc.caller.reusedWorkflowJobResults {
|
||||||
|
if result == "pending" {
|
||||||
|
allJobDone = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if result == "failure" {
|
||||||
|
hasFailure = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if allJobDone {
|
||||||
|
reusedWorkflowJobResult := "success"
|
||||||
|
reusedWorkflowJobResultMessage := "succeeded"
|
||||||
|
if hasFailure {
|
||||||
|
reusedWorkflowJobResult = "failure"
|
||||||
|
reusedWorkflowJobResultMessage = "failed"
|
||||||
|
}
|
||||||
|
rc.caller.runContext.result(reusedWorkflowJobResult)
|
||||||
|
logger.WithField("jobResult", reusedWorkflowJobResult).Infof("\U0001F3C1 Job %s", reusedWorkflowJobResultMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
rc.caller.updateResultLock.Unlock()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
jobResultMessage := "succeeded"
|
jobResultMessage := "succeeded"
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ func NewReusableWorkflowRunner(rc *RunContext) (Runner, error) {
|
|||||||
eventJSON: rc.EventJSON,
|
eventJSON: rc.EventJSON,
|
||||||
caller: &caller{
|
caller: &caller{
|
||||||
runContext: rc,
|
runContext: rc,
|
||||||
|
|
||||||
|
reusedWorkflowJobResults: map[string]string{}, // For Gitea
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
docker_container "github.com/docker/docker/api/types/container"
|
docker_container "github.com/docker/docker/api/types/container"
|
||||||
@@ -86,6 +87,9 @@ func (c Config) GetToken() string {
|
|||||||
|
|
||||||
type caller struct {
|
type caller struct {
|
||||||
runContext *RunContext
|
runContext *RunContext
|
||||||
|
|
||||||
|
updateResultLock sync.Mutex // For Gitea
|
||||||
|
reusedWorkflowJobResults map[string]string // For Gitea
|
||||||
}
|
}
|
||||||
|
|
||||||
type runnerImpl struct {
|
type runnerImpl struct {
|
||||||
|
|||||||
@@ -122,6 +122,15 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
|
|||||||
summaryFileCommand := path.Join("workflow", "SUMMARY.md")
|
summaryFileCommand := path.Join("workflow", "SUMMARY.md")
|
||||||
(*step.getEnv())["GITHUB_STEP_SUMMARY"] = path.Join(actPath, summaryFileCommand)
|
(*step.getEnv())["GITHUB_STEP_SUMMARY"] = path.Join(actPath, summaryFileCommand)
|
||||||
|
|
||||||
|
{
|
||||||
|
// For Gitea
|
||||||
|
(*step.getEnv())["GITEA_OUTPUT"] = (*step.getEnv())["GITHUB_OUTPUT"]
|
||||||
|
(*step.getEnv())["GITEA_STATE"] = (*step.getEnv())["GITHUB_STATE"]
|
||||||
|
(*step.getEnv())["GITEA_PATH"] = (*step.getEnv())["GITHUB_PATH"]
|
||||||
|
(*step.getEnv())["GITEA_ENV"] = (*step.getEnv())["GITHUB_ENV"]
|
||||||
|
(*step.getEnv())["GITEA_STEP_SUMMARY"] = (*step.getEnv())["GITHUB_STEP_SUMMARY"]
|
||||||
|
}
|
||||||
|
|
||||||
_ = rc.JobContainer.Copy(actPath, &container.FileEntry{
|
_ = rc.JobContainer.Copy(actPath, &container.FileEntry{
|
||||||
Name: outputFileCommand,
|
Name: outputFileCommand,
|
||||||
Mode: 0o666,
|
Mode: 0o666,
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), safeFilename(sar.Step.Uses))
|
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), sar.Step.UsesHash())
|
||||||
gitClone := stepActionRemoteNewCloneExecutor(git.NewGitCloneExecutorInput{
|
gitClone := stepActionRemoteNewCloneExecutor(git.NewGitCloneExecutorInput{
|
||||||
URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance),
|
URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance),
|
||||||
Ref: sar.remoteAction.Ref,
|
Ref: sar.remoteAction.Ref,
|
||||||
@@ -177,7 +177,7 @@ func (sar *stepActionRemote) main() common.Executor {
|
|||||||
return sar.RunContext.JobContainer.CopyDir(copyToPath, sar.RunContext.Config.Workdir+string(filepath.Separator)+".", sar.RunContext.Config.UseGitIgnore)(ctx)
|
return sar.RunContext.JobContainer.CopyDir(copyToPath, sar.RunContext.Config.Workdir+string(filepath.Separator)+".", sar.RunContext.Config.UseGitIgnore)(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), safeFilename(sar.Step.Uses))
|
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), sar.Step.UsesHash())
|
||||||
|
|
||||||
return sar.runAction(sar, actionDir, sar.remoteAction)(ctx)
|
return sar.runAction(sar, actionDir, sar.remoteAction)(ctx)
|
||||||
}),
|
}),
|
||||||
@@ -236,7 +236,7 @@ func (sar *stepActionRemote) getActionModel() *model.Action {
|
|||||||
|
|
||||||
func (sar *stepActionRemote) getCompositeRunContext(ctx context.Context) *RunContext {
|
func (sar *stepActionRemote) getCompositeRunContext(ctx context.Context) *RunContext {
|
||||||
if sar.compositeRunContext == nil {
|
if sar.compositeRunContext == nil {
|
||||||
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), safeFilename(sar.Step.Uses))
|
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), sar.Step.UsesHash())
|
||||||
actionLocation := path.Join(actionDir, sar.remoteAction.Path)
|
actionLocation := path.Join(actionDir, sar.remoteAction.Path)
|
||||||
_, containerActionDir := getContainerActionPaths(sar.getStepModel(), actionLocation, sar.RunContext)
|
_, containerActionDir := getContainerActionPaths(sar.getStepModel(), actionLocation, sar.RunContext)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user