-
Notifications
You must be signed in to change notification settings - Fork 9
77 lines (67 loc) · 2.07 KB
/
build.yml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: build
on:
push:
paths-ignore:
- "**.md"
jobs:
build:
name: Go ${{ matrix.go-version }} on ${{ matrix.vm-os }}
runs-on: ${{ matrix.vm-os }}
strategy:
max-parallel: 10
fail-fast: false
matrix:
vm-os: [ubuntu-latest, macOS-latest, windows-latest]
go-version: [1.13.15, 1.14.12, 1.15.5]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out source code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get dependencies
shell: bash
run: |
go version
go get github.com/sqs/goreturns
go get golang.org/x/tools/cmd/goimports
go get -v -t -d ./...
- name: Go format
shell: bash
run: |
test -z "$(gofmt -l .)"
test -z "$(goreturns -l .)"
test -z "$(goimports -l .)"
if: startsWith(matrix.vm-os, 'windows') == false
- name: Go test
shell: bash
run: go test -v -race -cover -covermode=atomic -coverprofile=coverage.txt -count 1 .
- name: Go benchmark
shell: bash
run: go test -parallel=4 -run="none" -benchtime="2s" -benchmem -bench .
- name: Go generate
shell: bash
run: |
go get golang.org/x/tools/cmd/stringer
go generate
if: startsWith(matrix.vm-os, 'ubuntu')
- name: Upload report to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.txt
if: startsWith(matrix.vm-os, 'ubuntu')
- name: Upload report to Codacy
shell: bash
run: |
export GOPATH=$(go env GOPATH)
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
go get github.com/schrej/godacov
godacov -t $CODACY_PROJECT_TOKEN -r ./coverage.txt -c $GITHUB_SHA
env:
CODACY_PROJECT_TOKEN: ${{ secrets.codacy_token }}
if: startsWith(matrix.vm-os, 'ubuntu')