-
Notifications
You must be signed in to change notification settings - Fork 14
127 lines (118 loc) · 3.03 KB
/
unit-test-on-pull-request.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: FreeLRU
on:
push:
branches: [main]
pull_request:
branches: ["**"]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Linter
run: |
go version
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
make lint
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable", "1.18.10"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Run Test
run: |
make check
bench:
name: Bench
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Run Benchmarks
run: |
GOMAXPROCS=100 make bench
coverage:
name: Coverage
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
permissions:
contents: write
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Build
run: |
go install
- name: Run Coverage
run: |
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out
- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v1
# if: ${{ runner.os == 'Linux' && matrix.go == '1.17' }} # Runs this on only one of the ci builds.
with:
green: 80
filename: coverage.out
# - name: Pull in remote changes
# run: git pull --rebase
- uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
commit_message: Apply Code Coverage Badge
skip_fetch: true
skip_checkout: true
file_pattern: ./README.md
# - name: Push Changes
# if: steps.auto-commit-action.outputs.changes_detected == 'true'
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ github.token }}
# branch: ${{ github.ref }}