mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-24 07:45:02 +01:00
feat: CustomExecutor Provide Custom Job Runner Implementation (#113)
This commit is contained in:
@@ -757,6 +757,9 @@ 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()
|
||||||
|
|
||||||
|
if exec, ok := rc.Config.CustomExecutor[jobType]; ok {
|
||||||
|
executor = exec(rc)
|
||||||
|
} else {
|
||||||
switch jobType {
|
switch jobType {
|
||||||
case model.JobTypeDefault:
|
case model.JobTypeDefault:
|
||||||
executor = newJobExecutor(rc, &stepFactoryImpl{}, rc)
|
executor = newJobExecutor(rc, &stepFactoryImpl{}, rc)
|
||||||
@@ -767,6 +770,7 @@ func (rc *RunContext) Executor() (common.Executor, error) {
|
|||||||
case model.JobTypeInvalid:
|
case model.JobTypeInvalid:
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
res, err := rc.isEnabled(ctx)
|
res, err := rc.isEnabled(ctx)
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user