From b2dfbdde2007d57202f01a5cea427b576fe7db39 Mon Sep 17 00:00:00 2001 From: drdr xp Date: Sat, 14 Nov 2020 12:48:11 +0800 Subject: [PATCH] refactor: ci: add Action of local lint, refine coveralls task --- .github/workflows/golangci-lint.yml | 47 +++++++++++++---------------- .github/workflows/local-lint.yml | 35 +++++++++++++++++++++ Makefile | 8 ++++- 3 files changed, 63 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/local-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 01b705fa..a300bcbb 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,35 +1,30 @@ name: golangci-lint on: push: + tags: + - v* + branches: + - '*' pull_request: - jobs: - test: - strategy: - matrix: - go-version: - - 1.14.x - os: - - ubuntu-latest - - runs-on: ${{ matrix.os }} - + golangci: + name: lint + runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v2 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.29 - - name: checkout - uses: actions/checkout@v2 + # Optional: working directory, useful for monorepos + # working-directory: somedir - - name: cache - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + # disable staticcheck: + # SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead + args: --issues-exit-code=0 --exclude SA1019 - - name: test - run: make lint + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true diff --git a/.github/workflows/local-lint.yml b/.github/workflows/local-lint.yml new file mode 100644 index 00000000..60556791 --- /dev/null +++ b/.github/workflows/local-lint.yml @@ -0,0 +1,35 @@ +name: local-lint +on: + push: + pull_request: + +jobs: + test: + strategy: + matrix: + go-version: + - 1.14.x + os: + - ubuntu-latest + + runs-on: ${{ matrix.os }} + + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: checkout + uses: actions/checkout@v2 + + - name: cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: test + run: make lint diff --git a/Makefile b/Makefile index 324053eb..0a131bab 100644 --- a/Makefile +++ b/Makefile @@ -78,9 +78,15 @@ fix: gofmt -s -w $(GOFILES) unconvert -v -apply $(PKGS) +# local coverage +coverage: + $(GO) test -covermode=count -coverprofile=coverage.out $(PKGS) + go tool cover -func=coverage.out + go tool cover -html=coverage.out coveralls: $(GO) get golang.org/x/tools/cmd/cover $(GO) get github.com/mattn/goveralls $(GO) test -covermode=count -coverprofile=coverage.out $(PKGS) - $$HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $$COVERALLS_TOKEN + goveralls -ignore='*.pb.go' -coverprofile=coverage.out -service=travis-ci + # -repotoken $$COVERALLS_TOKEN