-
Notifications
You must be signed in to change notification settings - Fork 100
Add Jacoco Coverage Provider #161
Add Jacoco Coverage Provider #161
Conversation
Will reopen after fixing test |
@ChaitanyaPramod what happened to this PR? |
68ca588
to
81b84aa
Compare
Thanks for reviving this PR! |
phabricator-plugin.iml
Outdated
<orderEntry type="library" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.13" level="project" /> | ||
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jenkins-ci.plugins:jacoco:1.0.19" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jacoco:org.jacoco.report:0.7.4.201502262128" level="project" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind using jacoco 0.8.1 which is the latest stable
phabricator-plugin.iml
Outdated
<orderEntry type="library" name="Maven: org.jacoco:org.jacoco.core:0.7.4.201502262128" level="project" /> | ||
<orderEntry type="library" name="Maven: org.ow2.asm:asm-debug-all:5.0.1" level="project" /> | ||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.kohsuke:asm5:5.0.1" level="project" /> | ||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.1" level="project" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest jacoco requires asm 6 for java 9/10 support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address comments
81b84aa
to
fde8c78
Compare
build.gradle
Outdated
optionalJenkinsPlugins 'org.jenkins-ci.plugins:junit:1.6@jar' | ||
optionalJenkinsPlugins 'org.jenkins-ci.plugins:cobertura:1.9.6@jar' | ||
optionalJenkinsPlugins 'org.jenkins-ci.plugins:jacoco:2.0.1@jar' | ||
providedCompile 'org.jacoco:org.jacoco.report:0.7.5.201505241946' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind using jacoco 0.8.1 which is the latest stable
latest jacoco requires asm 6 for java 9/10 support
Jacoco is on the compile classpath only so compiler can find its symbols for compilation. Jacoco, at runtime, comes from Jacoco Jenkins plugin. Updating Jacoco, therefore, would be out of this PR's scope and would belong in the Jacoco plugin. Jacoco plugin 3.0.1 uses Jacoco 0.8.0 and ASM 6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
fakeHitCount = 1; | ||
break; | ||
case ICounter.PARTLY_COVERED: | ||
fakeHitCount = 1; // Harbormaster format doesn't allow for partially covered lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider partially covered lines as uncovered instead
} | ||
|
||
@Test | ||
@Ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finish this test
fde8c78
to
8476a3f
Compare
@ChaitanyaPramod plans to finish the test in the PR? Planning to cut a release soon and would be good to get this merged before that |
8476a3f
to
ea5b5e7
Compare
I'd like the test finished before merging, would give me lot more peace of mind. Will not be able to spend more time on this until the next weekend. Contributions to tests are welcome. (I'd use uncovered lines as guide) Would encourage community to try this out and report bugs, if any before merging. |
ea5b5e7
to
3dd6811
Compare
return null; | ||
} | ||
|
||
CoverageProvider coverage = Objects.firstNonNull(coberturaCoverage, jacocoCoverage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure this logic is sound. Cobertura plugin could be available but only jacoco report could have been generated. We want to select the provider based on which one has coverage available.
Ideally we would support a hybrid coverage provider that can aggregate coverage results from all available providers. This can be a follow up/enhancement however
CoverageProvider jacocoCoverage = jacocoProvider.getInstance(); | ||
|
||
if (coverage == null) { | ||
if (coberturaCoverage == null && jacocoCoverage == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets pick the first non null coverage provider that satisfies
coverage.hasCoverage() == true
HashMap<String, List<Integer>> lineCoverage = new HashMap<String, List<Integer>>(); | ||
|
||
try { | ||
ExecutionFileLoader executionFileLoader = jacocoAction.getJacocoReport().parse(null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only need the getJacocoReport()
, we should not be gating this feature on the presence of a jacoco build step. All we need is for the plugin to be available in jenkins so we have the runtime components to parse a coverage result. We should be able to use it to parse the result and provide coverage. The cobertura provider does not need the cobertura plugin to be applied to the job either, so we should mirror the same behavior by adding a config option to the phab jenkins plugint to accept the path to the jacoco xml report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We pick a few things from the JacocoPublisher
attached to the current build, so we can't do that.
That said, I prefer we take advantage of Jenkins ecosystem and not recreate the coverage plugin's function here. It's trivial to add a coverage plugin to a job and we get to maintain minimal code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Feel free to leave it this way. We will add a way to not have the jacoco plugin added to the job and still use the functionality in a separate change.
68f5d87
to
b6b328f
Compare
The Java 7 test fails on CI, but works locally. The CI uses older version of Java (1.7.0_121) which doesn't have TLS 1.2 enabled by default, and hence is not able to connect to now TLS 1.2 only maven repositories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor nits to address. LGTM after that
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please avoid star imports?
You may want to configure your IDE to not do this
i.remove(); | ||
} | ||
} | ||
if (!coverageProviders.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a logger.info
statement here about which coverage we picked if its a non empty list?
It will help with debugging issues
b6b328f
to
adeed25
Compare
@ChaitanyaPramod ci issues should be fixed. Can you please rebase? |
adeed25
to
6277313
Compare
@kageiit Rebased, and the CI build has succeeded. |
Fixes #99