Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fail to find local subworkflow of remote workflow #1876

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
matrixes := parseMatrix(input.matrix)
log.Debugf("Evaluated matrix inclusions: %v", matrixes)

planner, err := model.NewWorkflowPlanner(input.WorkflowsPath(), input.noWorkflowRecurse)
planner, err := model.NewWorkflowPlanner("", input.WorkflowsPath(), input.noWorkflowRecurse)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/artifacts/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) {
runner, err := runner.New(runnerConfig)
assert.Nil(t, err, tjfi.workflowPath)

planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true)
planner, err := model.NewWorkflowPlanner(workdir, tjfi.workflowPath, true)
assert.Nil(t, err, fullWorkflowPath)

plan, err := planner.PlanEvent(tjfi.eventName)
Expand Down
10 changes: 8 additions & 2 deletions pkg/model/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@
// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
//
//nolint:gocyclo
func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, error) {
func NewWorkflowPlanner(directory string, workflow string, noWorkflowRecurse bool) (WorkflowPlanner, error) {
path := ""
if directory == "" || workflow == "" {
path = directory + workflow

Check warning on line 64 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L64

Added line #L64 was not covered by tests
} else {
path = filepath.Join(directory, workflow)
}
path, err := filepath.Abs(path)
if err != nil {
return nil, err
Expand Down Expand Up @@ -142,7 +148,7 @@
_ = f.Close()
return nil, fmt.Errorf("error occurring when resetting io pointer in '%s': %w", wf.workflowDirEntry.Name(), err)
}

workflow.RepoPath = directory
workflow.File = wf.workflowDirEntry.Name()
if workflow.Name == "" {
workflow.Name = wf.workflowDirEntry.Name()
Expand All @@ -162,30 +168,30 @@
return wp, nil
}

func NewSingleWorkflowPlanner(name string, f io.Reader) (WorkflowPlanner, error) {
wp := new(workflowPlanner)

log.Debugf("Reading workflow %s", name)
workflow, err := ReadWorkflow(f)
if err != nil {
if err == io.EOF {
return nil, fmt.Errorf("unable to read workflow '%s': file is empty: %w", name, err)
}
return nil, fmt.Errorf("workflow is not valid. '%s': %w", name, err)

Check warning on line 180 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L171-L180

Added lines #L171 - L180 were not covered by tests
}
workflow.File = name
if workflow.Name == "" {
workflow.Name = name
}

Check warning on line 185 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L182-L185

Added lines #L182 - L185 were not covered by tests

err = validateJobName(workflow)
if err != nil {
return nil, err
}

Check warning on line 190 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L187-L190

Added lines #L187 - L190 were not covered by tests

wp.workflows = append(wp.workflows, workflow)

return wp, nil

Check warning on line 194 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L192-L194

Added lines #L192 - L194 were not covered by tests
}

func validateJobName(workflow *Workflow) error {
Expand All @@ -203,34 +209,34 @@
}

// PlanEvent builds a new list of runs to execute in parallel for an event name
func (wp *workflowPlanner) PlanEvent(eventName string) (*Plan, error) {

Check warning on line 212 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L212

Added line #L212 was not covered by tests
plan := new(Plan)
if len(wp.workflows) == 0 {
log.Debug("no workflows found by planner")
return plan, nil

Check warning on line 216 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L215-L216

Added lines #L215 - L216 were not covered by tests
}
var lastErr error

Check warning on line 218 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L218

Added line #L218 was not covered by tests

for _, w := range wp.workflows {
events := w.On()
if len(events) == 0 {
log.Debugf("no events found for workflow: %s", w.File)
continue

Check warning on line 224 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L221-L224

Added lines #L221 - L224 were not covered by tests
}

for _, e := range events {

Check warning on line 227 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L227

Added line #L227 was not covered by tests
if e == eventName {
stages, err := createStages(w, w.GetJobIDs()...)
if err != nil {
log.Warn(err)
lastErr = err
} else {
plan.mergeStages(stages)
}

Check warning on line 235 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L229-L235

Added lines #L229 - L235 were not covered by tests
}
}
}
return plan, lastErr

Check warning on line 239 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L239

Added line #L239 was not covered by tests
}

// PlanJob builds a new run to execute in parallel for a job name
Expand All @@ -244,8 +250,8 @@
for _, w := range wp.workflows {
stages, err := createStages(w, jobName)
if err != nil {
log.Warn(err)
lastErr = err

Check warning on line 254 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L253-L254

Added lines #L253 - L254 were not covered by tests
} else {
plan.mergeStages(stages)
}
Expand All @@ -254,25 +260,25 @@
}

// PlanAll builds a new run to execute in parallel all
func (wp *workflowPlanner) PlanAll() (*Plan, error) {

Check warning on line 263 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L263

Added line #L263 was not covered by tests
plan := new(Plan)
if len(wp.workflows) == 0 {
log.Debug("no workflows found by planner")
return plan, nil

Check warning on line 267 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L266-L267

Added lines #L266 - L267 were not covered by tests
}
var lastErr error

Check warning on line 269 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L269

Added line #L269 was not covered by tests

for _, w := range wp.workflows {
stages, err := createStages(w, w.GetJobIDs()...)
if err != nil {
log.Warn(err)
lastErr = err
} else {
plan.mergeStages(stages)
}

Check warning on line 278 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L272-L278

Added lines #L272 - L278 were not covered by tests
}

return plan, lastErr

Check warning on line 281 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L281

Added line #L281 was not covered by tests
}

// GetEvents gets all the events in the workflows file
Expand Down Expand Up @@ -377,7 +383,7 @@
}
}
if len(stage.Runs) == 0 {
return nil, fmt.Errorf("unable to build dependency graph for %s (%s)", w.Name, w.File)

Check warning on line 386 in pkg/model/planner.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/planner.go#L386

Added line #L386 was not covered by tests
}
stages = append(stages, stage)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/model/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestPlanner(t *testing.T) {
workdir, err := filepath.Abs("testdata")
assert.NoError(t, err, workdir)
for _, table := range tables {
fullWorkflowPath := filepath.Join(workdir, table.workflowPath)
_, err = NewWorkflowPlanner(fullWorkflowPath, table.noWorkflowRecurse)
_, err = NewWorkflowPlanner(workdir, table.workflowPath, table.noWorkflowRecurse)
if table.errorMessage == "" {
assert.NoError(t, err, "WorkflowPlanner should exit without any error")
} else {
Expand Down
1 change: 1 addition & 0 deletions pkg/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Workflow is the structure of the files in .github/workflows
type Workflow struct {
RepoPath string
File string
Name string `yaml:"name"`
RawOn yaml.Node `yaml:"on"`
Expand Down Expand Up @@ -58,8 +59,8 @@
func (w *Workflow) OnEvent(event string) interface{} {
if w.RawOn.Kind == yaml.MappingNode {
var val map[string]interface{}
if !decodeNode(w.RawOn, &val) {
return nil

Check warning on line 63 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L62-L63

Added lines #L62 - L63 were not covered by tests
}
return val[event]
}
Expand All @@ -84,14 +85,14 @@
}

var val map[string]yaml.Node
if !decodeNode(w.RawOn, &val) {
return nil

Check warning on line 89 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L88-L89

Added lines #L88 - L89 were not covered by tests
}

var config WorkflowDispatch
node := val["workflow_dispatch"]
if !decodeNode(node, &config) {
return nil

Check warning on line 95 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L94-L95

Added lines #L94 - L95 were not covered by tests
}

return &config
Expand Down Expand Up @@ -120,19 +121,19 @@

func (w *Workflow) WorkflowCallConfig() *WorkflowCall {
if w.RawOn.Kind != yaml.MappingNode {
// The callers expect for "on: workflow_call" and "on: [ workflow_call ]" a non nil return value
return &WorkflowCall{}

Check warning on line 125 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L124-L125

Added lines #L124 - L125 were not covered by tests
}

var val map[string]yaml.Node
if !decodeNode(w.RawOn, &val) {
return &WorkflowCall{}

Check warning on line 130 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L129-L130

Added lines #L129 - L130 were not covered by tests
}

var config WorkflowCall
node := val["workflow_call"]
if !decodeNode(node, &config) {
return &WorkflowCall{}

Check warning on line 136 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L135-L136

Added lines #L135 - L136 were not covered by tests
}

return &config
Expand Down Expand Up @@ -215,8 +216,8 @@
}

var val string
if !decodeNode(j.RawSecrets, &val) {
return false

Check warning on line 220 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L219-L220

Added lines #L219 - L220 were not covered by tests
}

return val == "inherit"
Expand All @@ -228,8 +229,8 @@
}

var val map[string]string
if !decodeNode(j.RawSecrets, &val) {
return nil

Check warning on line 233 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L232-L233

Added lines #L232 - L233 were not covered by tests
}

return val
Expand All @@ -242,12 +243,12 @@
case yaml.ScalarNode:
val = new(ContainerSpec)
if !decodeNode(j.RawContainer, &val.Image) {
return nil

Check warning on line 246 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L246

Added line #L246 was not covered by tests
}
case yaml.MappingNode:
val = new(ContainerSpec)
if !decodeNode(j.RawContainer, val) {
return nil

Check warning on line 251 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L251

Added line #L251 was not covered by tests
}
}
return val
Expand All @@ -258,14 +259,14 @@
switch j.RawNeeds.Kind {
case yaml.ScalarNode:
var val string
if !decodeNode(j.RawNeeds, &val) {
return nil

Check warning on line 263 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L262-L263

Added lines #L262 - L263 were not covered by tests
}
return []string{val}
case yaml.SequenceNode:
var val []string
if !decodeNode(j.RawNeeds, &val) {
return nil

Check warning on line 269 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L268-L269

Added lines #L268 - L269 were not covered by tests
}
return val
}
Expand All @@ -282,8 +283,8 @@
}

if !decodeNode(j.RawRunsOn, &val) {
return nil
}

Check warning on line 287 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L286-L287

Added lines #L286 - L287 were not covered by tests

labels := nodeAsStringSlice(val.Labels)

Expand All @@ -292,8 +293,8 @@
}

return labels
default:
return nodeAsStringSlice(j.RawRunsOn)

Check warning on line 297 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L296-L297

Added lines #L296 - L297 were not covered by tests
}
}

Expand All @@ -302,13 +303,13 @@
case yaml.ScalarNode:
var val string
if !decodeNode(node, &val) {
return nil

Check warning on line 306 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L306

Added line #L306 was not covered by tests
}
return []string{val}
case yaml.SequenceNode:
var val []string
if !decodeNode(node, &val) {
return nil

Check warning on line 312 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L312

Added line #L312 was not covered by tests
}
return val
}
Expand All @@ -318,8 +319,8 @@
func environment(yml yaml.Node) map[string]string {
env := make(map[string]string)
if yml.Kind == yaml.MappingNode {
if !decodeNode(yml, &env) {
return nil

Check warning on line 323 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L322-L323

Added lines #L322 - L323 were not covered by tests
}
}
return env
Expand All @@ -335,7 +336,7 @@
if j.Strategy.RawMatrix.Kind == yaml.MappingNode {
var val map[string][]interface{}
if !decodeNode(j.Strategy.RawMatrix, &val) {
return nil

Check warning on line 339 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L339

Added line #L339 was not covered by tests
}
return val
}
Expand Down Expand Up @@ -397,7 +398,7 @@
excludes = append(excludes, e)
} else {
// We fail completely here because that's what GitHub does for non-existing matrix keys, fail on exclude, silent skip on include
return nil, fmt.Errorf("the workflow is not valid. Matrix exclude key %q does not match any key within the matrix", k)

Check warning on line 401 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L401

Added line #L401 was not covered by tests
}
}
}
Expand Down Expand Up @@ -441,7 +442,7 @@
}
} else {
matrixes = append(matrixes, make(map[string]interface{}))
log.Debugf("Empty Strategy, matrixes=%v", matrixes)

Check warning on line 445 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L445

Added line #L445 was not covered by tests
}
return matrixes, nil
}
Expand Down Expand Up @@ -592,7 +593,7 @@
case "sh":
shellCommand = "sh -e {0}"
case "cmd":
shellCommand = "cmd /D /E:ON /V:OFF /S /C \"CALL \"{0}\"\""

Check warning on line 596 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L596

Added line #L596 was not covered by tests
case "powershell":
shellCommand = "powershell -command . '{0}'"
default:
Expand Down Expand Up @@ -702,16 +703,16 @@
return ids
}

var OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) {
log.Fatalf("Failed to decode node %v into %T: %v", node, out, err)

Check warning on line 707 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L706-L707

Added lines #L706 - L707 were not covered by tests
}

func decodeNode(node yaml.Node, out interface{}) bool {
if err := node.Decode(out); err != nil {
if OnDecodeNodeError != nil {
OnDecodeNodeError(node, out, err)
}
return false

Check warning on line 715 in pkg/model/workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/workflow.go#L712-L715

Added lines #L712 - L715 were not covered by tests
}
return true
}
2 changes: 1 addition & 1 deletion pkg/model/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ jobs:
}

func TestReadWorkflow_Strategy(t *testing.T) {
w, err := NewWorkflowPlanner("testdata/strategy/push.yml", true)
w, err := NewWorkflowPlanner("testdata/strategy", "push.yml", true)
assert.NoError(t, err)

p, err := w.PlanJob("strategy-only-max-parallel")
Expand Down
12 changes: 9 additions & 3 deletions pkg/runner/reusable_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"fmt"
"io/fs"
"os"
"path"
"regexp"
"strings"
"sync"

"github.com/nektos/act/pkg/common"
Expand All @@ -17,7 +17,13 @@
)

func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor {
return newReusableWorkflowExecutor(rc, rc.Config.Workdir, rc.Run.Job().Uses)
job := rc.Run.Job()
if strings.Index(job.Uses, "./") == 0 {
// relative path
return newReusableWorkflowExecutor(rc, rc.Run.Workflow.RepoPath, job.Uses)
} else {

Check warning on line 24 in pkg/runner/reusable_workflow.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
return newReusableWorkflowExecutor(rc, rc.Config.Workdir, job.Uses)
}

Check warning on line 26 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L25-L26

Added lines #L25 - L26 were not covered by tests
}

func newRemoteReusableWorkflowExecutor(rc *RunContext) common.Executor {
Expand All @@ -25,8 +31,8 @@

remoteReusableWorkflow := newRemoteReusableWorkflow(uses)
if remoteReusableWorkflow == nil {
return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.github/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses))
}

Check warning on line 35 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L34-L35

Added lines #L34 - L35 were not covered by tests

// uses with safe filename makes the target directory look something like this {owner}-{repo}-.github-workflows-{filename}@{ref}
// instead we will just use {owner}-{repo}@{ref} as our target directory. This should also improve performance when we are using
Expand All @@ -35,8 +41,8 @@
workflowDir := fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(filename))

if rc.Config.ActionCache != nil {
return newActionCacheReusableWorkflowExecutor(rc, filename, remoteReusableWorkflow)
}

Check warning on line 45 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L44-L45

Added lines #L44 - L45 were not covered by tests

return common.NewPipelineExecutor(
newMutexExecutor(cloneIfRequired(rc, *remoteReusableWorkflow, workflowDir)),
Expand All @@ -44,38 +50,38 @@
)
}

func newActionCacheReusableWorkflowExecutor(rc *RunContext, filename string, remoteReusableWorkflow *remoteReusableWorkflow) common.Executor {
return func(ctx context.Context) error {
ghctx := rc.getGithubContext(ctx)
remoteReusableWorkflow.URL = ghctx.ServerURL
sha, err := rc.Config.ActionCache.Fetch(ctx, filename, remoteReusableWorkflow.CloneURL(), remoteReusableWorkflow.Ref, ghctx.Token)
if err != nil {
return err
}
archive, err := rc.Config.ActionCache.GetTarArchive(ctx, filename, sha, fmt.Sprintf(".github/workflows/%s", remoteReusableWorkflow.Filename))
if err != nil {
return err
}
defer archive.Close()
treader := tar.NewReader(archive)
if _, err = treader.Next(); err != nil {
return err
}
planner, err := model.NewSingleWorkflowPlanner(remoteReusableWorkflow.Filename, treader)
if err != nil {
return err
}
plan, err := planner.PlanEvent("workflow_call")
if err != nil {
return err
}

Check warning on line 77 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L53-L77

Added lines #L53 - L77 were not covered by tests

runner, err := NewReusableWorkflowRunner(rc)
if err != nil {
return err
}

Check warning on line 82 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L79-L82

Added lines #L79 - L82 were not covered by tests

return runner.NewPlanExecutor(plan)(ctx)

Check warning on line 84 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L84

Added line #L84 was not covered by tests
}
}

Expand Down Expand Up @@ -114,20 +120,20 @@

func newReusableWorkflowExecutor(rc *RunContext, directory string, workflow string) common.Executor {
return func(ctx context.Context) error {
planner, err := model.NewWorkflowPlanner(path.Join(directory, workflow), true)
planner, err := model.NewWorkflowPlanner(directory, workflow, true)
if err != nil {
return err
}

Check warning on line 126 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L125-L126

Added lines #L125 - L126 were not covered by tests

plan, err := planner.PlanEvent("workflow_call")
if err != nil {
return err
}

Check warning on line 131 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L130-L131

Added lines #L130 - L131 were not covered by tests

runner, err := NewReusableWorkflowRunner(rc)
if err != nil {
return err
}

Check warning on line 136 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L135-L136

Added lines #L135 - L136 were not covered by tests

return runner.NewPlanExecutor(plan)(ctx)
}
Expand Down Expand Up @@ -163,8 +169,8 @@
r := regexp.MustCompile(`^([^/]+)/([^/]+)/.github/workflows/([^@]+)@(.*)$`)
matches := r.FindStringSubmatch(uses)
if len(matches) != 5 {
return nil
}

Check warning on line 173 in pkg/runner/reusable_workflow.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/reusable_workflow.go#L172-L173

Added lines #L172 - L173 were not covered by tests
return &remoteReusableWorkflow{
Org: matches[1],
Repo: matches[2],
Expand Down
15 changes: 8 additions & 7 deletions pkg/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {
}

func TestNoWorkflowsFoundByPlanner(t *testing.T) {
planner, err := model.NewWorkflowPlanner("res", true)
planner, err := model.NewWorkflowPlanner("res", "", true)
assert.NoError(t, err)

out := log.StandardLogger().Out
Expand All @@ -70,7 +70,7 @@ func TestNoWorkflowsFoundByPlanner(t *testing.T) {
}

func TestGraphMissingEvent(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-event.yml", true)
planner, err := model.NewWorkflowPlanner("testdata/issue-1595", "no-event.yml", true)
assert.NoError(t, err)

out := log.StandardLogger().Out
Expand All @@ -88,7 +88,7 @@ func TestGraphMissingEvent(t *testing.T) {
}

func TestGraphMissingFirst(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-first.yml", true)
planner, err := model.NewWorkflowPlanner("testdata/issue-1595", "no-first.yml", true)
assert.NoError(t, err)

plan, err := planner.PlanEvent("push")
Expand All @@ -98,7 +98,7 @@ func TestGraphMissingFirst(t *testing.T) {
}

func TestGraphWithMissing(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/missing.yml", true)
planner, err := model.NewWorkflowPlanner("testdata/issue-1595", "missing.yml", true)
assert.NoError(t, err)

out := log.StandardLogger().Out
Expand All @@ -117,7 +117,7 @@ func TestGraphWithMissing(t *testing.T) {
func TestGraphWithSomeMissing(t *testing.T) {
log.SetLevel(log.DebugLevel)

planner, err := model.NewWorkflowPlanner("testdata/issue-1595/", true)
planner, err := model.NewWorkflowPlanner("testdata/issue-1595", "", true)
assert.NoError(t, err)

out := log.StandardLogger().Out
Expand All @@ -135,7 +135,7 @@ func TestGraphWithSomeMissing(t *testing.T) {
}

func TestGraphEvent(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/basic", true)
planner, err := model.NewWorkflowPlanner("testdata/basic", "", true)
assert.NoError(t, err)

plan, err := planner.PlanEvent("push")
Expand Down Expand Up @@ -192,7 +192,7 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config
runner, err := New(runnerConfig)
assert.Nil(t, err, j.workflowPath)

planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true)
planner, err := model.NewWorkflowPlanner(workdir, j.workflowPath, true)
assert.Nil(t, err, fullWorkflowPath)

plan, err := planner.PlanEvent(j.eventName)
Expand Down Expand Up @@ -242,6 +242,7 @@ func TestRunEvent(t *testing.T) {
{workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}},
{workdir, "uses-docker-url", "push", "", platforms, secrets},
{workdir, "act-composite-env-test", "push", "", platforms, secrets},
{workdir, "issue-1875-uses-workflow-with-sub-workflow", "dispatch", "", platforms, secrets},

// Eval
{workdir, "evalmatrix", "push", "", platforms, secrets},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Call Reusable Workflow
on:
push:

jobs:
call-reusable-workflow-with-sub:
uses: wildsheepz/TestReusableWorkflow/.github/workflows/main.yaml@ubuntu_platform