diff --git a/.github/actions/choco/Dockerfile b/.github/actions/choco/Dockerfile index aabcb3a6..b6478df9 100644 --- a/.github/actions/choco/Dockerfile +++ b/.github/actions/choco/Dockerfile @@ -1,9 +1,9 @@ -FROM alpine:3.17 +FROM alpine:3.21 ARG CHOCOVERSION=1.1.0 RUN apk add --no-cache bash ca-certificates git \ - && apk --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing add mono mono-dev \ + && apk --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community add mono mono-dev \ && cert-sync /etc/ssl/certs/ca-certificates.crt \ && wget "https://github.com/chocolatey/choco/archive/${CHOCOVERSION}.tar.gz" -O- | tar -xzf - \ && cd choco-"${CHOCOVERSION}" \ diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index df18970a..dd1f9707 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -22,9 +22,9 @@ jobs: with: go-version-file: go.mod check-latest: true - - uses: golangci/golangci-lint-action@v6.5.0 + - uses: golangci/golangci-lint-action@v7.0.0 with: - version: v1.64.8 + version: v2.0.2 - uses: megalinter/megalinter/flavors/go@v8.4.2 env: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} diff --git a/.golangci.yml b/.golangci.yml index 2c6823e7..aaf83f91 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,56 +1,65 @@ -# Minimum golangci-lint version required: v1.46.0 -run: - timeout: 3m - -issues: - exclude-dirs: - - report # megalinter results+fixes - max-issues-per-linter: 0 - max-same-issues: 0 - -linters-settings: - gocyclo: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 20 - gocritic: - disabled-checks: - - ifElseChain - importas: - alias: - - pkg: 'github.com/sirupsen/logrus' - alias: log - - pkg: 'github.com/stretchr/testify/assert' - alias: assert - depguard: - rules: - main: - deny: - - pkg: github.com/pkg/errors - desc: Please use "errors" package from standard library - - pkg: gotest.tools/v3 - desc: Please keep tests unified using only github.com/stretchr/testify - - pkg: log - desc: Please keep logging unified using only github.com/sirupsen/logrus +version: "2" linters: enable: - - gosimple - - staticcheck - - unused - - govet - - revive + - contextcheck + - copyloopvar + - depguard + - dupl + - gocritic - gocyclo - gosec - - unconvert - - dupl - - nakedret - - prealloc - - copyloopvar - - gocritic - - goimports - - whitespace - - misspell - - depguard - importas - - contextcheck + - misspell + - nakedret - nolintlint + - prealloc - revive + - unconvert + - whitespace + settings: + depguard: + rules: + main: + deny: + - pkg: github.com/pkg/errors + desc: Please use "errors" package from standard library + - pkg: gotest.tools/v3 + desc: Please keep tests unified using only github.com/stretchr/testify + - pkg: log + desc: Please keep logging unified using only github.com/sirupsen/logrus + gocritic: + disabled-checks: + - ifElseChain + gocyclo: + min-complexity: 20 + importas: + alias: + - pkg: github.com/sirupsen/logrus + alias: log + - pkg: github.com/stretchr/testify/assert + alias: assert + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - report + - third_party$ + - builtin$ + - examples$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 +formatters: + enable: + - goimports + exclusions: + generated: lax + paths: + - report + - third_party$ + - builtin$ + - examples$ diff --git a/cmd/execute_test.go b/cmd/execute_test.go index 90f43fd4..bc4ee098 100644 --- a/cmd/execute_test.go +++ b/cmd/execute_test.go @@ -33,13 +33,13 @@ func testMain(args []string) (exitCode int) { func TestMainHelp(t *testing.T) { exitCode := testMain([]string{"cmd", "--help"}) if exitCode != 0 { - t.Errorf("Expected exit code 0, got %d", exitCode) + t.Errorf("expected exit code 0, got %d", exitCode) } } func TestMainNoArgsError(t *testing.T) { exitCode := testMain([]string{"cmd"}) if exitCode != 1 { - t.Errorf("Expected exit code 1, got %d", exitCode) + t.Errorf("expected exit code 1, got %d", exitCode) } } diff --git a/cmd/root.go b/cmd/root.go index 3bd2876e..8c34d70b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -280,7 +280,7 @@ func readArgsFile(file string, split bool) []string { defer func() { err := f.Close() if err != nil { - log.Errorf("Failed to close args file: %v", err) + log.Errorf("failed to close args file: %v", err) } }() scanner := bufio.NewScanner(f) @@ -555,7 +555,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str } if plan != nil { if len(plan.Stages) == 0 { - plannerErr = fmt.Errorf("Could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name") + plannerErr = fmt.Errorf("could not find any stages to run. View the valid jobs with `act --list`. Use `act --help` to find how to filter by Job ID/Workflow/Event Name") } } if plan == nil && plannerErr != nil { diff --git a/cmd/secrets.go b/cmd/secrets.go index 25126f1c..3e053974 100644 --- a/cmd/secrets.go +++ b/cmd/secrets.go @@ -17,7 +17,7 @@ func newSecrets(secretList []string) secrets { secretPairParts := strings.SplitN(secretPair, "=", 2) secretPairParts[0] = strings.ToUpper(secretPairParts[0]) if strings.ToUpper(s[secretPairParts[0]]) == secretPairParts[0] { - log.Errorf("Secret %s is already defined (secrets are case insensitive)", secretPairParts[0]) + log.Errorf("secret %s is already defined (secrets are case insensitive)", secretPairParts[0]) } if len(secretPairParts) == 2 { s[secretPairParts[0]] = secretPairParts[1] diff --git a/pkg/artifacts/arifacts_v4.go b/pkg/artifacts/arifacts_v4.go index 9cbe0b3c..d9967aef 100644 --- a/pkg/artifacts/arifacts_v4.go +++ b/pkg/artifacts/arifacts_v4.go @@ -203,7 +203,7 @@ func (r artifactV4Routes) buildSignature(endp, expires, artifactName string, tas mac.Write([]byte(endp)) mac.Write([]byte(expires)) mac.Write([]byte(artifactName)) - mac.Write([]byte(fmt.Sprint(taskID))) + fmt.Fprint(mac, taskID) return mac.Sum(nil) } @@ -240,13 +240,13 @@ func (r artifactV4Routes) verifySignature(ctx *ArtifactContext, endp string) (in func (r *artifactV4Routes) parseProtbufBody(ctx *ArtifactContext, req protoreflect.ProtoMessage) bool { body, err := io.ReadAll(ctx.Req.Body) if err != nil { - log.Errorf("Error decode request body: %v", err) + log.Errorf("error decode request body: %v", err) ctx.Error(http.StatusInternalServerError, "Error decode request body") return false } err = protojson.Unmarshal(body, req) if err != nil { - log.Errorf("Error decode request body: %v", err) + log.Errorf("error decode request body: %v", err) ctx.Error(http.StatusInternalServerError, "Error decode request body") return false } @@ -256,7 +256,7 @@ func (r *artifactV4Routes) parseProtbufBody(ctx *ArtifactContext, req protorefle func (r *artifactV4Routes) sendProtbufBody(ctx *ArtifactContext, req protoreflect.ProtoMessage) { resp, err := protojson.Marshal(req) if err != nil { - log.Errorf("Error encode response body: %v", err) + log.Errorf("error encode response body: %v", err) ctx.Error(http.StatusInternalServerError, "Error encode response body") return } @@ -318,11 +318,11 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) { writer, ok := file.(io.Writer) if !ok { - panic(errors.New("File is not writable")) + panic(errors.New("file is not writable")) } if ctx.Req.Body == nil { - panic(errors.New("No body given")) + panic(errors.New("no body given")) } _, err = io.Copy(writer, ctx.Req.Body) diff --git a/pkg/artifacts/server.go b/pkg/artifacts/server.go index c98d8112..1ac64018 100644 --- a/pkg/artifacts/server.go +++ b/pkg/artifacts/server.go @@ -135,11 +135,11 @@ func uploads(router *httprouter.Router, baseDir string, fsys WriteFS) { writer, ok := file.(io.Writer) if !ok { - panic(errors.New("File is not writable")) + panic(errors.New("file is not writable")) } if req.Body == nil { - panic(errors.New("No body given")) + panic(errors.New("no body given")) } _, err = io.Copy(writer, req.Body) @@ -310,7 +310,7 @@ func Serve(ctx context.Context, artifactPath string, addr string, port string) c <-serverContext.Done() if err := server.Shutdown(ctx); err != nil { - logger.Errorf("Failed shutdown gracefully - force shutdown: %v", err) + logger.Errorf("failed shutdown gracefully - force shutdown: %v", err) server.Close() } }() diff --git a/pkg/common/executor.go b/pkg/common/executor.go index 5e38b23c..db36ab3b 100644 --- a/pkg/common/executor.go +++ b/pkg/common/executor.go @@ -227,7 +227,7 @@ func (e Executor) Finally(finally Executor) Executor { defer func() { err2 := finally(ctx) if err2 != nil { - err = fmt.Errorf("Error occurred running finally: %v (original error: %v)", err2, err) + err = fmt.Errorf("error occurred running finally: %v (original error: %v)", err2, err) } }() err = e(ctx) diff --git a/pkg/common/git/git.go b/pkg/common/git/git.go index d1802a98..9eedb3b3 100644 --- a/pkg/common/git/git.go +++ b/pkg/common/git/git.go @@ -74,7 +74,7 @@ func FindGitRevision(ctx context.Context, file string) (shortSha string, sha str } if head.Hash().IsZero() { - return "", "", fmt.Errorf("HEAD sha1 could not be resolved") + return "", "", fmt.Errorf("head sha1 could not be resolved") } hash := head.Hash().String() @@ -261,7 +261,7 @@ func CloneIfRequired(ctx context.Context, refName plumbing.ReferenceName, input } else if lgr, ok := logger.(*log.Logger); ok { progressWriter = lgr.WriterLevel(log.DebugLevel) } else { - log.Errorf("Unable to get writer from logger (type=%T)", logger) + log.Errorf("unable to get writer from logger (type=%T)", logger) progressWriter = os.Stdout } } @@ -279,7 +279,7 @@ func CloneIfRequired(ctx context.Context, refName plumbing.ReferenceName, input r, err = git.PlainCloneContext(ctx, input.Dir, false, &cloneOptions) if err != nil { - logger.Errorf("Unable to clone %v %s: %v", input.URL, refName, err) + logger.Errorf("unable to clone %v %s: %v", input.URL, refName, err) return nil, err } @@ -340,7 +340,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { var hash *plumbing.Hash rev := plumbing.Revision(input.Ref) if hash, err = r.ResolveRevision(rev); err != nil { - logger.Errorf("Unable to resolve %s: %v", input.Ref, err) + logger.Errorf("unable to resolve %s: %v", input.Ref, err) } if hash.String() != input.Ref && len(input.Ref) >= 4 && strings.HasPrefix(hash.String(), input.Ref) { @@ -369,7 +369,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { } if hash, err = r.ResolveRevision(rev); err != nil { - logger.Errorf("Unable to resolve %s: %v", input.Ref, err) + logger.Errorf("unable to resolve %s: %v", input.Ref, err) return err } @@ -390,7 +390,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { Branch: sourceRef, Force: true, }); err != nil { - logger.Errorf("Unable to checkout %s: %v", sourceRef, err) + logger.Errorf("unable to checkout %s: %v", sourceRef, err) return err } } @@ -404,7 +404,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { if hash.String() != input.Ref && refType == "branch" { logger.Debugf("Provided ref is not a sha. Updating branch ref after pull") if hash, err = r.ResolveRevision(rev); err != nil { - logger.Errorf("Unable to resolve %s: %v", input.Ref, err) + logger.Errorf("unable to resolve %s: %v", input.Ref, err) return err } } @@ -412,7 +412,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { Hash: *hash, Force: true, }); err != nil { - logger.Errorf("Unable to checkout %s: %v", *hash, err) + logger.Errorf("unable to checkout %s: %v", *hash, err) return err } @@ -420,7 +420,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { Mode: git.HardReset, Commit: *hash, }); err != nil { - logger.Errorf("Unable to reset to %s: %v", hash.String(), err) + logger.Errorf("unable to reset to %s: %v", hash.String(), err) return err } diff --git a/pkg/common/git/git_test.go b/pkg/common/git/git_test.go index 9c7037fe..c6d70b50 100644 --- a/pkg/common/git/git_test.go +++ b/pkg/common/git/git_test.go @@ -241,7 +241,7 @@ func gitCmd(args ...string) error { err := cmd.Run() if exitError, ok := err.(*exec.ExitError); ok { if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { - return fmt.Errorf("Exit error %d", waitStatus.ExitStatus()) + return fmt.Errorf("exit error %d", waitStatus.ExitStatus()) } return exitError } diff --git a/pkg/container/docker_cli.go b/pkg/container/docker_cli.go index bb49a999..5005897b 100644 --- a/pkg/container/docker_cli.go +++ b/pkg/container/docker_cli.go @@ -679,7 +679,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con } if copts.autoRemove && !hostConfig.RestartPolicy.IsNone() { - return nil, errors.Errorf("Conflicting options: --restart and --rm") + return nil, errors.Errorf("conflicting options: --restart and --rm") } // only set this value if the user provided the flag, else it should default to nil @@ -868,7 +868,7 @@ func parseSecurityOpts(securityOpts []string) ([]string, error) { if strings.Contains(opt, ":") { con = strings.SplitN(opt, ":", 2) } else { - return securityOpts, errors.Errorf("Invalid --security-opt: %q", opt) + return securityOpts, errors.Errorf("invalid --security-opt: %q", opt) } } if con[0] == "seccomp" && con[1] != "unconfined" { diff --git a/pkg/container/docker_cli_test.go b/pkg/container/docker_cli_test.go index 7ac715a2..cca08e24 100644 --- a/pkg/container/docker_cli_test.go +++ b/pkg/container/docker_cli_test.go @@ -693,7 +693,7 @@ func TestParseRestartPolicy(t *testing.T) { } func TestParseRestartPolicyAutoRemove(t *testing.T) { - expected := "Conflicting options: --restart and --rm" + expected := "conflicting options: --restart and --rm" _, _, _, err := parseRun([]string{"--rm", "--restart=always", "img", "cmd"}) //nolint:dogsled if err == nil || err.Error() != expected { t.Fatalf("Expected error %v, but got none", expected) diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index fa2974e0..6f978e2e 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -137,7 +137,7 @@ func (cr *containerReference) CopyDir(destPath string, srcPath string, useGitIgn func (cr *containerReference) GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error) { if common.Dryrun(ctx) { - return nil, fmt.Errorf("DRYRUN is not supported in GetContainerArchive") + return nil, fmt.Errorf("dryrun is not supported in GetContainerArchive") } a, _, err := cr.cli.CopyFromContainer(ctx, cr.id, srcPath) return a, err @@ -363,30 +363,30 @@ func (cr *containerReference) mergeContainerConfigs(ctx context.Context, config optionsArgs, err := shellquote.Split(input.Options) if err != nil { - return nil, nil, fmt.Errorf("Cannot split container options: '%s': '%w'", input.Options, err) + return nil, nil, fmt.Errorf("cannot split container options: '%s': '%w'", input.Options, err) } err = flags.Parse(optionsArgs) if err != nil { - return nil, nil, fmt.Errorf("Cannot parse container options: '%s': '%w'", input.Options, err) + return nil, nil, fmt.Errorf("cannot parse container options: '%s': '%w'", input.Options, err) } if len(copts.netMode.Value()) == 0 { if err = copts.netMode.Set(cr.input.NetworkMode); err != nil { - return nil, nil, fmt.Errorf("Cannot parse networkmode=%s. This is an internal error and should not happen: '%w'", cr.input.NetworkMode, err) + return nil, nil, fmt.Errorf("cannot parse networkmode=%s. This is an internal error and should not happen: '%w'", cr.input.NetworkMode, err) } } containerConfig, err := parse(flags, copts, runtime.GOOS) if err != nil { - return nil, nil, fmt.Errorf("Cannot process container options: '%s': '%w'", input.Options, err) + return nil, nil, fmt.Errorf("cannot process container options: '%s': '%w'", input.Options, err) } logger.Debugf("Custom container.Config from options ==> %+v", containerConfig.Config) err = mergo.Merge(config, containerConfig.Config, mergo.WithOverride) if err != nil { - return nil, nil, fmt.Errorf("Cannot merge container.Config options: '%s': '%w'", input.Options, err) + return nil, nil, fmt.Errorf("cannot merge container.Config options: '%s': '%w'", input.Options, err) } logger.Debugf("Merged container.Config ==> %+v", config) @@ -398,7 +398,7 @@ func (cr *containerReference) mergeContainerConfigs(ctx context.Context, config mounts := hostConfig.Mounts err = mergo.Merge(hostConfig, containerConfig.HostConfig, mergo.WithOverride) if err != nil { - return nil, nil, fmt.Errorf("Cannot merge container.HostConfig options: '%s': '%w'", input.Options, err) + return nil, nil, fmt.Errorf("cannot merge container.HostConfig options: '%s': '%w'", input.Options, err) } hostConfig.Binds = binds hostConfig.Mounts = mounts diff --git a/pkg/container/docker_run_test.go b/pkg/container/docker_run_test.go index 76cb8590..949d6081 100644 --- a/pkg/container/docker_run_test.go +++ b/pkg/container/docker_run_test.go @@ -200,7 +200,7 @@ func TestDockerCopyTarStreamErrorInCopyFiles(t *testing.T) { conn := &mockConn{} - merr := fmt.Errorf("Failure") + merr := fmt.Errorf("failure") client := &mockDockerClient{} client.On("CopyToContainer", ctx, "123", "/", mock.Anything, mock.AnythingOfType("container.CopyToContainerOptions")).Return(merr) @@ -225,7 +225,7 @@ func TestDockerCopyTarStreamErrorInMkdir(t *testing.T) { conn := &mockConn{} - merr := fmt.Errorf("Failure") + merr := fmt.Errorf("failure") client := &mockDockerClient{} client.On("CopyToContainer", ctx, "123", "/", mock.Anything, mock.AnythingOfType("container.CopyToContainerOptions")).Return(nil) diff --git a/pkg/container/docker_socket.go b/pkg/container/docker_socket.go index 8b3ed024..c04ace96 100644 --- a/pkg/container/docker_socket.go +++ b/pkg/container/docker_socket.go @@ -90,7 +90,7 @@ func GetSocketAndHost(containerSocket string) (SocketAndHost, error) { if !hasDockerHost && socketHost.Socket != "" && !isDockerHostURI(socketHost.Socket) { // Cases: 1B, 2B // Should we early-exit here, since there is no host nor socket to talk to? - return SocketAndHost{}, fmt.Errorf("DOCKER_HOST was not set, couldn't be found in the usual locations, and the container daemon socket ('%s') is invalid", socketHost.Socket) + return SocketAndHost{}, fmt.Errorf("docker host aka DOCKER_HOST was not set, couldn't be found in the usual locations, and the container daemon socket ('%s') is invalid", socketHost.Socket) } // Default to DOCKER_HOST if set diff --git a/pkg/container/host_environment.go b/pkg/container/host_environment.go index 239c20bb..ea898aca 100644 --- a/pkg/container/host_environment.go +++ b/pkg/container/host_environment.go @@ -83,7 +83,7 @@ func (e *HostEnvironment) CopyTarStream(ctx context.Context, destPath string, ta continue } if ctx.Err() != nil { - return fmt.Errorf("CopyTarStream has been cancelled") + return fmt.Errorf("copyTarStream has been cancelled") } if err := cp.WriteFile(ti.Name, ti.FileInfo(), ti.Linkname, tr); err != nil { return err @@ -405,12 +405,14 @@ func (e *HostEnvironment) GetActPath() string { } func (*HostEnvironment) GetPathVariableName() string { - if runtime.GOOS == "plan9" { + switch runtime.GOOS { + case "plan9": return "path" - } else if runtime.GOOS == "windows" { + case "windows": return "Path" // Actually we need a case insensitive map + default: + return "PATH" } - return "PATH" } func (e *HostEnvironment) DefaultPathVariable() string { diff --git a/pkg/exprparser/functions.go b/pkg/exprparser/functions.go index 018fc09b..3a261923 100644 --- a/pkg/exprparser/functions.go +++ b/pkg/exprparser/functions.go @@ -94,13 +94,13 @@ func (impl *interperterImpl) format(str reflect.Value, replaceValue ...reflect.V case '}': index, err := strconv.ParseInt(replacementIndex, 10, 32) if err != nil { - return "", fmt.Errorf("The following format string is invalid: '%s'", input) + return "", fmt.Errorf("the following format string is invalid: '%s'", input) } replacementIndex = "" if len(replaceValue) <= int(index) { - return "", fmt.Errorf("The following format string references more arguments than were supplied: '%s'", input) + return "", fmt.Errorf("the following format string references more arguments than were supplied: '%s'", input) } output += impl.coerceToString(replaceValue[index]).String() @@ -127,10 +127,10 @@ func (impl *interperterImpl) format(str reflect.Value, replaceValue ...reflect.V if state != passThrough { switch state { case bracketOpen: - return "", fmt.Errorf("Unclosed brackets. The following format string is invalid: '%s'", input) + return "", fmt.Errorf("unclosed brackets. The following format string is invalid: '%s'", input) case bracketClose: - return "", fmt.Errorf("Closing bracket without opening one. The following format string is invalid: '%s'", input) + return "", fmt.Errorf("closing bracket without opening one. The following format string is invalid: '%s'", input) } } @@ -159,7 +159,7 @@ func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) { json, err := json.MarshalIndent(value.Interface(), "", " ") if err != nil { - return "", fmt.Errorf("Cannot convert value to JSON. Cause: %v", err) + return "", fmt.Errorf("cannot convert value to JSON. Cause: %v", err) } return string(json), nil @@ -167,14 +167,14 @@ func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) { func (impl *interperterImpl) fromJSON(value reflect.Value) (interface{}, error) { if value.Kind() != reflect.String { - return nil, fmt.Errorf("Cannot parse non-string type %v as JSON", value.Kind()) + return nil, fmt.Errorf("cannot parse non-string type %v as JSON", value.Kind()) } var data interface{} err := json.Unmarshal([]byte(value.String()), &data) if err != nil { - return nil, fmt.Errorf("Invalid JSON: %v", err) + return nil, fmt.Errorf("invalid JSON: %v", err) } return data, nil @@ -195,7 +195,7 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) { } ps = append(ps, gitignore.ParsePattern(cleanPath, nil)) } else { - return "", fmt.Errorf("Non-string path passed to hashFiles") + return "", fmt.Errorf("non-string path passed to hashFiles") } } @@ -214,7 +214,7 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) { files = append(files, path) return nil }); err != nil { - return "", fmt.Errorf("Unable to filepath.Walk: %v", err) + return "", fmt.Errorf("unable to filepath.Walk: %v", err) } if len(files) == 0 { @@ -226,15 +226,15 @@ func (impl *interperterImpl) hashFiles(paths ...reflect.Value) (string, error) { for _, file := range files { f, err := os.Open(file) if err != nil { - return "", fmt.Errorf("Unable to os.Open: %v", err) + return "", fmt.Errorf("unable to os.Open: %v", err) } if _, err := io.Copy(hasher, f); err != nil { - return "", fmt.Errorf("Unable to io.Copy: %v", err) + return "", fmt.Errorf("unable to io.Copy: %v", err) } if err := f.Close(); err != nil { - return "", fmt.Errorf("Unable to Close file: %v", err) + return "", fmt.Errorf("unable to Close file: %v", err) } } diff --git a/pkg/exprparser/functions_test.go b/pkg/exprparser/functions_test.go index bf799c30..063238b8 100644 --- a/pkg/exprparser/functions_test.go +++ b/pkg/exprparser/functions_test.go @@ -233,10 +233,10 @@ func TestFunctionFormat(t *testing.T) { {`format('Hello "{0}" {1} {2}', fromJSON('[0, true, "abc"]'), fromJSON('[{"a":1}]'), fromJSON('{"a":{"b":1}}'))`, `Hello "Array" Array Object`, nil, "format-with-complex-types"}, {"format(true)", "true", nil, "format-with-primitive-args"}, {"format('echo Hello {0} ${{Test}}', github.undefined_property)", "echo Hello ${Test}", nil, "format-with-undefined-value"}, - {"format('{0}}', '{1}', 'World')", nil, "Closing bracket without opening one. The following format string is invalid: '{0}}'", "format-invalid-format-string"}, - {"format('{0', '{1}', 'World')", nil, "Unclosed brackets. The following format string is invalid: '{0'", "format-invalid-format-string"}, - {"format('{2}', '{1}', 'World')", "", "The following format string references more arguments than were supplied: '{2}'", "format-invalid-replacement-reference"}, - {"format('{2147483648}')", "", "The following format string is invalid: '{2147483648}'", "format-invalid-replacement-reference"}, + {"format('{0}}', '{1}', 'World')", nil, "closing bracket without opening one. The following format string is invalid: '{0}}'", "format-invalid-format-string"}, + {"format('{0', '{1}', 'World')", nil, "unclosed brackets. The following format string is invalid: '{0'", "format-invalid-format-string"}, + {"format('{2}', '{1}', 'World')", "", "the following format string references more arguments than were supplied: '{2}'", "format-invalid-replacement-reference"}, + {"format('{2147483648}')", "", "the following format string is invalid: '{2147483648}'", "format-invalid-replacement-reference"}, {"format('{0} {1} {2} {3}', 1.0, 1.1, 1234567890.0, 12345678901234567890.0)", "1 1.1 1234567890 1.23456789012346E+19", nil, "format-floats"}, } diff --git a/pkg/exprparser/interpreter.go b/pkg/exprparser/interpreter.go index 31a95fe6..083c8f17 100644 --- a/pkg/exprparser/interpreter.go +++ b/pkg/exprparser/interpreter.go @@ -86,7 +86,7 @@ func (impl *interperterImpl) Evaluate(input string, defaultStatusCheck DefaultSt parser := actionlint.NewExprParser() exprNode, err := parser.Parse(actionlint.NewExprLexer(input + "}}")) if err != nil { - return nil, fmt.Errorf("Failed to parse: %s", err.Message) + return nil, fmt.Errorf("failed to parse: %s", err.Message) } if defaultStatusCheck != DefaultStatusCheckNone { @@ -146,7 +146,7 @@ func (impl *interperterImpl) evaluateNode(exprNode actionlint.ExprNode) (interfa case *actionlint.FuncCallNode: return impl.evaluateFuncCall(node) default: - return nil, fmt.Errorf("Fatal error! Unknown node type: %s node: %+v", reflect.TypeOf(exprNode), exprNode) + return nil, fmt.Errorf("fatal error! Unknown node type: %s node: %+v", reflect.TypeOf(exprNode), exprNode) } } @@ -160,7 +160,7 @@ func (impl *interperterImpl) evaluateVariable(variableNode *actionlint.VariableN return impl.env.Job, nil case "jobs": if impl.env.Jobs == nil { - return nil, fmt.Errorf("Unavailable context: jobs") + return nil, fmt.Errorf("unavailable context: jobs") } return impl.env.Jobs, nil case "steps": @@ -184,7 +184,7 @@ func (impl *interperterImpl) evaluateVariable(variableNode *actionlint.VariableN case "nan": return math.NaN(), nil default: - return nil, fmt.Errorf("Unavailable context: %s", variableNode.Name) + return nil, fmt.Errorf("unavailable context: %s", variableNode.Name) } } @@ -414,10 +414,10 @@ func (impl *interperterImpl) compareValues(leftValue reflect.Value, rightValue r } // not possible situation - params are converted to the same type in code above - return nil, fmt.Errorf("Compare params of Invalid type: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind()) + return nil, fmt.Errorf("compare params of Invalid type: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind()) default: - return nil, fmt.Errorf("Compare not implemented for types: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind()) + return nil, fmt.Errorf("compare not implemented for types: left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind()) } } @@ -505,7 +505,7 @@ func (impl *interperterImpl) compareString(left string, right string, kind actio case actionlint.CompareOpNodeKindNotEq: return left != right, nil default: - return false, fmt.Errorf("TODO: not implemented to compare '%+v'", kind) + return false, fmt.Errorf("todo: not implemented to compare '%+v'", kind) } } @@ -524,7 +524,7 @@ func (impl *interperterImpl) compareNumber(left float64, right float64, kind act case actionlint.CompareOpNodeKindNotEq: return left != right, nil default: - return false, fmt.Errorf("TODO: not implemented to compare '%+v'", kind) + return false, fmt.Errorf("todo: not implemented to compare '%+v'", kind) } } @@ -604,7 +604,7 @@ func (impl *interperterImpl) evaluateLogicalCompare(compareNode *actionlint.Logi return impl.getSafeValue(rightValue), nil } - return nil, fmt.Errorf("Unable to compare incompatibles types '%s' and '%s'", leftValue.Kind(), rightValue.Kind()) + return nil, fmt.Errorf("unable to compare incompatibles types '%s' and '%s'", leftValue.Kind(), rightValue.Kind()) } //nolint:gocyclo @@ -652,7 +652,7 @@ func (impl *interperterImpl) evaluateFuncCall(funcCallNode *actionlint.FuncCallN if impl.config.Context == "step" { return impl.stepSuccess() } - return nil, fmt.Errorf("Context '%s' must be one of 'job' or 'step'", impl.config.Context) + return nil, fmt.Errorf("context '%s' must be one of 'job' or 'step'", impl.config.Context) case "failure": if impl.config.Context == "job" { return impl.jobFailure() @@ -660,10 +660,10 @@ func (impl *interperterImpl) evaluateFuncCall(funcCallNode *actionlint.FuncCallN if impl.config.Context == "step" { return impl.stepFailure() } - return nil, fmt.Errorf("Context '%s' must be one of 'job' or 'step'", impl.config.Context) + return nil, fmt.Errorf("context '%s' must be one of 'job' or 'step'", impl.config.Context) case "cancelled": return impl.cancelled() default: - return nil, fmt.Errorf("TODO: '%s' not implemented", funcCallNode.Callee) + return nil, fmt.Errorf("todo: '%s' not implemented", funcCallNode.Callee) } } diff --git a/pkg/exprparser/interpreter_test.go b/pkg/exprparser/interpreter_test.go index 5473fa74..9db1713a 100644 --- a/pkg/exprparser/interpreter_test.go +++ b/pkg/exprparser/interpreter_test.go @@ -73,7 +73,7 @@ func TestOperators(t *testing.T) { {"github.event.commits[0].author.username1 != github.event.commits[1].author.username", true, "property-comparison2", ""}, {"github.event.commits[0].author.username != github.event.commits[1].author.username1", true, "property-comparison3", ""}, {"github.event.commits[0].author.username1 != github.event.commits[1].author.username2", true, "property-comparison4", ""}, - {"secrets != env", nil, "property-comparison5", "Compare not implemented for types: left: map, right: map"}, + {"secrets != env", nil, "property-comparison5", "compare not implemented for types: left: map, right: map"}, } env := &EvaluationEnvironment{ diff --git a/pkg/filecollector/file_collector_test.go b/pkg/filecollector/file_collector_test.go index 60a8d4dd..45ec6594 100644 --- a/pkg/filecollector/file_collector_test.go +++ b/pkg/filecollector/file_collector_test.go @@ -57,7 +57,7 @@ func (mfs *memoryFs) Walk(root string, fn filepath.WalkFunc) error { } func (mfs *memoryFs) OpenGitIndex(path string) (*index.Index, error) { - f, _ := mfs.Filesystem.Chroot(filepath.Join(path, ".git")) + f, _ := mfs.Chroot(filepath.Join(path, ".git")) storage := filesystem.NewStorage(f, cache.NewObjectLRUDefault()) i, err := storage.Index() if err != nil { diff --git a/pkg/model/action.go b/pkg/model/action.go index ee937430..c8fdea2c 100644 --- a/pkg/model/action.go +++ b/pkg/model/action.go @@ -24,7 +24,7 @@ func (a *ActionRunsUsing) UnmarshalYAML(unmarshal func(interface{}) error) error case ActionRunsUsingNode20, ActionRunsUsingNode16, ActionRunsUsingNode12, ActionRunsUsingDocker, ActionRunsUsingComposite: *a = format default: - return fmt.Errorf("The runs.using key in action.yml must be one of: %v, got %s", []string{ + return fmt.Errorf("the runs.using key in action.yml must be one of: %v, got %s", []string{ ActionRunsUsingComposite, ActionRunsUsingDocker, ActionRunsUsingNode12, diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go index 349f357f..7a93c379 100644 --- a/pkg/model/workflow.go +++ b/pkg/model/workflow.go @@ -74,7 +74,7 @@ func (w *Workflow) UnmarshalYAML(node *yaml.Node) error { Definition: "workflow-root", Schema: schema.GetWorkflowSchema(), }).UnmarshalYAML(node); err != nil { - return errors.Join(err, fmt.Errorf("Actions YAML Schema Validation Error detected:\nFor more information, see: https://actions-oss.github.io/act-docs/usage/schema.html")) + return errors.Join(err, fmt.Errorf("actions YAML Schema Validation Error detected:\nFor more information, see: https://actions-oss.github.io/act-docs/usage/schema.html")) } type WorkflowDefault Workflow return node.Decode((*WorkflowDefault)(w)) @@ -88,7 +88,7 @@ func (w *WorkflowStrict) UnmarshalYAML(node *yaml.Node) error { Definition: "workflow-root-strict", Schema: schema.GetWorkflowSchema(), }).UnmarshalYAML(node); err != nil { - return errors.Join(err, fmt.Errorf("Actions YAML Strict Schema Validation Error detected:\nFor more information, see: https://nektosact.com/usage/schema.html")) + return errors.Join(err, fmt.Errorf("actions YAML Strict Schema Validation Error detected:\nFor more information, see: https://nektosact.com/usage/schema.html")) } type WorkflowDefault Workflow return node.Decode((*WorkflowDefault)(w)) @@ -235,7 +235,7 @@ func (s Strategy) GetMaxParallel() int { if s.MaxParallelString != "" { var err error if maxParallel, err = strconv.Atoi(s.MaxParallelString); err != nil { - log.Errorf("Failed to parse 'max-parallel' option: %v", err) + log.Errorf("failed to parse 'max-parallel' option: %v", err) } } return maxParallel @@ -249,7 +249,7 @@ func (s Strategy) GetFailFast() bool { if s.FailFastString != "" { var err error if failFast, err = strconv.ParseBool(s.FailFastString); err != nil { - log.Errorf("Failed to parse 'fail-fast' option: %v", err) + log.Errorf("failed to parse 'fail-fast' option: %v", err) } } return failFast diff --git a/pkg/runner/action.go b/pkg/runner/action.go index fa2707e4..e004aafc 100644 --- a/pkg/runner/action.go +++ b/pkg/runner/action.go @@ -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, diff --git a/pkg/runner/action_cache.go b/pkg/runner/action_cache.go index a028e7c9..3baf9c76 100644 --- a/pkg/runner/action_cache.go +++ b/pkg/runner/action_cache.go @@ -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 diff --git a/pkg/runner/container_mock_test.go b/pkg/runner/container_mock_test.go index 7aedae1f..098ab697 100644 --- a/pkg/runner/container_mock_test.go +++ b/pkg/runner/container_mock_test.go @@ -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 diff --git a/pkg/runner/expression.go b/pkg/runner/expression.go index d1673f94..2cbfe518 100644 --- a/pkg/runner/expression.go +++ b/pkg/runner/expression.go @@ -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 "" } diff --git a/pkg/runner/job_executor.go b/pkg/runner/job_executor.go index f423df4f..509a1997 100644 --- a/pkg/runner/job_executor.go +++ b/pkg/runner/job_executor.go @@ -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 diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index a8eb0d30..5b0864a0 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -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) } } diff --git a/pkg/runner/run_context_other.go b/pkg/runner/run_context_other.go index 441a3be4..5f605220 100644 --- a/pkg/runner/run_context_other.go +++ b/pkg/runner/run_context_other.go @@ -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") } } diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 2cfeee8b..37da7dd3 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -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()) } } } diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go index 0b29020b..209c9c15 100644 --- a/pkg/runner/runner_test.go +++ b/pkg/runner/runner_test.go @@ -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{}) diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go index c2c9dfe9..8f9df270 100644 --- a/pkg/runner/step_action_remote.go +++ b/pkg/runner/step_action_remote.go @@ -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) diff --git a/pkg/runner/step_action_remote_test.go b/pkg/runner/step_action_remote_test.go index c81f8bc5..baea04f4 100644 --- a/pkg/runner/step_action_remote_test.go +++ b/pkg/runner/step_action_remote_test.go @@ -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) }) } } diff --git a/pkg/runner/step_factory.go b/pkg/runner/step_factory.go index 110c06c2..937871be 100644 --- a/pkg/runner/step_factory.go +++ b/pkg/runner/step_factory.go @@ -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) } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index a523e721..0d2dee77 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -142,15 +142,15 @@ func (s *Node) checkSingleExpression(exprNode actionlint.ExprNode) error { for _, v := range *funcs { if strings.EqualFold(funcCallNode.Callee, v.name) { if v.min > len(funcCallNode.Args) { - err = errors.Join(err, fmt.Errorf("Missing parameters for %s expected >= %v got %v", funcCallNode.Callee, v.min, len(funcCallNode.Args))) + err = errors.Join(err, fmt.Errorf("missing parameters for %s expected >= %v got %v", funcCallNode.Callee, v.min, len(funcCallNode.Args))) } if v.max < len(funcCallNode.Args) { - err = errors.Join(err, fmt.Errorf("Too many parameters for %s expected <= %v got %v", funcCallNode.Callee, v.max, len(funcCallNode.Args))) + err = errors.Join(err, fmt.Errorf("too many parameters for %s expected <= %v got %v", funcCallNode.Callee, v.max, len(funcCallNode.Args))) } return } } - err = errors.Join(err, fmt.Errorf("Unknown Function Call %s", funcCallNode.Callee)) + err = errors.Join(err, fmt.Errorf("unknown Function Call %s", funcCallNode.Callee)) } if varNode, ok := node.(*actionlint.VariableNode); entering && ok { for _, v := range s.Context { @@ -158,7 +158,7 @@ func (s *Node) checkSingleExpression(exprNode actionlint.ExprNode) error { return } } - err = errors.Join(err, fmt.Errorf("Unknown Variable Access %s", varNode.Name)) + err = errors.Join(err, fmt.Errorf("unknown Variable Access %s", varNode.Name)) } }) return err diff --git a/pkg/tart/environment_darwin.go b/pkg/tart/environment_darwin.go index 11386bd2..2cf5454e 100644 --- a/pkg/tart/environment_darwin.go +++ b/pkg/tart/environment_darwin.go @@ -126,11 +126,11 @@ func (e *Environment) Stop(ctx context.Context) error { } if err := vm.Stop(ctx); err != nil { - common.Logger(ctx).Errorf("Failed to stop VM: %v", err) + common.Logger(ctx).Errorf("failed to stop VM: %v", err) } if err := vm.Delete(ctx); err != nil { - common.Logger(ctx).Error("Failed to delete VM: %v", err) + common.Logger(ctx).Error("failed to delete VM: %v", err) return err }