-
Notifications
You must be signed in to change notification settings - Fork 3
94 lines (78 loc) · 2.34 KB
/
Copy pathtest.yml
File metadata and controls
94 lines (78 loc) · 2.34 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
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
on:
push:
branches:
- main
pull_request:
name: run tests
jobs:
lint:
runs-on: ubuntu-latest
env:
GOLANGCI_LINT_VERSION: v2.11.3
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Install Go
id: install-go
uses: actions/setup-go@v7
with:
go-version-file: 'go.mod'
- name: Download dependencies
run: go mod download
if: steps.install-go.outputs.cache-hit != 'true'
- name: Run linter
uses: golangci/golangci-lint-action@v9
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
test:
strategy:
matrix:
go-version: [ "1.25", "1.26" ]
runs-on: ubuntu-latest
env:
GOTESTSUM_VERSION: v1.13.0
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Install Go
id: install-go
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}
check-latest: "true"
- name: Cache Go test cache
uses: actions/cache@v6
with:
path: /home/runner/.cache/go-test-cache
key: ${{ runner.os }}-go-testcache-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-testcache-
- name: Download dependencies
run: go mod download
if: steps.install-go.outputs.cache-hit != 'true'
- name: Setup gotestsum
run: go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: Run Tests
run: gotestsum --format pkgname -- -covermode=atomic -coverprofile=coverage.out -race ./...
env:
GOCACHE: /home/runner/.cache/go-test-cache
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.out
format: golang
parallel: true
flag-name: go-${{ matrix.go-version }}
test-results:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
- name: Check matrix results
if: ${{ contains(needs.test.result, 'failure') || contains(needs.test.result, 'cancelled') }}
run: exit 1