Skip to content

Commit 25e277e

Browse files
author
Vishal.Vaibhav
committed
updated readme
1 parent e433fd5 commit 25e277e

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ Sometimes when working to get a repo to an acceptable level of code coverage, it
99
covered enough. This plugin will look at just the lines changed in the PR and report code coverage for only those
1010
lines.
1111

12-
This plugin will output the coverage details to the drone step's console, as well as has the ability to comment on the
12+
This plugin will output the coverage details to the vela step's console, as well as has the ability to comment on the
1313
PR with a summary of the coverage details.
1414

15+
Currently, this plugin supports two coverage file format.
16+
* jacoco for jvm based languages like java,kotlin,scala
17+
* cobertura can be used for golang projects using [gocov-xml](https://github.com/AlekSi/gocov-xml) utility
18+
1519

1620

1721
## VELA Usage
1822

23+
### Jvm based projects
24+
For java/koltin based projects you need jacoco files that goes as an input to this plugin. How to generate jacoco files is outside the scope of
25+
this project. Once you have that jacoco file, you can pass that path to coverage_file parameters as shown in an example below
26+
1927
```yaml
2028
- name: check-pr-code-coverage
2129
image: docker.target.com/app/pull-request-code-coverage
@@ -36,6 +44,36 @@ PR with a summary of the coverage details.
3644
```
3745
3846
47+
### Golang based projects
48+
You can use [gocov-xml](https://github.com/AlekSi/gocov-xml) utility to generate coverage.xml
49+
```
50+
- go get github.com/axw/gocov/gocov
51+
- go get github.com/AlekSi/gocov-xml
52+
- go test -v -coverpkg=./... -coverprofile=coverage.txt ./...
53+
- go tool cover -func=coverage.txt
54+
- gocov convert coverage.txt | gocov-xml > ./coverage.xml
55+
```
56+
57+
Once you have coverage.xml same can be passed as an input to plugin shown below
58+
59+
```yaml
60+
- name: check-pr-code-coverage
61+
image: docker.target.com/app/pull-request-code-coverage
62+
pull: true
63+
ruleset:
64+
event: [pull_request]
65+
parameters:
66+
coverage_type: cobertura
67+
#coverage.xml generated in above step
68+
coverage_file: coverage.xml
69+
source_dirs:
70+
- /vela/src/git.target.com/TargetOSS/pull-request-code-coverage
71+
gh_api_base_url: https://git.target.com
72+
secrets:
73+
- source: pull_request_api_key
74+
target: plugin_gh_api_key
75+
```
76+
3977
#### Parameters
4078
4179
|param|required| default | description|
@@ -46,3 +84,10 @@ PR with a summary of the coverage details.
4684
|gh_api_base_url| false | | base url of the gh api for posting coverage comments<br><br>if not set, coverage details will not be commented on PR |
4785
|gh_api_key| false | | api key to auth for posting coverage comments<br><br>if not set, coverage details will not be commented on PR |
4886
|module | false | \<empty string\> | sub-module to use if operating inside a multi-module project (e.g. gradle multi-project build) |
87+
88+
# Development
89+
90+
This project needs go (>= 1.17) to be installed.
91+
92+
# License
93+
This project is licensed under the Apache License, Version 2.0.

0 commit comments

Comments
 (0)