Skip to content

Commit

Permalink
Add code coverage reporting (#137)
Browse files Browse the repository at this point in the history
* Add code coverage reporting

Signed-off-by: John Collier <jcollier@redhat.com>

* Update PR template

Signed-off-by: John Collier <jcollier@redhat.com>

* Remove incorrect license

Signed-off-by: John Collier <jcollier@redhat.com>

Signed-off-by: John Collier <jcollier@redhat.com>
  • Loading branch information
johnmcollier committed Sep 13, 2022
1 parent 25d4dc0 commit 0f8c1eb
Show file tree
Hide file tree
Showing 5 changed files with 404 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See http://docs.codecov.io/docs/coverage-configuration
coverage:
precision: 2 # 2 = xx.xx%, 0 = xx%
round: down
# For example: 20...60 would result in any coverage less than 20%
# would have a red background. The color would gradually change to
# green approaching 60%. Any coverage over 60% would result in a
# solid green color.
range: "20...60"

status:
# project will give us the diff in the total code coverage between a commit
# and its parent
project: yes
# Patch gives just the coverage of the patch
patch: yes
# changes tells us if there are unexpected code coverage changes in other files
# which were not changed by the diff
changes: yes

# See http://docs.codecov.io/docs/ignoring-paths
ignore:
- "assets/*"
- "build/*"
- "deploy/*"
- "hack/*"
- "manifests/*"
- "openshift-ci/*"
- "vendor/*"
- "Makefile"
- ".travis.yml"

# See http://docs.codecov.io/docs/pull-request-comments-1
comment:
layout: "diff, files"
behavior: ""
# default = posts once then update, posts new if delete
# once = post once then updates
# new = delete old, post new
# spammy = post new
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Fixes #?

**PR acceptance criteria**:

- [ ] Test (WIP)
- [ ] Test Coverage
- Are your changes sufficiently tested, and are any applicable test cases added or updated to cover your changes?

Documentation (WIP)
- [ ] Does the [REST API doc](../index/server/registry-REST-API.adoc) need to be updated with your changes?
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ jobs:
run: cd index/server && ./build.sh

- name: Test index server
run: cd index/server && go test ./...
run: cd index/server && go test ./... -coverprofile cover.out

- name: Check if oci server build is working
run: cd oci-registry && ./build.sh

- name: Check if devfile-registry-integration build is working
run: cd tests/integration && ./docker-build.sh

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0

test_minikube:
name: Test Devfile Registry
runs-on: ubuntu-latest
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Code Coverage Report
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
with:
persist-credentials: false
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run tests
run: cd index/server && go test ./... -coverprofile cover.out
- name: Codecov
uses: codecov/codecov-action@v2.1.0
Loading

0 comments on commit 0f8c1eb

Please sign in to comment.