-
-
Notifications
You must be signed in to change notification settings - Fork 62
64 lines (55 loc) · 1.75 KB
/
test.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
name: Run tests
on:
push:
branches:
- main
paths:
- "*.go"
- ".github/workflows/*"
- "README.md"
pull_request:
paths:
- "*.go"
- ".github/workflows/*"
- "README.md"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: actions/checkout@v3
- run: go build -v ./...
- run: go install github.com/jpoles1/gopherbadger@latest
- run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
# Run tests with nice formatting. Save the original log in /tmp/gotest.log
- name: Run tests
run: |
set -euo pipefail
go test -p 1 -json -v -covermode atomic -coverprofile=cover.out ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload original test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
- name: Generate coverage badge
run: gopherbadger -style=for-the-badge -covercmd "go tool cover -func=cover.out"
- name: Commit coverage badge
uses: EndBug/add-and-commit@v7
with:
message: "ci: update coverage"
add: "coverage_badge.png"
author_name: "github-actions[bot]"
author_email: "github-actions[bot]@users.noreply.github.com"
- run: ./update-usage-readme.sh
- name: Commit README update
uses: EndBug/add-and-commit@v7
with:
message: "ci: update binary usage in README"
add: "README.md"
author_name: "github-actions[bot]"
author_email: "github-actions[bot]@users.noreply.github.com"