-
Notifications
You must be signed in to change notification settings - Fork 53
52 lines (46 loc) · 1.36 KB
/
build-test-coverage.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
# This workflow will test and run code coverage for the golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build Test Coverage
on:
pull_request:
push:
env:
TEST_RESULTS: /tmp/test-results
jobs:
build-test:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache-dependency-path: |
subdir/go.sum
tools/go.sum
- name: Create test directory
run: mkdir -p $TEST_RESULTS
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Run unit tests
run: |
PACKAGE_NAMES=$(go list ./... | xargs)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES
- name: Run build
run: make build
coverage:
runs-on: ubuntu-20.04
needs: build-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
- name: Generate coverage report
run: make coverage
- name: Upload coverage report
run: bash -c "$(curl -s https://codecov.io/bash)"