Skip to content

Commit

Permalink
Composite action (#608)
Browse files Browse the repository at this point in the history
* Refactor maybeCopyToActionDir

* Use maybeCopyToActionDir for model.ActionRunsUsingComposite
  • Loading branch information
jsoref authored May 3, 2021
1 parent cec6348 commit 020d6a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions pkg/runner/runner_test.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ func TestRunEvent(t *testing.T) {
{"testdata", "workdir", "push", "", platforms, ""},
{"testdata", "defaults-run", "push", "", platforms, ""},
{"testdata", "uses-composite", "push", "", platforms, ""},
{"testdata", "issue-597", "push", "", platforms, ""},
{"testdata", "issue-597", "push", "", platforms, ""},
// {"testdata", "powershell", "push", "", platforms, ""}, // Powershell is not available on default act test runner (yet) but preserving here for posterity
// {"testdata", "issue-228", "push", "", platforms, ""}, // TODO [igni]: Remove this once everything passes

// single test for different architecture: linux/arm64
{"testdata", "basic", "push", "", platforms, "linux/arm64"},

}
log.SetLevel(log.DebugLevel)

Expand Down
27 changes: 18 additions & 9 deletions pkg/runner/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,22 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe

log.Debugf("type=%v actionDir=%s actionPath=%s Workdir=%s ActionCacheDir=%s actionName=%s containerActionDir=%s", step.Type(), actionDir, actionPath, rc.Config.Workdir, rc.ActionCacheDir(), actionName, containerActionDir)

maybeCopyToActionDir := func() error {
if step.Type() != model.StepTypeUsesActionRemote {
return nil
}
err := removeGitIgnore(actionDir)
if err != nil {
return err
}
return rc.JobContainer.CopyDir(containerActionDir+"/", actionDir, rc.Config.UseGitIgnore)(ctx)
}

switch action.Runs.Using {
case model.ActionRunsUsingNode12:
if step.Type() == model.StepTypeUsesActionRemote {
err := removeGitIgnore(actionDir)
if err != nil {
return err
}
err = rc.JobContainer.CopyDir(containerActionDir+"/", actionDir, rc.Config.UseGitIgnore)(ctx)
if err != nil {
return err
}
err := maybeCopyToActionDir()
if err != nil {
return err
}
containerArgs := []string{"node", path.Join(containerActionDir, actionName, actionPath, action.Runs.Main)}
log.Debugf("executing remote job container: %s", containerArgs)
Expand Down Expand Up @@ -488,6 +493,10 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
stepContainer.Remove().IfBool(!rc.Config.ReuseContainers),
)(ctx)
case model.ActionRunsUsingComposite:
err := maybeCopyToActionDir()
if err != nil {
return err
}
for outputName, output := range action.Outputs {
re := regexp.MustCompile(`\${{ steps\.([a-zA-Z_][a-zA-Z0-9_-]+)\.outputs\.([a-zA-Z_][a-zA-Z0-9_-]+) }}`)
matches := re.FindStringSubmatch(output.Value)
Expand Down

0 comments on commit 020d6a6

Please sign in to comment.