diff --git a/.github/.golangci.yml b/.github/.golangci.yml new file mode 100644 index 0000000..b90a330 --- /dev/null +++ b/.github/.golangci.yml @@ -0,0 +1,17 @@ +issues: + exclude-rules: + # Some deterministic "pseudo random" data is needed in tests + - path: _test\.go + text: "G404:" + linters: + - gosec + +linters: + # In addition to the default + enable: + - gocyclo + - gofmt + - goimports + - gosec + - prealloc + - unconvert diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..948bc8d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: [push, pull_request] + +jobs: + golang: + name: Build and test cboring + + runs-on: ubuntu-latest + + strategy: + matrix: + go: [ '1.13', '1.15' ] + + steps: + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build on Go ${{ matrix.go }} + run: go build ./... + + - name: Test + run: go test -v ./... + + + golangci: + name: Check golangci-lint + + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.32 + args: --config .github/.golangci.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a60582 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.iml +.idea diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 41126dd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: go - -go: - - 1.11.x - - 1.12.x - - 1.13.x - -env: - - GO111MODULE=on - -git: - depth: 1 - -install: true - -script: - - gofmt -l -e -d . - - go vet ./... - - go test -v ./... diff --git a/README.md b/README.md index 4d58fa9..24d7500 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# cboring [![Build Status](https://travis-ci.org/dtn7/cboring.svg?branch=master)](https://travis-ci.org/dtn7/cboring) [![GoDoc](https://godoc.org/github.com/dtn7/cboring?status.svg)](https://godoc.org/github.com/dtn7/cboring) +# cboring [![CI](https://github.com/dtn7/cboring/workflows/CI/badge.svg)](https://github.com/dtn7/cboring/actions) [![GoDoc](https://godoc.org/github.com/dtn7/cboring?status.svg)](https://godoc.org/github.com/dtn7/cboring) -Simple [CBOR][cbor] Go(lang) library for a selected subset of features, +A simple [CBOR][cbor] Go(lang) library for a selected subset of features, developed to be used in [`dtn7-go`][dtn7-go], an implementation of the [Bundle Protocol Version 7][bpbis]. The name is based on the fact that `cboring` is both boring to use and bored about the amount of data to handle. @@ -17,10 +17,10 @@ developed to be used in [`dtn7-go`][dtn7-go], an implementation of the - Booleans - Small and clear codebase: - Only works on streams, Go's `io.Reader` or `io.Writer` - - Does *not* use reflection or makes any strange assumptions + - Does *not* use reflection or make any strange assumptions - Surprisingly fast -[bpbis]: https://tools.ietf.org/html/draft-ietf-dtn-bpbis-14 +[bpbis]: https://tools.ietf.org/html/draft-ietf-dtn-bpbis-29 [cbor]: https://tools.ietf.org/html/rfc7049 [dtn7-go]: https://github.com/dtn7/dtn7-go diff --git a/major_test.go b/major_test.go index 8cfb941..1669ba3 100644 --- a/major_test.go +++ b/major_test.go @@ -52,9 +52,9 @@ func TestReadMajorsBig(t *testing.T) { func TestReadMajorsError(t *testing.T) { tests := [][]byte{ // Empty stream - []byte{}, + {}, // Incomplete streams - []byte{0x18}, []byte{0x19, 0x03}, + {0x18}, {0x19, 0x03}, } for _, test := range tests { diff --git a/primitives_test.go b/primitives_test.go index c2c4ae4..8856c45 100644 --- a/primitives_test.go +++ b/primitives_test.go @@ -50,13 +50,13 @@ func TestUInt(t *testing.T) { func TestReadUIntError(t *testing.T) { tests := [][]byte{ // Wrong major type - []byte{0xFF}, + {0xFF}, // Wrong additionals for major type 0 - []byte{0x1F}, + {0x1F}, // Empty stream - []byte{}, + {}, // Incomplete streams - []byte{0x18}, []byte{0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0x18}, {0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, } for _, test := range tests {