mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-23 15:25:03 +01:00
core(deps): bump golang-cilint to v2.0.2 (#83)
This commit is contained in:
@@ -190,7 +190,7 @@ func runActionImpl(step actionStep, actionDir string, remoteAction *remoteAction
|
||||
|
||||
return execAsComposite(step)(ctx)
|
||||
default:
|
||||
return fmt.Errorf("The runs.using key must be one of: %v, got %s", []string{
|
||||
return fmt.Errorf("the runs.using key must be one of: %v, got %s", []string{
|
||||
model.ActionRunsUsingDocker,
|
||||
model.ActionRunsUsingNode12,
|
||||
model.ActionRunsUsingNode16,
|
||||
|
||||
@@ -44,11 +44,11 @@ func (c GoGitActionCache) Fetch(ctx context.Context, cacheDir, url, ref, token s
|
||||
gogitrepo, err = git.PlainOpen(gitPath)
|
||||
}
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("GoGitActionCache failed to open bare git %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
return "", fmt.Errorf("goGitActionCache failed to open bare git %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
}
|
||||
tmpBranch := make([]byte, 12)
|
||||
if _, err := rand.Read(tmpBranch); err != nil {
|
||||
return "", fmt.Errorf("GoGitActionCache failed to generate random tmp branch %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
return "", fmt.Errorf("goGitActionCache failed to generate random tmp branch %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
}
|
||||
branchName := hex.EncodeToString(tmpBranch)
|
||||
|
||||
@@ -66,7 +66,7 @@ func (c GoGitActionCache) Fetch(ctx context.Context, cacheDir, url, ref, token s
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("GoGitActionCache failed to create remote %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
return "", fmt.Errorf("goGitActionCache failed to create remote %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
}
|
||||
defer func() {
|
||||
_ = gogitrepo.DeleteBranch(branchName)
|
||||
@@ -79,11 +79,11 @@ func (c GoGitActionCache) Fetch(ctx context.Context, cacheDir, url, ref, token s
|
||||
Force: true,
|
||||
Depth: 1,
|
||||
}); err != nil {
|
||||
return "", fmt.Errorf("GoGitActionCache failed to fetch %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
return "", fmt.Errorf("goGitActionCache failed to fetch %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
}
|
||||
hash, err := gogitrepo.ResolveRevision(plumbing.Revision(branchName))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("GoGitActionCache failed to resolve sha %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
return "", fmt.Errorf("goGitActionCache failed to resolve sha %s with ref %s at %s: %w", url, ref, gitPath, err)
|
||||
}
|
||||
logger.Infof("GoGitActionCache fetch %s with ref %s at %s resolved to %s", url, ref, gitPath, hash.String())
|
||||
return hash.String(), nil
|
||||
@@ -132,23 +132,23 @@ func (c GoGitActionCache) GetTarArchive(ctx context.Context, cacheDir, sha, incl
|
||||
|
||||
gitPath := path.Join(c.Path, safeFilename(cacheDir)+".git")
|
||||
|
||||
logger.Infof("GoGitActionCache get content %s with sha %s subpath %s at %s", cacheDir, sha, includePrefix, gitPath)
|
||||
logger.Infof("goGitActionCache get content %s with sha %s subpath %s at %s", cacheDir, sha, includePrefix, gitPath)
|
||||
|
||||
gogitrepo, err := git.PlainOpen(gitPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GoGitActionCache failed to open bare git %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
return nil, fmt.Errorf("goGitActionCache failed to open bare git %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
}
|
||||
commit, err := gogitrepo.CommitObject(plumbing.NewHash(sha))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GoGitActionCache failed to get commit %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
return nil, fmt.Errorf("goGitActionCache failed to get commit %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
}
|
||||
t, err := commit.Tree()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GoGitActionCache failed to open git tree %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
return nil, fmt.Errorf("goGitActionCache failed to open git tree %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
}
|
||||
files, err := commit.Files()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GoGitActionCache failed to list files %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
return nil, fmt.Errorf("goGitActionCache failed to list files %s with sha %s subpath %s at %s: %w", cacheDir, sha, includePrefix, gitPath, err)
|
||||
}
|
||||
rpipe, wpipe := io.Pipe()
|
||||
// Interrupt io.Copy using ctx
|
||||
|
||||
@@ -75,7 +75,7 @@ func (cm *containerMock) GetContainerArchive(ctx context.Context, srcPath string
|
||||
}
|
||||
|
||||
func (cm *containerMock) CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error {
|
||||
args := cm.Mock.Called(ctx, destPath, tarStream)
|
||||
args := cm.Called(ctx, destPath, tarStream)
|
||||
err, hasErr := args.Get(0).(error)
|
||||
if !hasErr {
|
||||
err = nil
|
||||
|
||||
@@ -186,7 +186,7 @@ func getHashFilesFunction(ctx context.Context, rc *RunContext) func(v []reflect.
|
||||
followSymlink = true
|
||||
continue
|
||||
}
|
||||
return "", fmt.Errorf("Invalid glob option %s, available option: '--follow-symbolic-links'", s)
|
||||
return "", fmt.Errorf("invalid glob option %s, available option: '--follow-symbolic-links'", s)
|
||||
}
|
||||
}
|
||||
patterns = append(patterns, s)
|
||||
@@ -385,7 +385,7 @@ func (ee expressionEvaluator) Interpolate(ctx context.Context, in string) string
|
||||
expr, _ := rewriteSubExpression(ctx, in, true)
|
||||
evaluated, err := ee.evaluate(ctx, expr, exprparser.DefaultStatusCheckNone)
|
||||
if err != nil {
|
||||
common.Logger(ctx).Errorf("Unable to interpolate expression '%s': %s", expr, err)
|
||||
common.Logger(ctx).Errorf("unable to interpolate expression '%s': %s", expr, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||
logger := common.Logger(ctx)
|
||||
logger.Infof("Cleaning up container for job %s", rc.JobName)
|
||||
if err = info.stopContainer()(ctx); err != nil {
|
||||
logger.Errorf("Error while stop job container: %v", err)
|
||||
logger.Errorf("error while stop job container: %v", err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -356,7 +356,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||
if len(rc.ServiceContainers) > 0 {
|
||||
logger.Infof("Cleaning up services for job %s", rc.JobName)
|
||||
if err := rc.stopServiceContainers()(ctx); err != nil {
|
||||
logger.Errorf("Error while cleaning services: %v", err)
|
||||
logger.Errorf("error while cleaning services: %v", err)
|
||||
}
|
||||
if createAndDeleteNetwork {
|
||||
// clean network if it has been created by act
|
||||
@@ -365,7 +365,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||
// so, we should remove the network at last.
|
||||
logger.Infof("Cleaning up network for job %s, and network name is: %s", rc.JobName, networkName)
|
||||
if err := container.NewDockerNetworkRemoveExecutor(networkName)(ctx); err != nil {
|
||||
logger.Errorf("Error while cleaning network: %v", err)
|
||||
logger.Errorf("error while cleaning network: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||
Options: rc.options(ctx),
|
||||
})
|
||||
if rc.JobContainer == nil {
|
||||
return errors.New("Failed to create job container")
|
||||
return errors.New("failed to create job container")
|
||||
}
|
||||
|
||||
return common.NewPipelineExecutor(
|
||||
@@ -774,7 +774,7 @@ func (rc *RunContext) runsOnPlatformNames(ctx context.Context) []string {
|
||||
}
|
||||
|
||||
if err := rc.ExprEval.EvaluateYamlNode(ctx, &job.RawRunsOn); err != nil {
|
||||
common.Logger(ctx).Errorf("Error while evaluating runs-on: %v", err)
|
||||
common.Logger(ctx).Errorf("error while evaluating runs-on: %v", err)
|
||||
return []string{}
|
||||
}
|
||||
|
||||
@@ -950,7 +950,7 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
|
||||
if rc.EventJSON != "" {
|
||||
err := json.Unmarshal([]byte(rc.EventJSON), &ghc.Event)
|
||||
if err != nil {
|
||||
logger.Errorf("Unable to Unmarshal event '%s': %v", rc.EventJSON, err)
|
||||
logger.Errorf("unable to Unmarshal event '%s': %v", rc.EventJSON, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ import (
|
||||
|
||||
func (rc *RunContext) startTartEnvironment() common.Executor {
|
||||
return func(_ context.Context) error {
|
||||
return fmt.Errorf("You need macOS for tart")
|
||||
return fmt.Errorf("you need macOS for tart")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||
|
||||
strategyRc := runner.newRunContext(ctx, run, nil)
|
||||
if err := strategyRc.NewExpressionEvaluator(ctx).EvaluateYamlNode(ctx, &job.Strategy.RawMatrix); err != nil {
|
||||
log.Errorf("Error while evaluating matrix: %v", err)
|
||||
log.Errorf("error while evaluating matrix: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
var matrixes []map[string]interface{}
|
||||
if m, err := job.GetMatrixes(); err != nil {
|
||||
log.Errorf("Error while get job's matrix: %v", err)
|
||||
log.Errorf("error while get job's matrix: %v", err)
|
||||
} else {
|
||||
log.Debugf("Job Matrices: %v", m)
|
||||
log.Debugf("Runner Matrices: %v", runner.config.Matrix)
|
||||
@@ -212,7 +212,7 @@ func handleFailure(plan *model.Plan) common.Executor {
|
||||
for _, stage := range plan.Stages {
|
||||
for _, run := range stage.Runs {
|
||||
if run.Job().Result == "failure" {
|
||||
return fmt.Errorf("Job '%s' failed", run.String())
|
||||
return fmt.Errorf("job '%s' failed", run.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
assert "github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -364,8 +363,8 @@ type captureJobLoggerFactory struct {
|
||||
buffer bytes.Buffer
|
||||
}
|
||||
|
||||
func (factory *captureJobLoggerFactory) WithJobLogger() *logrus.Logger {
|
||||
logger := logrus.New()
|
||||
func (factory *captureJobLoggerFactory) WithJobLogger() *log.Logger {
|
||||
logger := log.New()
|
||||
logger.SetOutput(&factory.buffer)
|
||||
logger.SetLevel(log.TraceLevel)
|
||||
logger.SetFormatter(&log.JSONFormatter{})
|
||||
@@ -397,7 +396,7 @@ func TestPullFailureIsJobFailure(t *testing.T) {
|
||||
path.Clean(path.Join(workdir, "cache")),
|
||||
}
|
||||
|
||||
logger := logrus.New()
|
||||
logger := log.New()
|
||||
logger.SetOutput(&factory.buffer)
|
||||
logger.SetLevel(log.TraceLevel)
|
||||
logger.SetFormatter(&log.JSONFormatter{})
|
||||
@@ -467,7 +466,7 @@ func TestFetchFailureIsJobFailure(t *testing.T) {
|
||||
}
|
||||
config.ActionCache = &mockCache{}
|
||||
|
||||
logger := logrus.New()
|
||||
logger := log.New()
|
||||
logger.SetOutput(&factory.buffer)
|
||||
logger.SetLevel(log.TraceLevel)
|
||||
logger.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
@@ -38,7 +38,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||
|
||||
sar.remoteAction = newRemoteAction(sar.Step.Uses)
|
||||
if sar.remoteAction == nil {
|
||||
return fmt.Errorf("Expected format {org}/{repo}[/path]@ref. Actual '%s' Input string was not in a correct format", sar.Step.Uses)
|
||||
return fmt.Errorf("expected format {org}/{repo}[/path]@ref. Actual '%s' Input string was not in a correct format", sar.Step.Uses)
|
||||
}
|
||||
|
||||
github := sar.getGithubContext(ctx)
|
||||
|
||||
@@ -35,12 +35,12 @@ type TestRepositoryCache struct {
|
||||
}
|
||||
|
||||
func (l *TestRepositoryCache) Fetch(ctx context.Context, cacheDir, url, ref, token string) (string, error) {
|
||||
args := l.Mock.Called(ctx, cacheDir, url, ref, token)
|
||||
args := l.Called(ctx, cacheDir, url, ref, token)
|
||||
return args.Get(0).(string), nil
|
||||
}
|
||||
|
||||
func (l *TestRepositoryCache) GetTarArchive(ctx context.Context, cacheDir, sha, includePrefix string) (io.ReadCloser, error) {
|
||||
args := l.Mock.Called(ctx, cacheDir, sha, includePrefix)
|
||||
args := l.Called(ctx, cacheDir, sha, includePrefix)
|
||||
return args.Get(0).(io.ReadCloser), nil
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func TestStepActionRemote(t *testing.T) {
|
||||
|
||||
sarm.AssertExpectations(t)
|
||||
cm.AssertExpectations(t)
|
||||
cacheMock.Mock.AssertExpectations(t)
|
||||
cacheMock.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ func TestStepActionRemotePre(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
sarm.AssertExpectations(t)
|
||||
cacheMock.Mock.AssertExpectations(t)
|
||||
cacheMock.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ func TestStepActionRemotePreThroughAction(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
sarm.AssertExpectations(t)
|
||||
cacheMock.Mock.AssertExpectations(t)
|
||||
cacheMock.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,7 @@ func TestStepActionRemotePreThroughActionToken(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
|
||||
sarm.AssertExpectations(t)
|
||||
cacheMock.Mock.AssertExpectations(t)
|
||||
cacheMock.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type stepFactoryImpl struct{}
|
||||
func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step, error) {
|
||||
switch stepModel.Type() {
|
||||
case model.StepTypeInvalid:
|
||||
return nil, fmt.Errorf("Invalid run/uses syntax for job:%s step:%+v", rc.Run, stepModel)
|
||||
return nil, fmt.Errorf("invalid run/uses syntax for job:%s step:%+v", rc.Run, stepModel)
|
||||
case model.StepTypeRun:
|
||||
return &stepRun{
|
||||
Step: stepModel,
|
||||
@@ -42,5 +42,5 @@ func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Unable to determine how to run job:%s step:%+v", rc.Run, stepModel)
|
||||
return nil, fmt.Errorf("unable to determine how to run job:%s step:%+v", rc.Run, stepModel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user