diff --git a/act/artifactcache/handler.go b/act/artifactcache/handler.go index 50ffbd05..82585e62 100644 --- a/act/artifactcache/handler.go +++ b/act/artifactcache/handler.go @@ -739,7 +739,6 @@ const ( keepOld = 5 * time.Minute ) -//nolint:gocyclo // function handles many cases func (h *Handler) gcCache() { if h.gcing.Load() { return diff --git a/act/artifactcache/handler_test.go b/act/artifactcache/handler_test.go index 9c8a8a15..953a09ee 100644 --- a/act/artifactcache/handler_test.go +++ b/act/artifactcache/handler_test.go @@ -71,7 +71,10 @@ func TestHandler(t *testing.T) { require.NoError(t, handler.Close()) assert.Nil(t, handler.server) assert.Nil(t, handler.listener) - _, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, 1), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, 1), "", nil) + if err == nil { + resp.Body.Close() + } assert.Error(t, err) }) }() @@ -79,8 +82,9 @@ func TestHandler(t *testing.T) { t.Run("get not exist", func(t *testing.T) { key := strings.ToLower(t.Name()) version := "c19da02a2bd7e77277f1ac29ab45c09b7d46a4ee758284e26bb3045ad11d9d20" - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, key, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, key, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 204, resp.StatusCode) }) @@ -94,16 +98,18 @@ func TestHandler(t *testing.T) { }) t.Run("clean", func(t *testing.T) { - resp, err := testClient.Post(base+"/clean", "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/clean", "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) }) t.Run("reserve with bad request", func(t *testing.T) { body := []byte(`invalid json`) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) }) @@ -120,8 +126,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) require.NoError(t, json.NewDecoder(resp.Body).Decode(&first)) @@ -134,8 +141,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) require.NoError(t, json.NewDecoder(resp.Body).Decode(&second)) @@ -151,8 +159,9 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) }) @@ -162,8 +171,9 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) }) @@ -181,8 +191,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) got := struct { @@ -197,13 +208,15 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { @@ -212,8 +225,9 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) } }) @@ -232,8 +246,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) got := struct { @@ -248,24 +263,27 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes xx-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) } }) t.Run("commit with bad id", func(t *testing.T) { { - resp, err := testClient.Post(base+"/caches/invalid_id", "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches/invalid_id", "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) } }) t.Run("commit with not exist id", func(t *testing.T) { { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, 100), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, 100), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) } }) @@ -284,8 +302,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) got := struct { @@ -300,18 +319,21 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 400, resp.StatusCode) } }) @@ -330,8 +352,9 @@ func TestHandler(t *testing.T) { Size: 100, }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) got := struct { @@ -346,32 +369,37 @@ func TestHandler(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-59/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 500, resp.StatusCode) } }) t.Run("get with bad id", func(t *testing.T) { - resp, err := testClient.Get(base + "/artifacts/invalid_id") //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(base + "/artifacts/invalid_id") require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 400, resp.StatusCode) }) t.Run("get with not exist id", func(t *testing.T) { - resp, err := testClient.Get(signArtifactURL(handler, 100)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(signArtifactURL(handler, 100)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 404, resp.StatusCode) }) t.Run("get with not exist id", func(t *testing.T) { - resp, err := testClient.Get(signArtifactURL(handler, 100)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(signArtifactURL(handler, 100)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 404, resp.StatusCode) }) @@ -401,8 +429,9 @@ func TestHandler(t *testing.T) { key + "_a", }, ",") - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) /* @@ -421,8 +450,9 @@ func TestHandler(t *testing.T) { assert.Equal(t, "hit", got.Result) assert.Equal(t, keys[except], got.CacheKey) - contentResp, err := testClient.Get(got.ArchiveLocation) //nolint:bodyclose // pre-existing issue from nektos/act + contentResp, err := testClient.Get(got.ArchiveLocation) require.NoError(t, err) + defer contentResp.Body.Close() require.Equal(t, 200, contentResp.StatusCode) content, err := io.ReadAll(contentResp.Body) require.NoError(t, err) @@ -439,8 +469,9 @@ func TestHandler(t *testing.T) { { reqKey := key + "_aBc" - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKey, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKey, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) got := struct { Result string `json:"result"` @@ -478,8 +509,9 @@ func TestHandler(t *testing.T) { key + "_a_b", }, ",") - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) /* @@ -496,8 +528,9 @@ func TestHandler(t *testing.T) { require.NoError(t, json.NewDecoder(resp.Body).Decode(&got)) assert.Equal(t, keys[expect], got.CacheKey) - contentResp, err := testClient.Get(got.ArchiveLocation) //nolint:bodyclose // pre-existing issue from nektos/act + contentResp, err := testClient.Get(got.ArchiveLocation) require.NoError(t, err) + defer contentResp.Body.Close() require.Equal(t, 200, contentResp.StatusCode) content, err := io.ReadAll(contentResp.Body) require.NoError(t, err) @@ -530,8 +563,9 @@ func TestHandler(t *testing.T) { key + "_a_b", }, ",") - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, reqKeys, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) /* @@ -549,8 +583,9 @@ func TestHandler(t *testing.T) { require.NoError(t, json.NewDecoder(resp.Body).Decode(&got)) assert.Equal(t, keys[expect], got.CacheKey) - contentResp, err := testClient.Get(got.ArchiveLocation) //nolint:bodyclose // pre-existing issue from nektos/act + contentResp, err := testClient.Get(got.ArchiveLocation) require.NoError(t, err) + defer contentResp.Body.Close() require.Equal(t, 200, contentResp.StatusCode) content, err := io.ReadAll(contentResp.Body) require.NoError(t, err) @@ -567,8 +602,9 @@ func uploadCacheNormally(t *testing.T, base, key, version string, content []byte Size: int64(len(content)), }) require.NoError(t, err) - resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(base+"/caches", "application/json", bytes.NewReader(body)) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) got := struct { @@ -583,19 +619,22 @@ func uploadCacheNormally(t *testing.T, base, key, version string, content []byte require.NoError(t, err) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Content-Range", "bytes 0-99/*") - resp, err := testClient.Do(req) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Do(req) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } { - resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Post(fmt.Sprintf("%s/caches/%d", base, id), "", nil) require.NoError(t, err) + defer resp.Body.Close() assert.Equal(t, 200, resp.StatusCode) } var archiveLocation string { - resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, key, version)) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, key, version)) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) got := struct { Result string `json:"result"` @@ -608,8 +647,9 @@ func uploadCacheNormally(t *testing.T, base, key, version string, content []byte archiveLocation = got.ArchiveLocation } { - resp, err := testClient.Get(archiveLocation) //nolint:bodyclose // pre-existing issue from nektos/act + resp, err := testClient.Get(archiveLocation) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, 200, resp.StatusCode) got, err := io.ReadAll(resp.Body) require.NoError(t, err) diff --git a/act/artifacts/server_test.go b/act/artifacts/server_test.go index b240308c..0fd20c06 100644 --- a/act/artifacts/server_test.go +++ b/act/artifacts/server_test.go @@ -202,7 +202,7 @@ func TestListArtifactContainer(t *testing.T) { panic(err) } - assert.Equal(1, len(response.Value)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Len(response.Value, 1) assert.Equal("some/file", response.Value[0].Path) assert.Equal("file", response.Value[0].ItemType) assert.Equal("http://localhost/artifact/1/some/file/.", response.Value[0].ContentLocation) @@ -283,7 +283,7 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) { } workdir, err := filepath.Abs(tjfi.workdir) - assert.Nil(t, err, workdir) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, workdir) //nolint:testifylint // pre-existing issue from nektos/act fullWorkflowPath := filepath.Join(workdir, tjfi.workflowPath) runnerConfig := &runner.Config{ Workdir: workdir, @@ -299,16 +299,16 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) { } runner, err := runner.New(runnerConfig) - assert.Nil(t, err, tjfi.workflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, tjfi.workflowPath) //nolint:testifylint // pre-existing issue from nektos/act planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true) - assert.Nil(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act plan, err := planner.PlanEvent(tjfi.eventName) if err == nil { err = runner.NewPlanExecutor(plan)(ctx) if tjfi.errorMessage == "" { - assert.Nil(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act } else { assert.Error(t, err, tjfi.errorMessage) //nolint:testifylint // pre-existing issue from nektos/act } diff --git a/act/common/cartesian_test.go b/act/common/cartesian_test.go index ff0ca8cc..91f748de 100644 --- a/act/common/cartesian_test.go +++ b/act/common/cartesian_test.go @@ -35,9 +35,9 @@ func TestCartesianProduct(t *testing.T) { "baz": {false, true}, } output = CartesianProduct(input) - assert.Len(output, 0) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(output) input = map[string][]any{} output = CartesianProduct(input) - assert.Len(output, 0) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(output) } diff --git a/act/common/executor_test.go b/act/common/executor_test.go index e4b37067..b0771863 100644 --- a/act/common/executor_test.go +++ b/act/common/executor_test.go @@ -21,11 +21,11 @@ func TestNewWorkflow(t *testing.T) { // empty emptyWorkflow := NewPipelineExecutor() - assert.Nil(emptyWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(emptyWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act // error case errorWorkflow := NewErrorExecutor(errors.New("test error")) - assert.NotNil(errorWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Error(errorWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act // multiple success case runcount := 0 @@ -38,7 +38,7 @@ func TestNewWorkflow(t *testing.T) { runcount++ return nil }) - assert.Nil(successWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(successWorkflow(ctx)) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(2, runcount) } @@ -60,7 +60,7 @@ func TestNewConditionalExecutor(t *testing.T) { return nil })(ctx) - assert.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(0, trueCount) assert.Equal(1, falseCount) @@ -74,7 +74,7 @@ func TestNewConditionalExecutor(t *testing.T) { return nil })(ctx) - assert.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(1, trueCount) assert.Equal(1, falseCount) } @@ -105,7 +105,7 @@ func TestNewParallelExecutor(t *testing.T) { assert.Equal(int32(3), count.Load(), "should run all 3 executors") assert.Equal(int32(2), maxCount.Load(), "should run at most 2 executors in parallel") - assert.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // Reset to test running the executor with 0 parallelism count.Store(0) @@ -116,7 +116,7 @@ func TestNewParallelExecutor(t *testing.T) { assert.Equal(int32(3), count.Load(), "should run all 3 executors") assert.Equal(int32(1), maxCount.Load(), "should run at most 1 executors in parallel") - assert.Nil(errSingle) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(errSingle) } func TestNewParallelExecutorFailed(t *testing.T) { diff --git a/act/common/git/git.go b/act/common/git/git.go index cc33183a..de4c9b54 100644 --- a/act/common/git/git.go +++ b/act/common/git/git.go @@ -302,8 +302,6 @@ func gitOptions(token string) (fetchOptions git.FetchOptions, pullOptions git.Pu } // NewGitCloneExecutor creates an executor to clone git repos -// -//nolint:gocyclo // function handles many cases func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { return func(ctx context.Context) error { logger := common.Logger(ctx) diff --git a/act/container/docker_cli.go b/act/container/docker_cli.go index ca4b8d45..7beb8e1f 100644 --- a/act/container/docker_cli.go +++ b/act/container/docker_cli.go @@ -324,8 +324,6 @@ type containerConfig struct { // parse parses the args for the specified command and generates a Config, // a HostConfig and returns them with the specified command. // If the specified args are not valid, it will return an error. -// -//nolint:gocyclo // function handles many cases func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*containerConfig, error) { var ( attachStdin = copts.attach.Get("stdin") diff --git a/act/container/docker_cli_test.go b/act/container/docker_cli_test.go index 169a6be0..30aa4d6b 100644 --- a/act/container/docker_cli_test.go +++ b/act/container/docker_cli_test.go @@ -194,7 +194,6 @@ func TestParseRunWithInvalidArgs(t *testing.T) { } } -//nolint:gocyclo // function handles many cases func TestParseWithVolumes(t *testing.T) { // A single volume arr, tryit := setupPlatformVolume([]string{`/tmp`}, []string{`c:\tmp`}) @@ -632,7 +631,7 @@ func TestParseModes(t *testing.T) { } // uts ko - _, _, _, err = parseRun([]string{"--uts=container:", "img", "cmd"}) //nolint:dogsled // ignoring multiple returns in test helpers + _, _, _, err = parseRun([]string{"--uts=container:", "img", "cmd"}) assert.ErrorContains(t, err, "--uts: invalid UTS mode") // uts ok @@ -693,7 +692,7 @@ func TestParseRestartPolicy(t *testing.T) { func TestParseRestartPolicyAutoRemove(t *testing.T) { expected := "Conflicting options: --restart and --rm" - _, _, _, err := parseRun([]string{"--rm", "--restart=always", "img", "cmd"}) //nolint:dogsled // ignoring multiple returns in test helpers + _, _, _, err := parseRun([]string{"--rm", "--restart=always", "img", "cmd"}) if err == nil || err.Error() != expected { t.Fatalf("Expected error %v, but got none", expected) } diff --git a/act/container/docker_images_test.go b/act/container/docker_images_test.go index 5d4e496b..06e4ba1d 100644 --- a/act/container/docker_images_test.go +++ b/act/container/docker_images_test.go @@ -29,17 +29,17 @@ func TestImageExistsLocally(t *testing.T) { // Test if image exists with specific tag invalidImageTag, err := ImageExistsLocally(ctx, "library/alpine:this-random-tag-will-never-exist", "linux/amd64") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, false, invalidImageTag) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.False(t, invalidImageTag) // Test if image exists with specific architecture (image platform) invalidImagePlatform, err := ImageExistsLocally(ctx, "alpine:latest", "windows/amd64") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, false, invalidImagePlatform) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.False(t, invalidImagePlatform) // pull an image cli, err := client.NewClientWithOpts(client.FromEnv) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act cli.NegotiateAPIVersion(context.Background()) // Chose alpine latest because it's so small @@ -47,25 +47,25 @@ func TestImageExistsLocally(t *testing.T) { readerDefault, err := cli.ImagePull(ctx, "node:16-buster-slim", types.ImagePullOptions{ Platform: "linux/amd64", }) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act defer readerDefault.Close() _, err = io.ReadAll(readerDefault) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act imageDefaultArchExists, err := ImageExistsLocally(ctx, "node:16-buster-slim", "linux/amd64") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, true, imageDefaultArchExists) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, imageDefaultArchExists) // Validate if another architecture platform can be pulled readerArm64, err := cli.ImagePull(ctx, "node:16-buster-slim", types.ImagePullOptions{ Platform: "linux/arm64", }) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act defer readerArm64.Close() _, err = io.ReadAll(readerArm64) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act imageArm64Exists, err := ImageExistsLocally(ctx, "node:16-buster-slim", "linux/arm64") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, true, imageArm64Exists) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, imageArm64Exists) } diff --git a/act/container/docker_pull_test.go b/act/container/docker_pull_test.go index 672d1469..4a28c7fb 100644 --- a/act/container/docker_pull_test.go +++ b/act/container/docker_pull_test.go @@ -43,7 +43,7 @@ func TestGetImagePullOptions(t *testing.T) { config.SetDir("/non-existent/docker") options, err := getImagePullOptions(ctx, NewDockerPullExecutorInput{}) - assert.Nil(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, "", options.RegistryAuth, "RegistryAuth should be empty if no username or password is set") //nolint:testifylint // pre-existing issue from nektos/act options, err = getImagePullOptions(ctx, NewDockerPullExecutorInput{ @@ -51,7 +51,7 @@ func TestGetImagePullOptions(t *testing.T) { Username: "username", Password: "password", }) - assert.Nil(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, "eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZCJ9", options.RegistryAuth, "Username and Password should be provided") config.SetDir("testdata/docker-pull-options") @@ -59,6 +59,6 @@ func TestGetImagePullOptions(t *testing.T) { options, err = getImagePullOptions(ctx, NewDockerPullExecutorInput{ Image: "nektos/act", }) - assert.Nil(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, "Failed to create ImagePullOptions") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, "eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZFxuIiwic2VydmVyYWRkcmVzcyI6Imh0dHBzOi8vaW5kZXguZG9ja2VyLmlvL3YxLyJ9", options.RegistryAuth, "RegistryAuth should be taken from local docker config") } diff --git a/act/container/docker_socket_test.go b/act/container/docker_socket_test.go index 3b56c08d..a378dd32 100644 --- a/act/container/docker_socket_test.go +++ b/act/container/docker_socket_test.go @@ -29,7 +29,7 @@ func TestGetSocketAndHostWithSocket(t *testing.T) { ret, err := GetSocketAndHost(socketURI) // Assert - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{socketURI, dockerHost}, ret) } @@ -42,7 +42,7 @@ func TestGetSocketAndHostNoSocket(t *testing.T) { ret, err := GetSocketAndHost("") // Assert - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{dockerHost, dockerHost}, ret) } @@ -57,8 +57,8 @@ func TestGetSocketAndHostOnlySocket(t *testing.T) { ret, err := GetSocketAndHost(socketURI) // Assert - assert.NoError(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, true, defaultSocketFound, "Expected to find default socket") //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, defaultSocketFound, "Expected to find default socket") assert.Equal(t, socketURI, ret.Socket, "Expected socket to match common location") assert.Equal(t, defaultSocket, ret.Host, "Expected ret.Host to match default socket location") } @@ -73,7 +73,7 @@ func TestGetSocketAndHostDontMount(t *testing.T) { ret, err := GetSocketAndHost("-") // Assert - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{"-", dockerHost}, ret) } @@ -87,8 +87,8 @@ func TestGetSocketAndHostNoHostNoSocket(t *testing.T) { ret, err := GetSocketAndHost("") // Assert - assert.Equal(t, true, found, "Expected a default socket to be found") //nolint:testifylint // pre-existing issue from nektos/act - assert.Nil(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, found, "Expected a default socket to be found") + assert.NoError(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{defaultSocket, defaultSocket}, ret, "Expected to match default socket location") } @@ -112,8 +112,8 @@ func TestGetSocketAndHostNoHostNoSocketDefaultLocation(t *testing.T) { // Assert assert.Equal(t, unixSocket, defaultSocket, "Expected default socket to match common socket location") - assert.Equal(t, true, found, "Expected default socket to be found") //nolint:testifylint // pre-existing issue from nektos/act - assert.Nil(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, found, "Expected default socket to be found") + assert.NoError(t, err, "Expected no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{unixSocket, unixSocket}, ret, "Expected to match default socket location") } @@ -128,7 +128,7 @@ func TestGetSocketAndHostNoHostInvalidSocket(t *testing.T) { ret, err := GetSocketAndHost(mySocket) // Assert - assert.Equal(t, false, found, "Expected no default socket to be found") //nolint:testifylint // pre-existing issue from nektos/act + assert.False(t, found, "Expected no default socket to be found") assert.Equal(t, "", defaultSocket, "Expected no default socket to be found") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, SocketAndHost{}, ret, "Expected to match default socket location") assert.Error(t, err, "Expected an error in invalid state") @@ -147,8 +147,8 @@ func TestGetSocketAndHostOnlySocketValidButUnusualLocation(t *testing.T) { // Assert // Default socket locations assert.Equal(t, "", defaultSocket, "Expect default socket location to be empty") //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, false, found, "Expected no default socket to be found") //nolint:testifylint // pre-existing issue from nektos/act + assert.False(t, found, "Expected no default socket to be found") // Sane default - assert.Nil(t, err, "Expect no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, "Expect no error from GetSocketAndHost") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, socketURI, ret.Host, "Expect host to default to unusual socket") } diff --git a/act/exprparser/functions_test.go b/act/exprparser/functions_test.go index c281f73f..92e7e011 100644 --- a/act/exprparser/functions_test.go +++ b/act/exprparser/functions_test.go @@ -43,7 +43,7 @@ func TestFunctionContains(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -72,7 +72,7 @@ func TestFunctionStartsWith(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -101,7 +101,7 @@ func TestFunctionEndsWith(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -128,7 +128,7 @@ func TestFunctionJoin(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -154,7 +154,7 @@ func TestFunctionToJSON(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -177,7 +177,7 @@ func TestFunctionFromJSON(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -205,9 +205,9 @@ func TestFunctionHashFiles(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { workdir, err := filepath.Abs("testdata") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act output, err := NewInterpeter(env, Config{WorkingDir: workdir}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -248,7 +248,7 @@ func TestFunctionFormat(t *testing.T) { if tt.error != nil { assert.Equal(t, tt.error, err.Error()) } else { - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) } }) diff --git a/act/exprparser/interpreter.go b/act/exprparser/interpreter.go index 8a97ccff..127c3867 100644 --- a/act/exprparser/interpreter.go +++ b/act/exprparser/interpreter.go @@ -156,7 +156,6 @@ func (impl *interperterImpl) evaluateNode(exprNode actionlint.ExprNode) (any, er } } -//nolint:gocyclo // function handles many cases func (impl *interperterImpl) evaluateVariable(variableNode *actionlint.VariableNode) (any, error) { switch strings.ToLower(variableNode.Name) { case "github": @@ -584,7 +583,6 @@ func (impl *interperterImpl) evaluateLogicalCompare(compareNode *actionlint.Logi return nil, fmt.Errorf("Unable to compare incompatibles types '%s' and '%s'", leftValue.Kind(), rightValue.Kind()) } -//nolint:gocyclo // function handles many cases func (impl *interperterImpl) evaluateFuncCall(funcCallNode *actionlint.FuncCallNode) (any, error) { args := make([]reflect.Value, 0) diff --git a/act/exprparser/interpreter_test.go b/act/exprparser/interpreter_test.go index d930321f..87e3b070 100644 --- a/act/exprparser/interpreter_test.go +++ b/act/exprparser/interpreter_test.go @@ -35,7 +35,7 @@ func TestLiterals(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -105,10 +105,10 @@ func TestOperators(t *testing.T) { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) if tt.error != "" { - assert.NotNil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.Error(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.error, err.Error()) } else { - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act } assert.Equal(t, tt.expected, output) @@ -157,7 +157,7 @@ func TestOperatorsCompare(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) @@ -520,7 +520,7 @@ func TestOperatorsBooleanEvaluation(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act if expected, ok := tt.expected.(float64); ok && math.IsNaN(expected) { assert.True(t, math.IsNaN(output.(float64))) @@ -624,7 +624,7 @@ func TestContexts(t *testing.T) { for _, tt := range table { t.Run(tt.name, func(t *testing.T) { output, err := NewInterpeter(env, Config{}).Evaluate(tt.input, DefaultStatusCheckNone) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, output) }) diff --git a/act/filecollector/file_collector.go b/act/filecollector/file_collector.go index dd84549d..6b3e6813 100644 --- a/act/filecollector/file_collector.go +++ b/act/filecollector/file_collector.go @@ -128,7 +128,6 @@ func (*DefaultFs) Readlink(path string) (string, error) { return os.Readlink(path) } -//nolint:gocyclo // function handles many cases func (fc *FileCollector) CollectFiles(ctx context.Context, submodulePath []string) filepath.WalkFunc { i, _ := fc.Fs.OpenGitIndex(path.Join(fc.SrcPath, path.Join(submodulePath...))) return func(file string, fi os.FileInfo, err error) error { diff --git a/act/model/planner.go b/act/model/planner.go index 39bc588d..e09be245 100644 --- a/act/model/planner.go +++ b/act/model/planner.go @@ -61,8 +61,6 @@ type WorkflowFiles struct { } // NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories -// -//nolint:gocyclo // function handles many cases func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, error) { path, err := filepath.Abs(path) if err != nil { diff --git a/act/model/planner_test.go b/act/model/planner_test.go index 70e91052..515f904b 100644 --- a/act/model/planner_test.go +++ b/act/model/planner_test.go @@ -57,11 +57,11 @@ func TestWorkflow(t *testing.T) { // Check that an invalid job id returns error result, err := createStages(&workflow, "invalid_job_id") - assert.NotNil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.Error(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Nil(t, result) // Check that an valid job id returns non-error result, err = createStages(&workflow, "valid_job") - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, result) } diff --git a/act/model/workflow.go b/act/model/workflow.go index 7334049c..3fda3765 100644 --- a/act/model/workflow.go +++ b/act/model/workflow.go @@ -440,8 +440,6 @@ func (j *Job) Matrix() map[string][]any { // GetMatrixes returns the matrix cross product // It skips includes and hard fails excludes for non-existing keys -// -//nolint:gocyclo // function handles many cases func (j *Job) GetMatrixes() ([]map[string]any, error) { matrixes := make([]map[string]any, 0) if j.Strategy != nil { diff --git a/act/model/workflow_test.go b/act/model/workflow_test.go index 21f55583..9b4f173f 100644 --- a/act/model/workflow_test.go +++ b/act/model/workflow_test.go @@ -56,7 +56,7 @@ jobs: assert.NoError(t, err, "read workflow should succeed") //nolint:testifylint // pre-existing issue from nektos/act newSchedules = workflow.OnSchedule() - assert.Len(t, newSchedules, 0) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, newSchedules) yaml = ` name: local-action-docker-url @@ -74,7 +74,7 @@ jobs: assert.NoError(t, err, "read workflow should succeed") //nolint:testifylint // pre-existing issue from nektos/act newSchedules = workflow.OnSchedule() - assert.Len(t, newSchedules, 0) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, newSchedules) yaml = ` name: local-action-docker-url @@ -91,7 +91,7 @@ jobs: assert.NoError(t, err, "read workflow should succeed") //nolint:testifylint // pre-existing issue from nektos/act newSchedules = workflow.OnSchedule() - assert.Len(t, newSchedules, 0) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, newSchedules) } func TestReadWorkflow_StringEvent(t *testing.T) { @@ -870,7 +870,7 @@ jobs: assert.Nil(t, matrix, "matrix should be nil for jobs without strategy") } else { assert.NotNil(t, matrix, "matrix should not be nil") - assert.Equal(t, tt.wantLen, len(matrix), "matrix should have expected number of keys") //nolint:testifylint // pre-existing issue from nektos/act + assert.Len(t, matrix, tt.wantLen, "matrix should have expected number of keys") if tt.checkFn != nil { tt.checkFn(t, matrix) } diff --git a/act/runner/action.go b/act/runner/action.go index 1be16c70..bb85b929 100644 --- a/act/runner/action.go +++ b/act/runner/action.go @@ -265,8 +265,6 @@ func removeGitIgnore(ctx context.Context, directory string) error { } // TODO: break out parts of function to reduce complexicity -// -//nolint:gocyclo // function handles many cases func execAsDocker(ctx context.Context, step actionStep, actionName, basedir string, localAction bool) error { logger := common.Logger(ctx) rc := step.getRunContext() diff --git a/act/runner/action_test.go b/act/runner/action_test.go index d2a416df..1191edde 100644 --- a/act/runner/action_test.go +++ b/act/runner/action_test.go @@ -137,7 +137,7 @@ runs: action, err := readActionImpl(context.Background(), tt.step, "actionDir", "actionPath", readFile, writeFile) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.expected, action) closerMock.AssertExpectations(t) @@ -247,7 +247,7 @@ func TestActionRunner(t *testing.T) { err := runActionImpl(tt.step, "dir", newRemoteAction("org/repo/path@ref"))(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act cm.AssertExpectations(t) }) } diff --git a/act/runner/expression.go b/act/runner/expression.go index a5e4e7d9..3e6bd7d6 100644 --- a/act/runner/expression.go +++ b/act/runner/expression.go @@ -405,7 +405,6 @@ func escapeFormatString(in string) string { return strings.ReplaceAll(strings.ReplaceAll(in, "{", "{{"), "}", "}}") } -//nolint:gocyclo // function handles many cases func rewriteSubExpression(ctx context.Context, in string, forceFormat bool) (string, error) { //nolint:unparam // pre-existing issue from nektos/act if !strings.Contains(in, "${{") || !strings.Contains(in, "}}") { return in, nil @@ -472,7 +471,6 @@ func rewriteSubExpression(ctx context.Context, in string, forceFormat bool) (str return out, nil } -//nolint:gocyclo // function handles many cases func getEvaluatorInputs(ctx context.Context, rc *RunContext, step step, ghc *model.GithubContext) map[string]any { inputs := map[string]any{} diff --git a/act/runner/job_executor.go b/act/runner/job_executor.go index 0487f2e8..05f9a590 100644 --- a/act/runner/job_executor.go +++ b/act/runner/job_executor.go @@ -24,7 +24,6 @@ type jobInfo interface { result(result string) } -//nolint:contextcheck,gocyclo // composes many step executors func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executor { steps := make([]common.Executor, 0) preSteps := make([]common.Executor, 0) @@ -157,7 +156,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo pipeline = append(pipeline, steps...) return common.NewPipelineExecutor(info.startContainer(), common.NewPipelineExecutor(pipeline...). - Finally(func(ctx context.Context) error { //nolint:contextcheck // intentionally detaches from canceled parent + Finally(func(ctx context.Context) error { var cancel context.CancelFunc if ctx.Err() == context.Canceled { // in case of an aborted run, we still should execute the diff --git a/act/runner/job_executor_test.go b/act/runner/job_executor_test.go index ca2e5406..d5f0dbe1 100644 --- a/act/runner/job_executor_test.go +++ b/act/runner/job_executor_test.go @@ -331,7 +331,7 @@ func TestNewJobExecutor(t *testing.T) { executor := newJobExecutor(jim, sfm, rc) err := executor(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, tt.executedSteps, executorOrder) jim.AssertExpectations(t) diff --git a/act/runner/max_parallel_test.go b/act/runner/max_parallel_test.go index c560cb2c..684cf707 100644 --- a/act/runner/max_parallel_test.go +++ b/act/runner/max_parallel_test.go @@ -60,7 +60,7 @@ func TestMaxParallelStrategy(t *testing.T) { matrixes, err := job.GetMatrixes() assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, matrixes) - assert.Equal(t, 5, len(matrixes)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Len(t, matrixes, 5) assert.Equal(t, tt.expectedMaxParallel, job.Strategy.MaxParallel) }) } diff --git a/act/runner/run_context.go b/act/runner/run_context.go index 6db821de..89f1cf49 100644 --- a/act/runner/run_context.go +++ b/act/runner/run_context.go @@ -259,7 +259,6 @@ func (rc *RunContext) startHostEnvironment() common.Executor { } } -//nolint:gocyclo // function handles many cases func (rc *RunContext) startJobContainer() common.Executor { return func(ctx context.Context) error { logger := common.Logger(ctx) @@ -808,7 +807,6 @@ func (rc *RunContext) getStepsContext() map[string]*model.StepResult { return rc.StepResults } -//nolint:gocyclo // function handles many cases func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext { logger := common.Logger(ctx) ghc := &model.GithubContext{ diff --git a/act/runner/run_context_test.go b/act/runner/run_context_test.go index b4a5dca9..9e9e7d2b 100644 --- a/act/runner/run_context_test.go +++ b/act/runner/run_context_test.go @@ -282,7 +282,7 @@ func TestGetGitHubContext(t *testing.T) { log.SetLevel(log.DebugLevel) cwd, err := os.Getwd() - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act rc := &RunContext{ Config: &Config{ diff --git a/act/runner/runner.go b/act/runner/runner.go index 6389f53a..7c37576f 100644 --- a/act/runner/runner.go +++ b/act/runner/runner.go @@ -137,8 +137,6 @@ func (runner *runnerImpl) configure() (Runner, error) { } // NewPlanExecutor ... -// -//nolint:gocyclo // function handles many cases func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor { maxJobNameLen := 0 diff --git a/act/runner/runner_test.go b/act/runner/runner_test.go index 6eabca86..4014e11f 100644 --- a/act/runner/runner_test.go +++ b/act/runner/runner_test.go @@ -87,7 +87,7 @@ func TestGraphMissingEvent(t *testing.T) { plan, err := planner.PlanEvent("push") assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, plan) - assert.Equal(t, 0, len(plan.Stages)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, plan.Stages) assert.Contains(t, buf.String(), "no events found for workflow: no-event.yml") log.SetOutput(out) @@ -100,7 +100,7 @@ func TestGraphMissingFirst(t *testing.T) { plan, err := planner.PlanEvent("push") assert.EqualError(t, err, "unable to build dependency graph for no first (no-first.yml)") //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, plan) - assert.Equal(t, 0, len(plan.Stages)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, plan.Stages) } func TestGraphWithMissing(t *testing.T) { @@ -114,7 +114,7 @@ func TestGraphWithMissing(t *testing.T) { plan, err := planner.PlanEvent("push") assert.NotNil(t, plan) - assert.Equal(t, 0, len(plan.Stages)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, plan.Stages) assert.EqualError(t, err, "unable to build dependency graph for missing (missing.yml)") //nolint:testifylint // pre-existing issue from nektos/act assert.Contains(t, buf.String(), "unable to build dependency graph for missing (missing.yml)") log.SetOutput(out) @@ -134,7 +134,7 @@ func TestGraphWithSomeMissing(t *testing.T) { plan, err := planner.PlanAll() assert.Error(t, err, "unable to build dependency graph for no first (no-first.yml)") //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, plan) - assert.Equal(t, 1, len(plan.Stages)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Len(t, plan.Stages, 1) assert.Contains(t, buf.String(), "unable to build dependency graph for missing (missing.yml)") assert.Contains(t, buf.String(), "unable to build dependency graph for no first (no-first.yml)") log.SetOutput(out) @@ -159,7 +159,7 @@ func TestGraphEvent(t *testing.T) { plan, err = planner.PlanEvent("release") assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.NotNil(t, plan) - assert.Equal(t, 0, len(plan.Stages)) //nolint:testifylint // pre-existing issue from nektos/act + assert.Empty(t, plan.Stages) } type TestJobFileInfo struct { @@ -177,7 +177,7 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config log.SetLevel(logLevel) workdir, err := filepath.Abs(j.workdir) - assert.Nil(t, err, workdir) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, workdir) //nolint:testifylint // pre-existing issue from nektos/act fullWorkflowPath := filepath.Join(workdir, j.workflowPath) runnerConfig := &Config{ @@ -197,17 +197,17 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config } runner, err := New(runnerConfig) - assert.Nil(t, err, j.workflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, j.workflowPath) //nolint:testifylint // pre-existing issue from nektos/act planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true) - assert.Nil(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act plan, err := planner.PlanEvent(j.eventName) assert.True(t, (err == nil) != (plan == nil), "PlanEvent should return either a plan or an error") //nolint:testifylint // pre-existing issue from nektos/act if err == nil && plan != nil { err = runner.NewPlanExecutor(plan)(ctx) if j.errorMessage == "" { - assert.Nil(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err, fullWorkflowPath) //nolint:testifylint // pre-existing issue from nektos/act } else { assert.Error(t, err, j.errorMessage) //nolint:testifylint // pre-existing issue from nektos/act } diff --git a/act/runner/step_action_local_test.go b/act/runner/step_action_local_test.go index abf0ce20..823d8a66 100644 --- a/act/runner/step_action_local_test.go +++ b/act/runner/step_action_local_test.go @@ -97,10 +97,10 @@ func TestStepActionLocalTest(t *testing.T) { }) err := sal.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act err = sal.main()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act cm.AssertExpectations(t) salm.AssertExpectations(t) diff --git a/act/runner/step_action_remote.go b/act/runner/step_action_remote.go index 26410361..5a0e7c5a 100644 --- a/act/runner/step_action_remote.go +++ b/act/runner/step_action_remote.go @@ -39,7 +39,6 @@ type stepActionRemote struct { var stepActionRemoteNewCloneExecutor = git.NewGitCloneExecutor -//nolint:gocyclo // function handles many cases func (sar *stepActionRemote) prepareActionExecutor() common.Executor { return func(ctx context.Context) error { if sar.remoteAction != nil && sar.action != nil { diff --git a/act/runner/step_action_remote_test.go b/act/runner/step_action_remote_test.go index 52e97a78..42e852ba 100644 --- a/act/runner/step_action_remote_test.go +++ b/act/runner/step_action_remote_test.go @@ -272,8 +272,8 @@ func TestStepActionRemotePre(t *testing.T) { err := sar.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, true, clonedAction) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, clonedAction) sarm.AssertExpectations(t) }) @@ -343,8 +343,8 @@ func TestStepActionRemotePreThroughAction(t *testing.T) { err := sar.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act - assert.Equal(t, true, clonedAction) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.True(t, clonedAction) sarm.AssertExpectations(t) }) @@ -419,7 +419,7 @@ func TestStepActionRemotePreThroughActionToken(t *testing.T) { err := sar.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act // Verify that the clone was called (URL should be redirected to github.com) assert.True(t, actualURL != "", "Expected clone to be called") //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, "https://github.com/org/repo", actualURL, "URL should be redirected to github.com") diff --git a/act/runner/step_docker_test.go b/act/runner/step_docker_test.go index 59f8bad8..d73496a8 100644 --- a/act/runner/step_docker_test.go +++ b/act/runner/step_docker_test.go @@ -102,7 +102,7 @@ func TestStepDockerMain(t *testing.T) { cm.On("GetContainerArchive", ctx, "/var/run/act/workflow/pathcmd.txt").Return(io.NopCloser(&bytes.Buffer{}), nil) err := sd.main()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act assert.Equal(t, "node:14", input.Image) @@ -114,10 +114,10 @@ func TestStepDockerPrePost(t *testing.T) { sd := &stepDocker{} err := sd.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act err = sd.post()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) } func TestStepDockerNewStepContainerNetworkMode(t *testing.T) { diff --git a/act/runner/step_factory_test.go b/act/runner/step_factory_test.go index d770de64..349ddd9f 100644 --- a/act/runner/step_factory_test.go +++ b/act/runner/step_factory_test.go @@ -67,7 +67,7 @@ func TestStepFactoryNewStep(t *testing.T) { step, err := sf.newStep(tt.model, &RunContext{}) assert.True(t, tt.check((step))) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) }) } } diff --git a/act/runner/step_run_test.go b/act/runner/step_run_test.go index 75ef9ae3..80ca6068 100644 --- a/act/runner/step_run_test.go +++ b/act/runner/step_run_test.go @@ -81,7 +81,7 @@ func TestStepRun(t *testing.T) { cm.On("GetContainerArchive", ctx, "/var/run/act/workflow/pathcmd.txt").Return(io.NopCloser(&bytes.Buffer{}), nil) err := sr.main()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act cm.AssertExpectations(t) } @@ -91,8 +91,8 @@ func TestStepRunPrePost(t *testing.T) { sr := &stepRun{} err := sr.pre()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act err = sr.post()(ctx) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) } diff --git a/act/runner/step_test.go b/act/runner/step_test.go index 7f4d93a4..1a4c6fc6 100644 --- a/act/runner/step_test.go +++ b/act/runner/step_test.go @@ -156,7 +156,7 @@ func TestSetupEnv(t *testing.T) { sm.On("getEnv").Return(&env) err := setupEnv(context.Background(), sm) - assert.Nil(t, err) //nolint:testifylint // pre-existing issue from nektos/act + assert.NoError(t, err) //nolint:testifylint // pre-existing issue from nektos/act // These are commit or system specific delete((env), "GITHUB_REF") @@ -318,35 +318,35 @@ func TestIsContinueOnError(t *testing.T) { step := createTestStep(t, "name: test") continueOnError, err := isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.False(continueOnError) - assertObject.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // explcit true step = createTestStep(t, "continue-on-error: true") continueOnError, err = isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.True(continueOnError) - assertObject.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // explicit false step = createTestStep(t, "continue-on-error: false") continueOnError, err = isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.False(continueOnError) - assertObject.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // expression true step = createTestStep(t, "continue-on-error: ${{ 'test' == 'test' }}") continueOnError, err = isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.True(continueOnError) - assertObject.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // expression false step = createTestStep(t, "continue-on-error: ${{ 'test' != 'test' }}") continueOnError, err = isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.False(continueOnError) - assertObject.Nil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.NoError(err) //nolint:testifylint // pre-existing issue from nektos/act // expression parse error step = createTestStep(t, "continue-on-error: ${{ 'test' != test }}") continueOnError, err = isContinueOnError(context.Background(), step.getStepModel().RawContinueOnError, step, stepStageMain) assertObject.False(continueOnError) - assertObject.NotNil(err) //nolint:testifylint // pre-existing issue from nektos/act + assertObject.Error(err) } diff --git a/act/workflowpattern/workflow_pattern.go b/act/workflowpattern/workflow_pattern.go index f8969bb9..9f598618 100644 --- a/act/workflowpattern/workflow_pattern.go +++ b/act/workflowpattern/workflow_pattern.go @@ -38,7 +38,6 @@ func CompilePattern(rawpattern string) (*WorkflowPattern, error) { }, nil } -//nolint:gocyclo // function handles many cases func PatternToRegex(pattern string) (string, error) { var rpattern strings.Builder rpattern.WriteString("^")