Skip to content

Commit

Permalink
refactor: ci: add Action of local lint, refine coveralls task
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Nov 14, 2020
1 parent 935eb76 commit b2dfbdd
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 27 deletions.
47 changes: 21 additions & 26 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/local-lint.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b2dfbdd

Please sign in to comment.