Skip to content

Commit

Permalink
test: add coveralls coverage to master
Browse files Browse the repository at this point in the history
On amd64, linux unit test runs, code coverage will be collected and
uploaded to the coveralls coverage service on runs with the master
branch. This does not include forks or PRs from community members.

Currently, the coveralls service requires a token to be used to upload
all coverage reports. However, there is no safe/secure way with circle
ci to hide this with our current processes that we have in place.

This also removes the coverage for the parsers/influx/machine.go file as
it contains many "//line" comments which currently break reports. See
golang/go#35781 for more details.

fixes: #10733
  • Loading branch information
powersj committed Jun 17, 2022
1 parent f4d3aa2 commit b4f79af
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,30 @@ commands:
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
- run: 'sh ./scripts/installgo_windows.sh'
- run: choco install mingw
- run: mkdir -p test-results
- run: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >>
- unless:
condition:
equal: [ "386", << parameters.arch >> ]
steps:
- run: echo 'export RACE="-race"' >> $BASH_ENV
- run: |
GOARCH=<< parameters.arch >> ./<< parameters.gotestsum >> --junitfile test-results/gotestsum-report.xml -- ${RACE} -short ./...
- store_test_results:
path: test-results
GOARCH=<< parameters.arch >> ./<< parameters.gotestsum >> -- ${RACE} -short -cover -coverprofile=coverage.out ./...
- when:
condition:
and:
- equal: [ "master", << pipeline.git.branch >> ]
- equal: [ "linux", << parameters.os >> ]
- equal: [ "amd64", << parameters.arch >> ]
steps:
- run:
name: "Installing goveralls"
command: go install github.com/mattn/goveralls@latest
- run:
name: "Remove plugins/parsers/influx/machine.go from coverage"
command: sed -i '/github.com\/influxdata\/telegraf\/plugins\/parsers\/influx\/machine.go/d' coverage.out
- run:
name: "Create report"
command: /go/bin/goveralls -coverprofile=coverage.out -service=circle-ci -repotoken=${COVERALLS_TOKEN}
- when:
condition:
equal: [ linux, << parameters.os >> ]
Expand Down

0 comments on commit b4f79af

Please sign in to comment.