From a143a78a5c723413ee176eeffe01c84c209b83b6 Mon Sep 17 00:00:00 2001 From: Michael Weibel <307427+mweibel@users.noreply.github.com> Date: Mon, 30 Aug 2021 08:44:43 +0200 Subject: [PATCH] chore: use github actions replaces travis-ci --- .github/workflows/golangci-lint.yml | 24 +++++++++++++++++++ .github/workflows/test.yml | 37 +++++++++++++++++++++++++++++ .travis.yml | 25 ------------------- example_test.go | 3 +++ sheriff_test.go | 8 +++---- 5 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..46ddc1d --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,24 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + pull_request: +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + # * Module download cache + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b9990bd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.17', '1.16', '1.15', '1.14', '1.13' ] + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - uses: actions/cache@v2 + with: + # * Module download cache + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Test + run: go test -v -bench ./... -covermode=atomic -coverprofile=cover.out + + - uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: cover.out diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c5e4190..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: go -go: - - "1.13" - - "1.14" - - master - -before_install: - - go get github.com/mattn/goveralls - -script: - # testing - - go test -v -race -bench . -covermode=atomic -coverprofile=cover.out - # coveralls.io - - goveralls -coverprofile=cover.out -service=travis-ci - -jobs: - include: - - name: "Linting with Go 1.14" - script: - - go get -u golang.org/x/tools/cmd/goimports - - FILES=`find . -iname '*.go' -type f -not -path "./vendor/*"` - - gofmt -d $FILES - - go tool vet $FILES || echo "\n\nunexported field test is failing? that's ok. More failing? not ok.\n\n" - - goimports -d $FILES - go: "1.14" diff --git a/example_test.go b/example_test.go index 8fb2333..8d8b584 100644 --- a/example_test.go +++ b/example_test.go @@ -53,6 +53,9 @@ func Example() { log.Panic(err) } v2, err := version.NewVersion("2.0.0") + if err != nil { + log.Panic(err) + } output, err := MarshalUsers(v1, []string{"api"}, users) if err != nil { diff --git a/sheriff_test.go b/sheriff_test.go index 7b452fd..a009b7b 100644 --- a/sheriff_test.go +++ b/sheriff_test.go @@ -628,10 +628,10 @@ func TestMarshal_ArrayOfInterfaceable(t *testing.T) { } type TestInlineStruct struct { - // explicitely testing unexported fields - // go vet complains about it and that's ok to ignore. - tableName struct{ Test string } `json:"-" is:"notexported"` - tableNameWithTag struct{ Test string } `json:"foo" is:"notexported"` + // explicitly testing unexported fields + // golangci-lint complains about it and that's ok to ignore. + tableName struct{ Test string } `json:"-"` //nolint + tableNameWithTag struct{ Test string } `json:"foo"` //nolint Field string `json:"field"` Field2 *string `json:"field2"`