-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (53 loc) · 1.4 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
name: Test
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_call:
jobs:
go-test:
name: Run Go Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "go.sum"
- name: Test
run: |
go test ./... -coverprofile=coverage.out -covermode=count -v
- name: Upload coverage results to Github artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: ./coverage.out
upload-codecov:
name: Upload coverage output to Codecov.io
runs-on: ubuntu-latest
needs: go-test
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download coverage output file
uses: actions/download-artifact@v3
with:
name: coverage
- name: Upload coverage output to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
directory: "./"