Skip to content

Commit

Permalink
[fix][ci] Fix jacoco code coverage report aggregation (apache#22964)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari authored Jun 24, 2024
1 parent c78585a commit aa03c0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 5 additions & 4 deletions build/pulsar_ci_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ _ci_upload_coverage_files() {
--transform="flags=r;s|\\(/jacoco.*\\).exec$|\\1_${testtype}_${testgroup}.exec|" \
--transform="flags=r;s|\\(/tmp/jacocoDir/.*\\).exec$|\\1_${testtype}_${testgroup}.exec|" \
--exclude="*/META-INF/bundled-dependencies/*" \
--exclude="*/META-INF/versions/*" \
$GITHUB_WORKSPACE/target/classpath_* \
$(find "$GITHUB_WORKSPACE" -path "*/target/jacoco*.exec" -printf "%p\n%h/classes\n" | sort | uniq) \
$([ -d /tmp/jacocoDir ] && echo "/tmp/jacocoDir" ) \
Expand Down Expand Up @@ -494,11 +495,11 @@ ci_create_test_coverage_report() {
local classfilesArgs="--classfiles $({
{
for classpathEntry in $(cat $completeClasspathFile | { grep -v -f $filterArtifactsFile || true; } | sort | uniq | { grep -v -E "$excludeJarsPattern" || true; }); do
if [[ -f $classpathEntry && -n "$(unzip -Z1C $classpathEntry 'META-INF/bundled-dependencies/*' 2>/dev/null)" ]]; then
# file must be processed by removing META-INF/bundled-dependencies
if [[ -f $classpathEntry && -n "$(unzip -Z1C $classpathEntry 'META-INF/bundled-dependencies/*' 'META-INF/versions/*' 2>/dev/null)" ]]; then
# file must be processed by removing META-INF/bundled-dependencies and META-INF/versions
local jartempfile=$(mktemp -t jarfile.XXXX --suffix=.jar)
cp $classpathEntry $jartempfile
zip -q -d $jartempfile 'META-INF/bundled-dependencies/*' &> /dev/null
zip -q -d $jartempfile 'META-INF/bundled-dependencies/*' 'META-INF/versions/*' &> /dev/null
echo $jartempfile
else
echo $classpathEntry
Expand Down Expand Up @@ -560,7 +561,7 @@ ci_create_inttest_coverage_report() {
# remove jar file that causes duplicate classes issue
rm /tmp/jacocoDir/pulsar_lib/org.apache.pulsar-bouncy-castle* || true
# remove any bundled dependencies as part of .jar/.nar files
find /tmp/jacocoDir/pulsar_lib '(' -name "*.jar" -or -name "*.nar" ')' -exec echo "Processing {}" \; -exec zip -q -d {} 'META-INF/bundled-dependencies/*' \; |grep -E -v "Nothing to do|^$" || true
find /tmp/jacocoDir/pulsar_lib '(' -name "*.jar" -or -name "*.nar" ')' -exec echo "Processing {}" \; -exec zip -q -d {} 'META-INF/bundled-dependencies/*' 'META-INF/versions/*' \; |grep -E -v "Nothing to do|^$" || true
fi
# projects that aren't considered as production code and their own src/main/java source code shouldn't be analysed
local excludeProjectsPattern="testmocks|testclient|buildtools"
Expand Down
11 changes: 11 additions & 0 deletions jetcd-core-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<pattern>io.vertx</pattern>
<shadedPattern>org.apache.pulsar.jetcd.shaded.io.vertx</shadedPattern>
</relocation>
<!-- relocate multi-release packages -->
<relocation>
<pattern>META-INF/versions/(\d+)/io/vertx/</pattern>
<shadedPattern>META-INF/versions/$1/org/apache/pulsar/jetcd/shaded/io/vertx/</shadedPattern>
<rawString>true</rawString>
</relocation>
<!-- relocate to use grpc-netty-shaded packages -->
<relocation>
<pattern>io.grpc.netty</pattern>
Expand All @@ -123,6 +129,11 @@
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.PluginXmlResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ flexible messaging model and an intuitive client API.</description>
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
<wagon-ssh-external.version>3.5.3</wagon-ssh-external.version>
<os-maven-plugin.version>1.7.0</os-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<spotbugs-maven-plugin.version>4.7.3.6</spotbugs-maven-plugin.version>
<spotbugs.version>4.7.3</spotbugs.version>
<errorprone.version>2.24.0</errorprone.version>
Expand Down

0 comments on commit aa03c0e

Please sign in to comment.