Skip to content

Commit

Permalink
Merge pull request #915 from khrm/golangci-lint-action
Browse files Browse the repository at this point in the history
Migrate to GitHubAction for GolangCI Lint
  • Loading branch information
khrm authored Jan 17, 2025
2 parents a26b5e0 + 3f2a342 commit fce8ade
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions pkg/api/server/cel2sql/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/api/server/db/pagination/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/api/server/v1alpha2/log/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -141,15 +140,15 @@ 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()

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
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/server/v1alpha2/ordering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}
}
Expand Down Expand Up @@ -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)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/server/v1alpha2/plugin/plugin_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
16 changes: 0 additions & 16 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -58,7 +43,6 @@ function pre_integration_tests() {

function post_build_tests() {
popd
check_go_lint
}

function post_unit_tests() {
Expand Down

0 comments on commit fce8ade

Please sign in to comment.