Skip to content

Commit

Permalink
add badges
Browse files Browse the repository at this point in the history
add go report, coverage

fix coverage link

Update README.md

Update README.md

Update README.md

fix badge colors

Update README.md

Update README.md

add coverage to circleci

better coverage calculation

fix circleci
  • Loading branch information
rbren committed May 14, 2019
1 parent 6ec83e7 commit 4dba266
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
- run: go get -u github.com/golang/lint/golint
- run: go list ./... | grep -v vendor | xargs golint -set_exit_status
- run: go list ./... | grep -v vendor | xargs go vet
- run: go test ./pkg/... -v -coverprofile cover.out
- run: go test ./pkg/... -v -coverprofile ./test/cover.out
- run: ./test/calculate-coverage.sh
- run: git diff --exit-code README.md

test-deploy:
docker:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ polaris
# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

Tiltfile
main
.DS_Store
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<p align="center">
<div align="center">
<img src="/pkg/dashboard/assets/images/logo.png" alt="Polaris Logo" />
</p>
<br>

[![Version][version-image]][version-link] [![CircleCI][circleci-image]][circleci-link] [![Go Report Card][goreport-image]][goreport-link] [![Coverage][coverage-image]][coverage-link]
</div>

[version-image]: https://img.shields.io/static/v1.svg?label=Version&message=1.0.0&color=239922
[version-link]: https://github.com/reactiveops/polaris
[coverage-image]: https://img.shields.io/static/v1.svg?label=Coverage&message=79%25&color=239922
[coverage-link]: https://github.com/reactiveops/polaris

<!-- TODO: uncomment once project is public
[circleci-image]: https://circleci.com/gh/reactiveops/polaris.svg?style=svg
[goreport-image]: https://goreportcard.com/badge/github.com/reactiveops/polaris
-->
[circleci-link]: https://circleci.com/gh/reactiveops/polaris.svg
[goreport-link]: https://goreportcard.com/report/github.com/reactiveops/polaris

[circleci-image]: https://img.shields.io/static/v1.svg?label=Build&message=Passing&color=239922
[goreport-image]: https://img.shields.io/static/v1.svg?label=go+report&message=A&color=239922

Polaris keeps your cluster sailing smoothly. It runs a variety of checks to ensure that Kubernetes deployments are configured using best practices that will avoid potential problems in the future. The project includes two primary parts:

Expand Down
23 changes: 23 additions & 0 deletions test/calculate-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash

go tool cover -func=./test/cover.out > ./test/coverage-report.txt

total=0
count=0

while read l; do
fields=($l)
fn_coverage=${fields[2]::-3}
total=$((total + fn_coverage))
count=$((count + 1))
done <./test/coverage-report.txt

coverage=$(( total / count ))
echo $coverage
color="239922"
if [[ $coverage -lt 50 ]] ; then
color="C21807"
elif [[ $coverage -lt 70 ]] ; then
color="FFD300"
fi
sed -i -- "s/^\[coverage-image\].*$/\[coverage-image\]: https:\/\/img.shields.io\/static\/v1.svg?label=Coverage\&message=$coverage%25\&color=$color/" README.md
223 changes: 223 additions & 0 deletions test/cover.out

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions test/coverage-report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
github.com/reactiveops/polaris/pkg/config/config.go:112: ParseFile 0.0%
github.com/reactiveops/polaris/pkg/config/config.go:121: Parse 100.0%
github.com/reactiveops/polaris/pkg/config/severity.go:32: IsActionable 0.0%
github.com/reactiveops/polaris/pkg/kube/resources.go:35: CreateResourceProvider 0.0%
github.com/reactiveops/polaris/pkg/kube/resources.go:43: CreateResourceProviderFromPath 82.2%
github.com/reactiveops/polaris/pkg/kube/resources.go:114: CreateResourceProviderFromCluster 0.0%
github.com/reactiveops/polaris/pkg/kube/resources.go:124: CreateResourceProviderFromAPI 0.0%
github.com/reactiveops/polaris/pkg/validator/container.go:34: ValidateContainer 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:55: validateResources 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:84: validateResourceRange 85.7%
github.com/reactiveops/polaris/pkg/validator/container.go:104: validateHealthChecks 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:123: validateImage 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:143: validateNetworking 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:162: validateSecurity 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:217: validateCapabilities 86.7%
github.com/reactiveops/polaris/pkg/validator/container.go:261: commaSeparatedCapabilities 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:269: capIntersection 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:286: capDifference 100.0%
github.com/reactiveops/polaris/pkg/validator/container.go:303: capContains 100.0%
github.com/reactiveops/polaris/pkg/validator/deployment.go:24: ValidateDeployment 100.0%
github.com/reactiveops/polaris/pkg/validator/deployment.go:36: ValidateDeployments 100.0%
github.com/reactiveops/polaris/pkg/validator/deployment.go:47: addResult 87.5%
github.com/reactiveops/polaris/pkg/validator/fullaudit.go:31: RunAudit 88.9%
github.com/reactiveops/polaris/pkg/validator/pod.go:30: ValidatePod 100.0%
github.com/reactiveops/polaris/pkg/validator/pod.go:55: validateContainers 100.0%
github.com/reactiveops/polaris/pkg/validator/pod.go:62: validateSecurity 77.8%
github.com/reactiveops/polaris/pkg/validator/pod.go:82: validateNetworking 80.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:29: messages 100.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:37: summary 100.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:62: addMessage 0.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:74: addFailure 80.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:84: addError 100.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:92: addWarning 100.0%
github.com/reactiveops/polaris/pkg/validator/resource.go:100: addSuccess 100.0%
github.com/reactiveops/polaris/pkg/validator/types.go:48: appendCounts 100.0%
github.com/reactiveops/polaris/pkg/validator/types.go:63: appendResults 100.0%
total: (statements) 81.2%

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4dba266

Please sign in to comment.