-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 1.75 KB
/
ci.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
name: Tests
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
env:
GO111MODULE: on
GOPROXY: "https://proxy.golang.org"
jobs:
build:
name: Test on ${{ matrix.os }} @Go${{ matrix.go-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: ["1.20.x", "1.21.x"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Print Go environment
id: vars
run: |
printf "Using go at: $(which go)\n"
printf "Go version: $(go version)\n"
printf "\n\nGo environment:\n\n"
go env
printf "\n\nSystem environment:\n\n"
env
# Calculate the short SHA1 hash of the git commit
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v4
with:
path: |
${{ steps.vars.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-ci-
- name: Unit test
run: |
go test -v -race -coverprofile=coverage -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage
flags: unittests
verbose: true