forked from nektos/act
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to spawn and run a local reusable workflow (nektos#1423)
* feat: allow to spawn and run a local reusable workflow This change contains the ability to parse/plan/run a local reusable workflow. There are still numerous things missing: - inputs - secrets - outputs * feat: add workflow_call inputs * test: improve inputs test * feat: add input defaults * feat: allow expressions in inputs * feat: use context specific expression evaluator * refactor: prepare for better re-usability * feat: add secrets for reusable workflows * test: use secrets during test run * feat: handle reusable workflow outputs Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d281230
commit a8e05cd
Showing
10 changed files
with
472 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package runner | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
|
||
"github.com/nektos/act/pkg/common" | ||
"github.com/nektos/act/pkg/model" | ||
) | ||
|
||
func newLocalReusableWorkflowExecutor(rc *RunContext) common.Executor { | ||
return newReusableWorkflowExecutor(rc, rc.Config.Workdir) | ||
} | ||
|
||
func newRemoteReusableWorkflowExecutor(rc *RunContext) common.Executor { | ||
return common.NewErrorExecutor(fmt.Errorf("remote reusable workflows are currently not supported (see https://github.com/nektos/act/issues/826 for updates)")) | ||
} | ||
|
||
func newReusableWorkflowExecutor(rc *RunContext, directory string) common.Executor { | ||
planner, err := model.NewWorkflowPlanner(path.Join(directory, rc.Run.Job().Uses), true) | ||
if err != nil { | ||
return common.NewErrorExecutor(err) | ||
} | ||
|
||
plan := planner.PlanEvent("workflow_call") | ||
|
||
runner, err := NewReusableWorkflowRunner(rc) | ||
if err != nil { | ||
return common.NewErrorExecutor(err) | ||
} | ||
|
||
return runner.NewPlanExecutor(plan) | ||
} | ||
|
||
func NewReusableWorkflowRunner(rc *RunContext) (Runner, error) { | ||
runner := &runnerImpl{ | ||
config: rc.Config, | ||
eventJSON: rc.EventJSON, | ||
caller: &caller{ | ||
runContext: rc, | ||
}, | ||
} | ||
|
||
return runner.configure() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.