mirror of
https://gitea.com/gitea/act_runner
synced 2026-11-08 10:57:59 +01:00
Removes dead code and redundant logic and consolidates tests, so there is less to read and maintain. No behavior change. 1. **act/runner**: inline single-use wrappers, compile regexes once instead of per call, embed the trampoline as a string, drop the unused legacy result of `parseActionCommand` 2. **act/container**: `sanitizeConfig` and `mergeContainerConfigs` stop returning the configs they already mutate in place, drop never-set option fields and the unused `user` parameter of `ExecWithCmdLine` 3. **act/common and cache server**: drop the unused `Trace`/`Tracef` loggers and the short SHA of `FindGitRevision`, `RegisterJob` releases through `RevokeJob` 4. **daemon, poller and reporter**: one shutdown wait for both poll modes, drop an unreachable fetch timeout branch, guard the reporter's last report time with its existing lock instead of an atomic 5. **build**: drop unused Makefile and release workflow variables, collapse the goreleaser ignore list to the same build targets 6. **tests**: fold near-duplicate tests into tables with shared setup Throughout, hand-rolled logic gives way to `cmp.Or`, `strings.Cut`, `slices` and `min`/`max`. Reviewed-on: https://gitea.com/gitea/runner/pulls/1335 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// Copyright 2022 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package runner
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"gitea.com/gitea/runner/act/common"
|
|
"gitea.com/gitea/runner/act/container"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
var noopExecutor = func(context.Context) error { return nil }
|
|
|
|
type containerMock struct {
|
|
mock.Mock
|
|
container.Container
|
|
container.LinuxContainerEnvironmentExtensions
|
|
}
|
|
|
|
func (cm *containerMock) Create(capAdd, capDrop []string) common.Executor {
|
|
return cm.Called(capAdd, capDrop).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Pull(forcePull bool) common.Executor {
|
|
return cm.Called(forcePull).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Start(attach bool) common.Executor {
|
|
return cm.Called(attach).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Remove() common.Executor {
|
|
return cm.Called().Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Close() common.Executor {
|
|
return cm.Called().Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) UpdateFromEnv(srcPath string, env *map[string]string) common.Executor {
|
|
return cm.Called(srcPath, env).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Copy(destPath string, files ...*container.FileEntry) common.Executor {
|
|
return cm.Called(destPath, files).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) CopyDir(destPath, srcPath string, useGitIgnore, skipGitDir bool) common.Executor {
|
|
return cm.Called(destPath, srcPath, useGitIgnore, skipGitDir).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) Exec(command []string, env map[string]string, user, workdir string) common.Executor {
|
|
return cm.Called(command, env, user, workdir).Get(0).(func(context.Context) error)
|
|
}
|
|
|
|
func (cm *containerMock) GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error) {
|
|
args := cm.Called(ctx, srcPath)
|
|
err, _ := args.Get(1).(error)
|
|
return args.Get(0).(io.ReadCloser), err
|
|
}
|
|
|
|
func (cm *containerMock) DumpLogs(ctx context.Context) error {
|
|
return cm.Called(ctx).Error(0)
|
|
}
|
|
|
|
func (cm *containerMock) Inspect(ctx context.Context) (*container.Info, error) {
|
|
args := cm.Called(ctx)
|
|
info, _ := args.Get(0).(*container.Info)
|
|
err, _ := args.Get(1).(error)
|
|
return info, err
|
|
}
|