diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..19bc085 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,112 @@ +name: Go +on: + push: + tags: + - v* + branches: + - master + pull_request: + +jobs: + golangci-lint: + name: "GolangCI-lint" + runs-on: ubuntu-latest + strategy: + matrix: + golang: + - 1.18.x + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.golang }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.3.0 + with: + go-version: ${{ matrix.golang }} + version: v1.50.1 + args: --timeout=10m + + go-tests-on-linux: + runs-on: ubuntu-latest + strategy: + matrix: + golang: + - 1.18 + - 1.19 + env: + OS: ubuntu-latest + GOLANG: ${{ matrix.golang }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.golang }} + - name: Cache Go modules + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{matrix.golang}}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{matrix.golang}}- + - name: Download modules + run: go mod download + - name: Check go.mod and go.sum + run: | + go mod tidy -v + git --no-pager diff go.mod go.sum + git --no-pager diff --quiet go.mod go.sum + - name: Run tests with race, without goleak + run: go test -race -covermode=atomic -coverpkg=all -coverprofile=coverage.txt -cover -v ./... -test.timeout=10m + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + file: ./coverage.txt + flags: unittests + env_vars: OS,GOLANG + name: codecov-umbrella + fail_ci_if_error: false + go-tests-on-macos: + runs-on: macos-latest + strategy: + matrix: + golang: + - 1.18 + - 1.19 + env: + OS: macos-latest + GOLANG: ${{ matrix.golang }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.golang }} + - name: Cache Go modules + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-${{matrix.golang}}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-${{matrix.golang}}-go- + - name: Download modules + run: go mod download + - name: Check go.mod and go.sum + run: | + go mod tidy -v + git --no-pager diff go.mod go.sum + git --no-pager diff --quiet go.mod go.sum + - name: Run tests with race, without goleak + run: go test -race -covermode=atomic -coverpkg=all -coverprofile=coverage.txt -cover -v ./... -test.timeout=10m + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + file: ./coverage.txt + flags: unittests + env_vars: OS,GOLANG + name: codecov-umbrella + fail_ci_if_error: false diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..9f9c29f --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,29 @@ +run: + deadline: 1m + tests: true + +linters-settings: + golint: + min-confidence: 0 + maligned: + suggest-new: true + goconst: + min-len: 5 + min-occurrences: 4 + misspell: + locale: US + +linters: + disable-all: false + enable: + - goconst + - misspell + - misspell + - errcheck + - unused + - staticcheck + - unconvert + - gofmt + - goimports + - revive + - ineffassign