feat: CustomExecutor Provide Custom Job Runner Implementation (#113)

This commit is contained in:
ChristopherHX
2025-06-08 11:41:38 +02:00
committed by GitHub
parent d5a1a09aa4
commit f36df5592d
2 changed files with 15 additions and 9 deletions

View File

@@ -757,15 +757,19 @@ func (rc *RunContext) Executor() (common.Executor, error) {
var executor common.Executor var executor common.Executor
var jobType, err = rc.Run.Job().Type() var jobType, err = rc.Run.Job().Type()
switch jobType { if exec, ok := rc.Config.CustomExecutor[jobType]; ok {
case model.JobTypeDefault: executor = exec(rc)
executor = newJobExecutor(rc, &stepFactoryImpl{}, rc) } else {
case model.JobTypeReusableWorkflowLocal: switch jobType {
executor = newLocalReusableWorkflowExecutor(rc) case model.JobTypeDefault:
case model.JobTypeReusableWorkflowRemote: executor = newJobExecutor(rc, &stepFactoryImpl{}, rc)
executor = newRemoteReusableWorkflowExecutor(rc) case model.JobTypeReusableWorkflowLocal:
case model.JobTypeInvalid: executor = newLocalReusableWorkflowExecutor(rc)
return nil, err case model.JobTypeReusableWorkflowRemote:
executor = newRemoteReusableWorkflowExecutor(rc)
case model.JobTypeInvalid:
return nil, err
}
} }
return func(ctx context.Context) error { return func(ctx context.Context) error {

View File

@@ -66,6 +66,8 @@ type Config struct {
ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network) ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network)
ActionCache ActionCache // Use a custom ActionCache Implementation ActionCache ActionCache // Use a custom ActionCache Implementation
HostEnvironmentDir string // Custom folder for host environment, parallel jobs must be 1 HostEnvironmentDir string // Custom folder for host environment, parallel jobs must be 1
CustomExecutor map[model.JobType]func(*RunContext) common.Executor // Custom executor to run jobs
} }
func (runnerConfig *Config) GetGitHubServerURL() string { func (runnerConfig *Config) GetGitHubServerURL() string {