Skip to content

Commit b15d4c8

Browse files
Add test coverage collection (open-telemetry#69)
1 parent 53396b1 commit b15d4c8

File tree

6 files changed

+321
-0
lines changed

6 files changed

+321
-0
lines changed

.github/workflows/build-and-test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ jobs:
2929
- name: Install dependencies
3030
if: steps.module-cache.outputs.cache-hit != 'true'
3131
run: make gomoddownload
32+
- name: Cache Tools
33+
id: tool-cache
34+
uses: actions/cache@v3
35+
with:
36+
path: /home/runner/go/bin
37+
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
38+
- name: Install Tools
39+
if: steps.tool-cache.outputs.cache-hit != 'true'
40+
run: make install-tools
41+
3242
build-and-test:
3343
runs-on: ubuntu-latest
3444
needs: [setup-environment]
@@ -56,3 +66,43 @@ jobs:
5666
key: go-build-unittest-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
5767
- name: Build and Test
5868
run: make
69+
70+
test-coverage:
71+
runs-on: ubuntu-latest
72+
needs: [setup-environment]
73+
steps:
74+
- name: Checkout Repo
75+
uses: actions/checkout@v3
76+
- name: Setup Go
77+
uses: actions/setup-go@v3
78+
with:
79+
go-version: 1.17
80+
- name: Setup Go Environment
81+
run: |
82+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
83+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
84+
- name: Cache Go
85+
id: module-cache
86+
uses: actions/cache@v3
87+
with:
88+
path: /home/runner/go/pkg/mod
89+
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
90+
- name: Cache Tools
91+
id: tool-cache
92+
uses: actions/cache@v3
93+
with:
94+
path: /home/runner/go/bin
95+
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
96+
- name: Cache Build
97+
uses: actions/cache@v3
98+
with:
99+
path: /home/runner/.cache/go-build
100+
key: go-build-coverage-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
101+
- name: Run Unit Tests With Coverage
102+
run: make test-with-cover
103+
- name: Upload coverage report
104+
uses: codecov/codecov-action@v3
105+
with:
106+
file: ./coverage.out
107+
fail_ci_if_error: true
108+
verbose: true

internal/tools/empty.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package tools

internal/tools/go.mod

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module github.com/open-telemetry/opamp-go/internal/tools
2+
3+
go 1.17
4+
5+
require github.com/ory/go-acc v0.2.8
6+
7+
require (
8+
github.com/cespare/xxhash v1.1.0 // indirect
9+
github.com/dgraph-io/ristretto v0.0.2 // indirect
10+
github.com/fsnotify/fsnotify v1.4.9 // indirect
11+
github.com/google/uuid v1.1.1 // indirect
12+
github.com/hashicorp/hcl v1.0.0 // indirect
13+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
14+
github.com/magiconair/properties v1.8.1 // indirect
15+
github.com/mitchellh/mapstructure v1.3.2 // indirect
16+
github.com/ory/viper v1.7.5 // indirect
17+
github.com/pborman/uuid v1.2.0 // indirect
18+
github.com/pelletier/go-toml v1.8.0 // indirect
19+
github.com/spf13/afero v1.2.2 // indirect
20+
github.com/spf13/cast v1.3.1 // indirect
21+
github.com/spf13/cobra v1.0.0 // indirect
22+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
23+
github.com/spf13/pflag v1.0.5 // indirect
24+
github.com/subosito/gotenv v1.2.0 // indirect
25+
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
26+
golang.org/x/text v0.3.2 // indirect
27+
gopkg.in/ini.v1 v1.57.0 // indirect
28+
gopkg.in/yaml.v2 v2.3.0 // indirect
29+
)

0 commit comments

Comments
 (0)