diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 000000000..c1d21e88d --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -0,0 +1,25 @@ +name: golangci-lint +on: # yamllint disable-line rule:truthy + push: + branches: + - main + pull_request: # yamllint disable-line rule:empty-values + +permissions: + contents: read + checks: write # Used to annotate code in the PR + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 + with: + version: v1.62.2 + args: --timeout=10m diff --git a/pkg/api/server/cel2sql/interpreter.go b/pkg/api/server/cel2sql/interpreter.go index c0740671f..52dd7d1a1 100644 --- a/pkg/api/server/cel2sql/interpreter.go +++ b/pkg/api/server/cel2sql/interpreter.go @@ -89,9 +89,9 @@ func (i *interpreter) interpretExpr(expr *exprpb.Expr) error { func (i *interpreter) unsupportedExprError(id int64, name string) error { sourceInfo := i.checkedExpr.SourceInfo column := sourceInfo.Positions[id] - var line int32 + var line int for i, offset := range sourceInfo.LineOffsets { - line = int32(i) + 1 + line = i + 1 if offset > column { break } diff --git a/pkg/api/server/config/config.go b/pkg/api/server/config/config.go index c8d0d95f5..52ff1c31f 100644 --- a/pkg/api/server/config/config.go +++ b/pkg/api/server/config/config.go @@ -61,7 +61,7 @@ type Config struct { LOGGING_PLUGIN_CA_CERT string `mapstructure:"LOGGING_PLUGIN_CA_CERT"` LOGGING_PLUGIN_QUERY_LIMIT uint `mapstructure:"LOGGING_PLUGIN_QUERY_LIMIT"` LOGGING_PLUGIN_TLS_VERIFICATION_DISABLE bool `mapstructure:"LOGGING_PLUGIN_TLS_VERIFICATION_DISABLE"` - LOGGING_PLUGIN_FORWARDER_DELAY_DURATION uint `mapstructure:"LOGGING_PLUGIN_FORWARDER_DELAY_DURATION"` + LOGGING_PLUGIN_FORWARDER_DELAY_DURATION int64 `mapstructure:"LOGGING_PLUGIN_FORWARDER_DELAY_DURATION"` LOGGING_PLUGIN_QUERY_PARAMS string `mapstructure:"LOGGING_PLUGIN_QUERY_PARAMS"` } diff --git a/pkg/api/server/db/pagination/pagination.go b/pkg/api/server/db/pagination/pagination.go index f6f61b418..f5364a080 100644 --- a/pkg/api/server/db/pagination/pagination.go +++ b/pkg/api/server/db/pagination/pagination.go @@ -71,11 +71,11 @@ type Batcher struct { } // NewBatcher creates a new batcher for the given requested page size. -func NewBatcher(want, min, max int) *Batcher { +func NewBatcher(want, mini, maxi int) *Batcher { return &Batcher{ want: want, - min: min, - max: max, + min: mini, + max: maxi, ratio: 1, } } diff --git a/pkg/api/server/v1alpha2/log/s3.go b/pkg/api/server/v1alpha2/log/s3.go index d592908e4..fd4aa619e 100644 --- a/pkg/api/server/v1alpha2/log/s3.go +++ b/pkg/api/server/v1alpha2/log/s3.go @@ -8,7 +8,6 @@ import ( v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "context" - "fmt" "io" "github.com/aws/aws-sdk-go-v2/aws" @@ -141,7 +140,7 @@ func (s3s *s3Stream) WriteTo(w io.Writer) (n int64, err error) { Key: &s3s.key, }) if err != nil { - return 0, fmt.Errorf(err.Error()) + return 0, err } defer outPut.Body.Close() @@ -149,7 +148,7 @@ func (s3s *s3Stream) WriteTo(w io.Writer) (n int64, err error) { reader := bufio.NewReaderSize(outPut.Body, s3s.size) n, err = reader.WriteTo(w) if err != nil { - return 0, fmt.Errorf(err.Error()) + return 0, err } return } diff --git a/pkg/api/server/v1alpha2/ordering_test.go b/pkg/api/server/v1alpha2/ordering_test.go index a037db886..b9e63ea1f 100644 --- a/pkg/api/server/v1alpha2/ordering_test.go +++ b/pkg/api/server/v1alpha2/ordering_test.go @@ -25,7 +25,7 @@ func TestOrderBy(t *testing.T) { t.Errorf("unexpected error: %v", err) } if ob != tc.out { - t.Errorf(diff.PrintWantGot(cmp.Diff(tc.out, ob))) + t.Error(diff.PrintWantGot(cmp.Diff(tc.out, ob))) } } } @@ -70,7 +70,7 @@ func TestNormalizeOrderByField(t *testing.T) { t.Errorf("unexpected error: %v", err) } if n != tc.out { - t.Errorf(diff.PrintWantGot(cmp.Diff(tc.out, n))) + t.Error(diff.PrintWantGot(cmp.Diff(tc.out, n))) } } } diff --git a/pkg/api/server/v1alpha2/plugin/plugin_logs.go b/pkg/api/server/v1alpha2/plugin/plugin_logs.go index dd544ae9a..c3c0799b2 100644 --- a/pkg/api/server/v1alpha2/plugin/plugin_logs.go +++ b/pkg/api/server/v1alpha2/plugin/plugin_logs.go @@ -172,7 +172,7 @@ func getLokiLogs(s *LogServer, writer io.Writer, parent string, rec *db.Record) parameters.Add("query", `{ `+s.staticLabels+s.config.LOGGING_PLUGIN_NAMESPACE_KEY+`="`+parent+`" }|json uid="`+uidKey+`", message="message" |uid="`+rec.Name+`"| line_format "{{.message}}"`) parameters.Add("end", endTime) parameters.Add("start", startTime) - parameters.Add("limit", strconv.Itoa(int(s.queryLimit))) + parameters.Add("limit", strconv.FormatUint(uint64(s.queryLimit), 10)) URL.RawQuery = parameters.Encode() s.logger.Debugf("loki request url:%s", URL.String()) diff --git a/test/presubmit-tests.sh b/test/presubmit-tests.sh index c24a62ff3..26cdaceb2 100755 --- a/test/presubmit-tests.sh +++ b/test/presubmit-tests.sh @@ -29,21 +29,6 @@ export GO111MODULE=on source $(dirname $0)/vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh -function check_go_lint() { - header "Testing if golint has been done" - - # deadline of 5m, and show all the issues - GOFLAGS="-mod=mod" make golangci-lint-check - - if [[ $? != 0 ]]; then - results_banner "Go Lint" 1 - exit 1 - fi - - results_banner "Go Lint" 0 -} - - function pre_build_tests() { pushd ${TEST_FOLDER} } @@ -58,7 +43,6 @@ function pre_integration_tests() { function post_build_tests() { popd - check_go_lint } function post_unit_tests() {