1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-14 02:33:21 +02:00

Export coverage report to codecov (#995)

* Export coverage report to codecov

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Use orb and individual coverage files per module

* Run go cover inside module directory to account for local rewrites

Still try to upload using a single file, since orb docs seem to
indicate if you have more than one file, you're going to need to run
the orb multiple times.

* Use correct filename

* Don't do anything silly like appending a file to itself

* Handle subtle differences between FreeBSD and Linux

* Ignore opentelemetry-proto-gen files in exporters/otlp/internal

* Does codecov orb leave current directory in a bad state?

* Copy instead of move

* Ignore generated protobuf code in jaeger exporter module

Co-authored-by: Evan Torrie <evantorrie@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Bogdan Drutu 2020-08-24 09:43:29 -07:00 committed by GitHub
parent 0ba595bddb
commit 9907328c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 6 deletions

View File

@ -1,4 +1,6 @@
version: 2.1
orbs:
codecov: codecov/codecov@1.1.1
executors:
current-go:
resource_class: large
@ -25,7 +27,10 @@ build-template: &build-template
name: "Precommit and Coverage Report"
command: |
make ci
mv coverage.html $TEST_RESULTS/
cp coverage.{out,txt,html} $TEST_RESULTS/
- codecov/upload:
file: "coverage.txt"
- save_cache:
key: cimg-go-pkg-mod-{{ checksum "go.sum" }}

24
.github/codecov.yaml vendored Normal file
View File

@ -0,0 +1,24 @@
codecov:
require_ci_to_pass: yes
ignore:
- "exporters/otlp/internal/opentelemetry-proto-gen/**/*"
- "exporters/trace/jaeger/internal/gen-go/**/*"
coverage:
precision: 1
round: down
range: "70...100"
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no

View File

@ -33,7 +33,7 @@ endif
GOTEST_MIN = go test -timeout 30s
GOTEST = $(GOTEST_MIN) -race
GOTEST_WITH_COVERAGE = $(GOTEST) -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...
GOTEST_WITH_COVERAGE = $(GOTEST) -coverprofile=coverage.out -covermode=atomic -coverpkg=./...
.DEFAULT_GOAL := precommit
@ -61,12 +61,17 @@ precommit: generate build lint examples test
.PHONY: test-with-coverage
test-with-coverage:
set -e; for dir in $(ALL_COVERAGE_MOD_DIRS); do \
set -e; \
printf "" > coverage.txt; \
for dir in $(ALL_COVERAGE_MOD_DIRS); do \
echo "go test ./... + coverage in $${dir}"; \
(cd "$${dir}" && \
$(GOTEST_WITH_COVERAGE) ./... && \
go tool cover -html=coverage.txt -o coverage.html); \
done
$(GOTEST_WITH_COVERAGE) ./... && \
go tool cover -html=coverage.out -o coverage.html); \
[ -f "$${dir}/coverage.out" ] && cat "$${dir}/coverage.out" >> coverage.txt; \
done; \
sed -i.bak -e '2,$$ { /^mode: /d; }' coverage.txt
.PHONY: ci
ci: precommit check-clean-work-tree license-check test-with-coverage test-386