-
Notifications
You must be signed in to change notification settings - Fork 8
84 lines (73 loc) · 2.35 KB
/
go.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
78
79
80
81
82
83
84
name: Go
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
stable: false
go-version: 1.18
- name: Build
run: go build -v ./...
- name: Test
run: go test -v -update ./...
# - name: Coverage
# run: |
# go test -coverprofile=coverage.out -covermode=count ./...
# coverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+')
# echo "COVERAGE=$coverage" >> $GITHUB_ENV
# - name: Install go report card
# run: |
# git clone https://github.com/gojp/goreportcard.git
# cd goreportcard
# make install
# go install ./cmd/goreportcard-cli
# - name: Run go report card
# run: |
# goreportcard-cli
# grade=$(goreportcard-cli | head -1)
# grade=${grade:7}
# grade_percent=$(echo $grade | grep -E -o "[0-9.]+")
# echo "GRADE=${grade}" >> $GITHUB_ENV
# echo "GRADE_PERCENT=${grade_percent}" >> $GITHUB_ENV
# - name: Decide color of badges
# run: |
# get_color () {
# percent=$1
# if (( $(echo "$percent <= 50" | bc -l) )) ; then
# color=red
# elif (( $(echo "$percent > 80" | bc -l) )); then
# color=green
# else
# color=orange
# fi
# echo $color
# }
# echo "COVERAGE_COLOR=$(get_color ${{ env.COVERAGE }})" >> $GITHUB_ENV
# echo "GRADE_COLOR=$(get_color ${{ env.GRADE_PERCENT }})" >> $GITHUB_ENV
# - name: Create code coverage badge
# uses: schneegans/[email protected]
# with:
# auth: ${{ secrets.GIST }}
# gistID: f78532b2b7fa732b9884ebbf0c8c23aa
# filename: gola.cov
# label: Coverage
# message: ${{ env.COVERAGE }}%
# color: ${{ env.COVERAGE_COLOR }}
# - name: Create go report badge
# uses: schneegans/[email protected]
# with:
# auth: ${{ secrets.GIST }}
# gistID: f91bfcfee734a57cbdc5001d3886c8a7
# filename: gola.goreport.json
# label: Go Report
# message: ${{ env.GRADE }}
# color: ${{ env.GRADE_COLOR }}