Repository navigation
57 lines (51 loc) · 1.62 KB
/
Copy pathcodecov.yaml
File metadata and controls
57 lines (51 loc) · 1.62 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
name: Unit Coverage
on:
pull_request:
paths:
- "**.go"
- "go.mod"
- "go.sum"
- "vendor/**"
- ".codecov.yaml"
- ".github/workflows/codecov.yaml"
push:
branches:
- main
paths:
- "**.go"
- "go.mod"
- "go.sum"
- "vendor/**"
- ".codecov.yaml"
- ".github/workflows/codecov.yaml"
workflow_dispatch:
jobs:
unit-coverage:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: "go.mod"
- name: Run unit tests with coverage
run: |
PACKAGES=$(go list ./... | grep -vE '/cmd(/|$)|/vendor(/|$)|/hack(/|$)|/test(/|$)|/config(/|$)|/docs(/|$)|/pkg/generated(/|$)|/pkg/apis(/|$)|/pkg/test(/|$)|/pkg/provider/.*/test(/|$)|/fake(/|$)')
COVERPKG=$(echo $PACKAGES | tr ' ' ',')
go test -coverprofile=coverage_raw.txt -covermode=atomic -coverpkg="$COVERPKG" $PACKAGES
grep -vE 'zz_generated\.deepcopy\.go|\.pb\.go' coverage_raw.txt > coverage.txt
rm -f coverage_raw.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: coverage.txt
flags: unit-tests
use_oidc: true
fail_ci_if_error: true
disable_search: true