mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-22 06:45:03 +01:00
feat: add act runner compat code (#35)
* attempt to build an act_runner using this implementation of act with minimal changes on act side. Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/35 Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:
committed by
ChristopherHX
parent
933c4a5bd5
commit
40ee0f3ef6
@@ -60,6 +60,13 @@ type PlannerConfig struct {
|
|||||||
Workflow WorkflowConfig
|
Workflow WorkflowConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CombineWorkflowPlanner combines workflows to a WorkflowPlanner
|
||||||
|
func CombineWorkflowPlanner(workflows ...*Workflow) WorkflowPlanner {
|
||||||
|
return &workflowPlanner{
|
||||||
|
workflows: workflows,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
|
// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
|
||||||
func NewWorkflowPlanner(path string, config PlannerConfig) (WorkflowPlanner, error) {
|
func NewWorkflowPlanner(path string, config PlannerConfig) (WorkflowPlanner, error) {
|
||||||
path, err := filepath.Abs(path)
|
path, err := filepath.Abs(path)
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ type Config struct {
|
|||||||
Planner model.PlannerConfig // Configuration for the workflow planner
|
Planner model.PlannerConfig // Configuration for the workflow planner
|
||||||
Action model.ActionConfig // Configuration for action reading
|
Action model.ActionConfig // Configuration for action reading
|
||||||
MainContextNames []string // e.g. "github", "gitea", "forgejo"
|
MainContextNames []string // e.g. "github", "gitea", "forgejo"
|
||||||
|
ContextData map[string]interface{}
|
||||||
|
EventJSON string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (runnerConfig *Config) GetGitHubServerURL() string {
|
func (runnerConfig *Config) GetGitHubServerURL() string {
|
||||||
@@ -129,7 +131,9 @@ func New(runnerConfig *Config) (Runner, error) {
|
|||||||
|
|
||||||
func (runner *runnerImpl) configure() (Runner, error) {
|
func (runner *runnerImpl) configure() (Runner, error) {
|
||||||
runner.eventJSON = "{}"
|
runner.eventJSON = "{}"
|
||||||
if runner.config.EventPath != "" {
|
if runner.config.EventJSON != "" {
|
||||||
|
runner.eventJSON = runner.config.EventJSON
|
||||||
|
} else if runner.config.EventPath != "" {
|
||||||
log.Debugf("Reading event.json from %s", runner.config.EventPath)
|
log.Debugf("Reading event.json from %s", runner.config.EventPath)
|
||||||
eventJSONBytes, err := os.ReadFile(runner.config.EventPath)
|
eventJSONBytes, err := os.ReadFile(runner.config.EventPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -295,6 +299,7 @@ func (runner *runnerImpl) newRunContext(ctx context.Context, run *model.Run, mat
|
|||||||
StepResults: make(map[string]*model.StepResult),
|
StepResults: make(map[string]*model.StepResult),
|
||||||
Matrix: matrix,
|
Matrix: matrix,
|
||||||
caller: runner.caller,
|
caller: runner.caller,
|
||||||
|
ContextData: runner.config.ContextData,
|
||||||
}
|
}
|
||||||
rc.ExprEval = rc.NewExpressionEvaluator(ctx)
|
rc.ExprEval = rc.NewExpressionEvaluator(ctx)
|
||||||
rc.Name = rc.ExprEval.Interpolate(ctx, run.String())
|
rc.Name = rc.ExprEval.Interpolate(ctx, run.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user