1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
name: build
on: [push, pull_request]
env:
GO111MODULE: on
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["1.14.x", "1.15.x", "1.16.x"]
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{matrix.go}}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Lint code
run: |
gofiles=$(find ./ -name '*.go') && [ -z "$gofiles" ] || unformatted=$(goimports -l $gofiles) && [ -z "$unformatted" ] || (echo >&2 "Go files must be formatted with gofmt. Following files has problem: $unformatted" && true);
diff <(echo -n) <(gofmt -s -d .)
go get -u golang.org/x/lint/golint
golint ./...
- name: Static code check
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go get -u github.com/gordonklaus/ineffassign
ineffassign .
go vet ./...
- name: Test
run: |
go test -race -count=1 -coverprofile=queue.coverprofile ./queue
go test -race -count=1 -coverprofile=server.coverprofile ./server
go test -race -count=1 -coverprofile=main.coverprofile
- name: Upload coverage to codecov
run: |
go get github.com/modocache/gover;
echo "" > coverage.txt
gover
cat gover.coverprofile >> coverage.txt
bash <(curl -s https://codecov.io/bash)
- name: Build
run: go build -v .
|