refactor: remove unreachable runner code (#1179)

Remove inherited act APIs, configuration branches, and test seams that neither the daemon nor exec can reach. Constant-fold settings both entry points already enforce and consolidate duplicate runner paths.

Major removals:

- Unwired custom action-cache and local-repository-cache implementations.
- Legacy matrix, platform, input, container-reuse, logging, Git remote, and action-replacement configuration paths.
- Unused Docker socket, container network, tar-copy, and platform PTY wrappers.
- Single-implementation filesystem, environment, runner, and expression abstractions.
- Duplicated step-container, command-logging, credential, reusable-workflow, and execution paths.
- Generated client mock boilerplate, obsolete fixtures, test-only seams, stale wrappers, and commented-out code.

This removes 2844 net Go lines while retaining Gitea RPC, event, matrix, input, cache, artifact, action, reusable workflow, Docker, host, exec, and release behavior.

Assisted by Codex (GPT-5).

Reviewed-on: https://gitea.com/gitea/runner/pulls/1179
Reviewed-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
silverwind
2026-08-22 16:54:41 +00:00
committed by silverwind
parent a0c4de79f7
commit 546eca312e
71 changed files with 593 additions and 3507 deletions
+33 -87
View File
@@ -56,10 +56,9 @@ type RunContext struct {
CurrentStepIndex int
StepResults map[string]*model.StepResult
IntraActionState map[string]map[string]string
ExprEval ExpressionEvaluator
ExprEval *expressionEvaluator
JobContainer container.ExecutionsEnvironment
serviceContainers []*serviceContainer
OutputMappings map[MappableOutput]MappableOutput
JobName string
ActionPath string
Parent *RunContext
@@ -148,11 +147,6 @@ func (rc *RunContext) AddMask(mask string) {
rc.Masks = append(rc.Masks, mask)
}
type MappableOutput struct {
StepID string
OutputName string
}
func (rc *RunContext) String() string {
name := fmt.Sprintf("%s/%s", rc.Run.Workflow.Name, rc.Name)
if rc.caller != nil {
@@ -341,16 +335,7 @@ func (rc *RunContext) GetBindsAndMounts() ([]string, map[string]string) {
func (rc *RunContext) startHostEnvironment() common.Executor {
return func(ctx context.Context) error {
logger := common.Logger(ctx)
rawLogger := logger.WithField(rawOutputField, true)
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
if rc.Config.LogOutput {
rawLogger.Infof("%s", s)
} else {
rawLogger.Debugf("%s", s)
}
return true
})
logWriter := rc.commandLogWriter(ctx)
cacheDir := rc.ActionCacheDir()
randBytes := make([]byte, 8)
_, _ = rand.Read(randBytes)
@@ -437,15 +422,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
return func(ctx context.Context) error {
logger := common.Logger(ctx)
image := rc.platformImage(ctx)
rawLogger := logger.WithField(rawOutputField, true)
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
if rc.Config.LogOutput {
rawLogger.Infof("%s", s)
} else {
rawLogger.Debugf("%s", s)
}
return true
})
logWriter := rc.commandLogWriter(ctx)
username, password, err := rc.handleCredentials(ctx)
if err != nil {
@@ -497,7 +474,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
}
// keep these local: reusing username/password would overwrite the
// credentials the job container is pulled with further down
serviceUsername, servicePassword, err := rc.handleServiceCredentials(ctx, spec.Credentials)
serviceUsername, servicePassword, err := rc.interpolateCredentials(ctx, spec.Credentials, "")
if err != nil {
return fmt.Errorf("failed to handle service %s credentials: %w", serviceID, err)
}
@@ -568,7 +545,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
UsernsMode: rc.Config.UsernsMode,
Platform: rc.Config.ContainerArchitecture,
Options: rc.options(ctx),
AutoRemove: rc.Config.AutoRemove,
AutoRemove: true,
ValidVolumes: rc.validVolumes(),
AllocatePTY: rc.Config.AllocatePTY,
})
@@ -604,12 +581,20 @@ func (rc *RunContext) startJobContainer() common.Executor {
}
}
func (rc *RunContext) commandLogWriter(ctx context.Context) io.Writer {
rawLogger := common.Logger(ctx).WithField(rawOutputField, true)
return common.NewLineWriter(rc.commandHandler(ctx), func(line string) bool {
rawLogger.Infof("%s", line)
return true
})
}
// cleanupJobResources removes everything the job created, continuing past failures.
// Only job container and volume errors are returned, the rest are logged.
func (rc *RunContext) cleanupJobResources(networkName string, createAndDeleteNetwork bool) common.Executor {
return func(ctx context.Context) error {
logger := common.Logger(ctx)
removeJobContainer := rc.JobContainer != nil && !rc.Config.ReuseContainers
removeJobContainer := rc.JobContainer != nil
var errs []error
if removeJobContainer {
@@ -639,12 +624,6 @@ func (rc *RunContext) cleanupJobResources(networkName string, createAndDeleteNet
}
}
func (rc *RunContext) execJobContainer(cmd []string, env map[string]string, user, workdir string) common.Executor { //nolint:unparam // pre-existing issue from nektos/act
return func(ctx context.Context) error {
return rc.JobContainer.Exec(cmd, env, user, workdir)(ctx)
}
}
func (rc *RunContext) ApplyExtraPath(ctx context.Context, env *map[string]string) {
if len(rc.ExtraPath) > 0 {
path := rc.JobContainer.GetPathVariableName()
@@ -1078,19 +1057,9 @@ func (rc *RunContext) runsOnImage(ctx context.Context) string {
runsOn[i] = rc.ExprEval.Interpolate(ctx, v)
}
if pick := rc.Config.PlatformPicker; pick != nil {
if image := pick(runsOn); image != "" {
return image
}
if rc.Config.PlatformPicker != nil {
return rc.Config.PlatformPicker(runsOn)
}
for _, platformName := range rc.runsOnPlatformNames(ctx) {
image := rc.Config.Platforms[strings.ToLower(platformName)]
if image != "" {
return image
}
}
return ""
}
@@ -1367,9 +1336,9 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
ghc.SetBaseAndHeadRef()
repoPath := rc.Config.Workdir
ghcontext.SetRepositoryAndOwner(ctx, ghc, rc.Config.GitHubInstance, rc.Config.RemoteName, repoPath)
ghcontext.SetRepositoryAndOwner(ctx, ghc, rc.Config.GitHubInstance, repoPath)
if ghc.Ref == "" {
ghcontext.SetRef(ctx, ghc, rc.Config.DefaultBranch, repoPath)
ghcontext.SetRef(ctx, ghc, repoPath)
}
if ghc.Sha == "" {
ghcontext.SetSha(ctx, ghc, repoPath)
@@ -1585,53 +1554,30 @@ func (rc *RunContext) handleCredentials(ctx context.Context) (string, string, er
return "", "", nil
}
if len(container.Credentials) != 2 {
err := errors.New("invalid property count for key 'credentials:'")
return "", "", err
return rc.interpolateCredentials(ctx, container.Credentials, "container.")
}
func (rc *RunContext) interpolateCredentials(ctx context.Context, credentials map[string]string, prefix string) (string, string, error) {
if credentials == nil {
return "", "", nil
}
if len(credentials) != 2 {
return "", "", errors.New("invalid property count for key 'credentials:'")
}
ee := rc.NewExpressionEvaluator(ctx)
var username, password string
if username = ee.Interpolate(ctx, container.Credentials["username"]); username == "" {
err := errors.New("failed to interpolate container.credentials.username")
return "", "", err
username := ee.Interpolate(ctx, credentials["username"])
if username == "" {
return "", "", errors.New("failed to interpolate " + prefix + "credentials.username")
}
if password = ee.Interpolate(ctx, container.Credentials["password"]); password == "" {
err := errors.New("failed to interpolate container.credentials.password")
return "", "", err
}
if container.Credentials["username"] == "" || container.Credentials["password"] == "" {
err := errors.New("container.credentials cannot be empty")
return "", "", err
password := ee.Interpolate(ctx, credentials["password"])
if password == "" {
return "", "", errors.New("failed to interpolate " + prefix + "credentials.password")
}
return username, password, nil
}
func (rc *RunContext) handleServiceCredentials(ctx context.Context, creds map[string]string) (username, password string, err error) {
if creds == nil {
return username, password, err
}
if len(creds) != 2 {
err = errors.New("invalid property count for key 'credentials:'")
return username, password, err
}
ee := rc.NewExpressionEvaluator(ctx)
if username = ee.Interpolate(ctx, creds["username"]); username == "" {
err = errors.New("failed to interpolate credentials.username")
return username, password, err
}
if password = ee.Interpolate(ctx, creds["password"]); password == "" {
err = errors.New("failed to interpolate credentials.password")
return username, password, err
}
return username, password, err
}
// GetServiceBindsAndMounts returns the binds and mounts for the service container, resolving paths as appopriate
func (rc *RunContext) GetServiceBindsAndMounts(svcVolumes []string) ([]string, map[string]string) {
binds, mounts, claimed := splitVolumes(svcVolumes)