Skip to content

Commit

Permalink
Update to use coverage/ and upload artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune <afiune@chef.io>
  • Loading branch information
Salim Afiune committed Oct 28, 2019
1 parent bdde2e6 commit 9e3a534
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ steps:
- label: ":linux: go-unit-code-coverage"
command:
- ./scripts/code_coverage.sh
artifact_paths:
- "coverage/*"
expeditor:
secrets:
GITHUB_TOKEN:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Habitat
results/
coverage/

# mac
.DS_Store
Expand Down
11 changes: 6 additions & 5 deletions .studiorc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
hab pkg install chef/studio-common >/dev/null
source "$(hab pkg path chef/studio-common)/bin/studio-common"

coverage_out="results/coverage.raw"
coverage_txt="results/coverage.txt"
coverage_html="results/coverage.html"
# when updating these output files, update 'scripts/code_coverage.sh' as well
coverage_out="coverage/coverage.raw"
coverage_txt="coverage/coverage.txt"
coverage_html="coverage/coverage.html"

function build_cross_platform() {
install_if_missing core/go go
Expand All @@ -34,7 +35,7 @@ function unit_tests() {
log_line "Running unit tests"
# Avoid running integration tests inside unit tests
( cd /src || return 1
mkdir -p results/
mkdir -p coverage/
GO_PACKAGES=$(go list ./... | grep -v integration)
go test \
-coverprofile=$coverage_out \
Expand All @@ -45,7 +46,7 @@ function unit_tests() {
# run unit tests plus code coverage information
function code_coverage() {
( cd /src || return 1
mkdir -p results/
mkdir -p coverage/
unit_tests
log_line "Generating coverage profile information for each function ($(yellow /src/$coverage_txt))"
go tool cover -func=$coverage_out -o $coverage_txt
Expand Down
4 changes: 2 additions & 2 deletions scripts/code_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

# the generated code coverage profile coming from our habitat studio
COVERAGE_TXT="results/coverage.txt"
COVERAGE_TXT="coverage/coverage.txt"
# extract the repository name from the environment variable BUILDKITE_REPO
# example: "https://github.com/chef/chef-analyze.git"
REPO_NAME=$(echo $BUILDKITE_REPO | cut -d/ -f5 | cut -d. -f1)
Expand All @@ -27,4 +27,4 @@ EOF

hab studio run "source .studiorc && code_coverage"

curl -H "Authorization: token $GITHUB_TOKEN" "$COMMENTS_URL" -d "$(post_data)"
curl -H "Authorization: token $GITHUB_TOKEN" "$COMMENTS_URL" -d "$(post_data)" >/dev/null

0 comments on commit 9e3a534

Please sign in to comment.