Skip to content

Commit

Permalink
add golangci-lint action
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhelfand committed Jan 19, 2021
1 parent ce85779 commit 08ad8d2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: golangci-lint

on:
push:
pull_request:
types: [opened, reopened]

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.34
args: -v --max-same-issues 0
2 changes: 1 addition & 1 deletion hack/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -e

golangci-lint cache clean
golangci-lint run --max-same-issues 0 --tests=false
golangci-lint run --max-same-issues 0
2 changes: 1 addition & 1 deletion pkg/yamlfmt/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func evalTemplate(t *testing.T, data string) (string, *testErr) {
func expectEquals(t *testing.T, resultStr, expectedStr string) error {
if resultStr != expectedStr {
diff := difflib.PPDiff(strings.Split(expectedStr, "\n"), strings.Split(resultStr, "\n"))
return fmt.Errorf("Not equal; diff expected...actual:\n%v\n", diff)
return fmt.Errorf("Not equal; diff expected...actual:\n%v", diff)
}
return nil
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/yamlmeta/internal/yaml.v2/decode_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package yaml_test

import (
Expand Down Expand Up @@ -1017,15 +1020,15 @@ func (s *S) TestUnmarshalerTypeErrorProxying(c *C) {

type failingUnmarshaler struct{}

var failingErr = errors.New("failingErr")
var errFailing = errors.New("errFailing")

func (ft *failingUnmarshaler) UnmarshalYAML(unmarshal func(interface{}) error) error {
return failingErr
return errFailing
}

func (s *S) TestUnmarshalerError(c *C) {
err := yaml.Unmarshal([]byte("a: b"), &failingUnmarshaler{})
c.Assert(err, Equals, failingErr)
c.Assert(err, Equals, errFailing)
}

type sliceUnmarshaler []int
Expand Down
7 changes: 5 additions & 2 deletions pkg/yamlmeta/internal/yaml.v2/encode_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package yaml_test

import (
Expand Down Expand Up @@ -540,12 +543,12 @@ func (s *S) TestMarshalerWholeDocument(c *C) {
type failingMarshaler struct{}

func (ft *failingMarshaler) MarshalYAML() (interface{}, error) {
return nil, failingErr
return nil, errFailing
}

func (s *S) TestMarshalerError(c *C) {
_, err := yaml.Marshal(&failingMarshaler{})
c.Assert(err, Equals, failingErr)
c.Assert(err, Equals, errFailing)
}

func (s *S) TestSortedOutput(c *C) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/yamlmeta/internal/yaml.v2/example_embedded_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package yaml_test

import (
Expand Down
3 changes: 3 additions & 0 deletions pkg/yamlmeta/internal/yaml.v2/sorter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package yaml

import (
Expand Down
6 changes: 5 additions & 1 deletion pkg/yamlmeta/internal/yaml.v2/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package yaml_test

import (
. "gopkg.in/check.v1"
"testing"

. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }
Expand Down

0 comments on commit 08ad8d2

Please sign in to comment.