-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (56 loc) · 1.41 KB
/
go.yml
File metadata and controls
68 lines (56 loc) · 1.41 KB
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
name: Go CI / Test / Lint
permissions:
contents: read
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.20, 1.21]
steps:
# Checkout code
- name: Checkout repository
uses: actions/checkout@v4
# Go setup
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
# Cache modules and build cache
- name: Cache Go build & modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Ensure dependencies
- name: Go mod tidy
run: go mod tidy
# Lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.59.0
args: run --timeout 5m
# Build
- name: Build code
run: go build -v ./...
# Test + coverage
- name: Run tests with coverage
run: |
go test ./... -coverprofile=coverage.out -failfast -timeout=30s
go tool cover -func=coverage.out
# Upload coverage report (optional)
- name: Upload coverage to Codecov
if: github.event_name != 'pull_request'
uses: codecov/codecov-action@v4
with:
files: coverage.out