This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/develop by this push:
     new b742377e Support codecov to show code coverage (#184)
b742377e is described below

commit b742377e3b1c89b3e824ce2720fcfbd156f80aa6
Author: Haonan <[email protected]>
AuthorDate: Wed Jul 31 14:25:36 2024 +0800

    Support codecov to show code coverage (#184)
---
 .github/workflows/code-coverage.yml         |  35 ++++++
 .github/workflows/unit-test.yml             |   4 +-
 README-zh.md                                |   3 +-
 README.md                                   |   1 +
 code-coverage/copy-code-coverage-sources.sh |  31 +++++
 code-coverage/pom.xml                       | 132 +++++++++++++++++++++
 codecov.yml                                 |  47 ++++++++
 java/examples/pom.xml                       |   2 +-
 pom.xml                                     | 171 +++++++++++++++++++++++++++-
 9 files changed, 418 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/code-coverage.yml 
b/.github/workflows/code-coverage.yml
new file mode 100644
index 00000000..29076c3c
--- /dev/null
+++ b/.github/workflows/code-coverage.yml
@@ -0,0 +1,35 @@
+name: Code Coverage
+on:
+  push:
+    branches:
+      - develop
+    paths-ignore:
+      - 'docs/**'
+  pull_request:
+    branches:
+      - develop
+    paths-ignore:
+      - 'docs/**'
+
+jobs:
+  codecov:
+    runs-on: ubuntu-latest
+    if: github.event_name == 'pull_request' && 
github.event.pull_request.head.repo.full_name == 'apache/tsfile' || 
github.event_name == 'push'
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Cache Maven packages
+        uses: actions/cache@v4
+        with:
+          path: ~/.m2
+          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+          restore-keys: ${{ runner.os }}-m2-
+      - name: Test
+        run: |
+          ./mvnw -B -P with-java,with-cpp,with-python,with-code-coverage clean 
verify
+          ./mvnw -B -P with-code-coverage post-integration-test
+      - name: Upload coverage reports to codecov
+        uses: codecov/codecov-action@v4
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 2192e465..93e95a80 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -38,7 +38,7 @@ jobs:
       fail-fast: false
       max-parallel: 20
       matrix:
-        java: [ 8, 11, 17, 21 ]
+        java: [ 8, 17, 21 ]
         os: [ ubuntu-latest, macos-latest, windows-latest ]
     runs-on: ${{ matrix.os }}
 
@@ -78,7 +78,7 @@ jobs:
             }
 
       # Run the actual maven build including all unit- and integration-tests.
-      - name: Build and test with Maven (All others)
+      - name: Build and test with Maven
         shell: bash
         run: |
           ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} -P 
with-java,with-cpp,with-python clean verify
diff --git a/README-zh.md b/README-zh.md
index 8596329f..baf5bb9d 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -29,6 +29,7 @@ ___________    ___________.__.__
   |____|/____  >\___  /   |__|____/\___  >  version 1.0.0
              \/     \/                 \/  
 </pre>
+[![codecov](https://codecov.io/github/apache/tsfile/graph/badge.svg?token=0Y8MVAB3K1)](https://codecov.io/github/apache/tsfile)
 [![Maven 
Version](https://maven-badges.herokuapp.com/maven-central/org.apache.tsfile/tsfile-parent/badge.svg)](http://search.maven.org/#search|gav|1|g:"org.apache.tsfile")
 
 ## 简介
@@ -126,4 +127,4 @@ TsFile、CSV 和 Parquet 三种文件格式的比较
 
 [C++](./cpp/README-zh.md)
 
-[Python](./python/README-zh.md)
\ No newline at end of file
+[Python](./python/README-zh.md)
diff --git a/README.md b/README.md
index 5b5636af..a5983790 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@ ___________    ___________.__.__
   |____|/____  >\___  /   |__|____/\___  >  version 1.0.0
              \/     \/                 \/  
 </pre>
+[![codecov](https://codecov.io/github/apache/tsfile/graph/badge.svg?token=0Y8MVAB3K1)](https://codecov.io/github/apache/tsfile)
 [![Maven 
Version](https://maven-badges.herokuapp.com/maven-central/org.apache.tsfile/tsfile-parent/badge.svg)](http://search.maven.org/#search|gav|1|g:"org.apache.tsfile")
 
 ## Introduction
diff --git a/code-coverage/copy-code-coverage-sources.sh 
b/code-coverage/copy-code-coverage-sources.sh
new file mode 100755
index 00000000..19c24fd1
--- /dev/null
+++ b/code-coverage/copy-code-coverage-sources.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+for file in ../java/*/target/*.exec
+do
+   cp $file ./target/
+done
+
+for file in ../java/*/target/classes
+do
+   echo "copy from" ${file}
+   cp -r $file ./target/
+done
+
diff --git a/code-coverage/pom.xml b/code-coverage/pom.xml
new file mode 100644
index 00000000..b75bee1e
--- /dev/null
+++ b/code-coverage/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tsfile</groupId>
+        <artifactId>tsfile-parent</artifactId>
+        <version>1.0.1-SNAPSHOT</version>
+    </parent>
+    <artifactId>tsfile-code-coverage</artifactId>
+    <packaging>pom</packaging>
+    <name>TsFile: Code-Coverage</name>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>make-cmake-executable</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>process-resources</phase>
+                        <configuration>
+                            <basedir>${project.basedir}</basedir>
+                            <executable>chmod</executable>
+                            <arguments>
+                                <argument>+x</argument>
+                                
<argument>copy-code-coverage-sources.sh</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>collect-code-coverage-results</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>post-integration-test</phase>
+                        <configuration>
+                            
<executable>${project.basedir}/copy-code-coverage-sources.sh</executable>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <configuration>
+                    <rules>
+                        <rule 
implementation="org.jacoco.maven.RuleConfiguration">
+                            <element>BUNDLE</element>
+                            <limits>  
+                                <!-- Cover methodes >=30%. (the plugin does 
not support
+                                ignore getter and setter and toString etc..) 
-->
+                                <limit 
implementation="org.jacoco.report.check.Limit">
+                                    <counter>METHOD</counter>
+                                    <value>COVEREDRATIO</value>
+                                    <minimum>0.00</minimum>
+                                </limit>
+                                <!-- if-else, swtich etc.. >=70% -->
+                                <limit 
implementation="org.jacoco.report.check.Limit">
+                                    <counter>BRANCH</counter>
+                                    <value>COVEREDRATIO</value>
+                                    <minimum>0.00</minimum>
+                                </limit>
+                                <!-- class files >=95% -->
+                                <limit 
implementation="org.jacoco.report.check.Limit">
+                                    <counter>CLASS</counter>
+                                    <value>COVEREDRATIO</value>
+                                    <minimum>0.00</minimum>
+                                </limit>
+                            </limits>
+                        </rule>
+                    </rules>
+                </configuration>
+                <executions>
+                    <!-- see 
https://natritmeyer.com/howto/reporting-aggregated-unit-and-integration-test-coverage-with-jacoco/-->
+                    <execution>
+                        <id>merge-unit-and-integration-final</id>
+                        <goals>
+                            <goal>merge</goal>
+                        </goals>
+                        <phase>post-integration-test</phase>
+                        <configuration>
+                            <fileSets>
+                                <fileSet>
+                                    
<directory>${project.build.directory}/</directory>
+                                    <includes>
+                                        <include>*.exec</include>
+                                    </includes>
+                                </fileSet>
+                            </fileSets>
+                            
<destFile>${project.build.directory}/merged.exec</destFile>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>create-merged-report-final</id>
+                        <goals>
+                            <goal>report</goal>
+                            <goal>check</goal>
+                        </goals>
+                        <phase>post-integration-test</phase>
+                        <configuration>
+                            
<dataFile>${project.build.directory}/merged.exec</dataFile>
+                            
<outputDirectory>${project.build.directory}/jacoco-merged-reports</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000..aefe55fa
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,47 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+coverage:
+  precision: 2
+  round: down
+  range: "50...100"
+
+  status:
+    project: yes
+    patch: no
+    changes: no
+
+parsers:
+  jacoco:
+    partials_as_hits: true #false by default
+
+ignore:
+  - "**/pom.xml"
+  - "**/*.md"
+  - "**/*.sh"
+  - "**/*.cmd"
+  - "**/*.bat"
+  - "**/*.yml"
+  - ".mvn"
+  - "mvnw"
+  - "NOTICE"
+  - "NOTICE-binary"
+  - "License"
+  - "LICENSE-binary"
+  - "DISCLAIMER"
diff --git a/java/examples/pom.xml b/java/examples/pom.xml
index 13e1ffca..8f215aaa 100644
--- a/java/examples/pom.xml
+++ b/java/examples/pom.xml
@@ -28,7 +28,7 @@
     </parent>
     <artifactId>examples</artifactId>
     <packaging>pom</packaging>
-    <name>TSFile: Java: Examples</name>
+    <name>TsFile: Java: Examples</name>
     <dependencies>
         <dependency>
             <groupId>ch.qos.logback</groupId>
diff --git a/pom.xml b/pom.xml
index 9f44c3ff..9adff945 100644
--- a/pom.xml
+++ b/pom.xml
@@ -608,7 +608,19 @@
                     [JEP 396: Strongly Encapsulate JDK Internals by Default],
                     [JEP 403: Strongly Encapsulate JDK Internals]
                 -->
-                
<argLine>--add-opens=java.base/java.util.concurrent=ALL-UNNAMED 
--add-opens=java.base/java.lang=ALL-UNNAMED 
--add-opens=java.base/java.util=ALL-UNNAMED 
--add-opens=java.base/java.nio=ALL-UNNAMED 
--add-opens=java.base/java.io=ALL-UNNAMED 
--add-opens=java.base/java.net=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add [...]
+                <argLine><![CDATA[
+                        --add-opens=java.base/java.lang=ALL-UNNAMED
+                        --add-opens=java.base/java.util=ALL-UNNAMED
+                        --add-opens=java.base/java.nio=ALL-UNNAMED
+                        --add-opens=java.base/java.io=ALL-UNNAMED
+                        --add-opens=java.base/java.net=ALL-UNNAMED
+                        --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
+                        
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
+                        
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
+                        
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
+                        
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
+                        
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
+                      ]]></argLine>
             </properties>
         </profile>
         <!-- Current version of spotless cannot support JDK11 below -->
@@ -662,7 +674,7 @@
                 <python.compiler.argument/>
             </properties>
         </profile>
-        <!-- Profile for linux aarch64 (mainly newer Mac or Raspberry PI 
Processors) (Self-Enabling) -->
+        <!-- Profile for linux aarch64 (mainly ARM64 Processors) 
(Self-Enabling) -->
         <profile>
             <id>.os-linux-aarch64</id>
             <activation>
@@ -699,7 +711,7 @@
                 <python.compiler.argument/>
             </properties>
         </profile>
-        <!-- Profile for mac aarch64 (mainly AMD Processors) (Self-Enabling) 
-->
+        <!-- Profile for mac aarch64 (mainly new Mac Processors) 
(Self-Enabling) -->
         <profile>
             <id>.os-mac-aarch64</id>
             <activation>
@@ -757,7 +769,7 @@
                 
<python.compiler.argument>--compiler=mingw32</python.compiler.argument>
             </properties>
         </profile>
-        <!-- profile for windows aarch64 (mainly newer Mac or Raspberry PI 
Processors) (Self-Enabling) -->
+        <!-- profile for windows aarch64 (mainly VM on newer Mac) 
(Self-Enabling) -->
         <profile>
             <id>.os-windows-aarch64</id>
             <activation>
@@ -875,6 +887,157 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>with-code-coverage</id>
+            <modules>
+                <module>code-coverage</module>
+            </modules>
+            <build>
+                <plugins>
+                    <!--
+            Jacoco is a code coverage analysis plugin when tests run.
+            (not a static code analysis tool)
+          -->
+                    <plugin>
+                        <groupId>org.jacoco</groupId>
+                        <artifactId>jacoco-maven-plugin</artifactId>
+                        <version>0.8.12</version>
+                        <configuration>
+                            <rules>
+                                <rule 
implementation="org.jacoco.maven.RuleConfiguration">
+                                    <element>BUNDLE</element>
+                                    <limits>  
+                                        <!-- Cover methodes >=30%. (the plugin 
does not support
+                                        ignore getter and setter and toString 
etc..) -->
+                                        <limit 
implementation="org.jacoco.report.check.Limit">
+                                            <counter>METHOD</counter>
+                                            <value>COVEREDRATIO</value>
+                                            <minimum>0.00</minimum>
+                                        </limit>
+                                        <!-- if-else, swtich etc.. >=70% -->
+                                        <limit 
implementation="org.jacoco.report.check.Limit">
+                                            <counter>BRANCH</counter>
+                                            <value>COVEREDRATIO</value>
+                                            <minimum>0.00</minimum>
+                                        </limit>
+                                        <!-- class files >=95% -->
+                                        <limit 
implementation="org.jacoco.report.check.Limit">
+                                            <counter>CLASS</counter>
+                                            <value>COVEREDRATIO</value>
+                                            <minimum>0.00</minimum>
+                                        </limit>
+                                    </limits>
+                                </rule>
+                            </rules>
+                        </configuration>
+                        <executions>
+                            <!-- For UT-->
+                            <execution>
+                                <id>prepare-ut</id>
+                                <goals>
+                                    <goal>prepare-agent</goal>
+                                </goals>
+                                <configuration>
+                                    
<destFile>${project.build.directory}/${project.build.finalName}-jacoco-unit-tests.exec</destFile>
+                                    
<propertyName>surefire.jacoco.args</propertyName>
+                                </configuration>
+                            </execution>
+                            <!-- attached to Maven test phase -->
+                            <execution>
+                                <id>ut-report</id>
+                                <goals>
+                                    <goal>report</goal>
+                                    <goal>check</goal>
+                                </goals>
+                                <phase>test</phase>
+                                <configuration>
+                                    
<dataFile>${project.build.directory}/${project.build.finalName}-jacoco-unit-tests.exec</dataFile>
+                                    
<outputDirectory>${project.build.directory}/jacoco-unit-reports</outputDirectory>
+                                </configuration>
+                            </execution>
+                            <!-- For IT-->
+                            <execution>
+                                <id>before-integration-test-execution</id>
+                                <goals>
+                                    <goal>prepare-agent</goal>
+                                </goals>
+                                <phase>pre-integration-test</phase>
+                                <configuration>
+                                    
<destFile>${project.build.directory}/${project.build.finalName}-jacoco-integration-tests.exec</destFile>
+                                    
<propertyName>failsafe.jacoco.args</propertyName>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>after-integration-test-execution</id>
+                                <goals>
+                                    <goal>report</goal>
+                                    <goal>check</goal>
+                                </goals>
+                                <phase>integration-test</phase>
+                                <configuration>
+                                    
<dataFile>${project.build.directory}/${project.build.finalName}-jacoco-integration-tests.exec</dataFile>
+                                    
<outputDirectory>${project.build.directory}/jacoco-integration-reports</outputDirectory>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>merge-unit-and-integration</id>
+                                <goals>
+                                    <goal>merge</goal>
+                                </goals>
+                                <phase>post-integration-test</phase>
+                                <configuration>
+                                    <fileSets>
+                                        <fileSet>
+                                            
<directory>${project.build.directory}/</directory>
+                                            <includes>
+                                                <include>*.exec</include>
+                                            </includes>
+                                        </fileSet>
+                                    </fileSets>
+                                    
<destFile>${project.build.directory}/${project.build.finalName}-merged.exec</destFile>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>create-merged-report</id>
+                                <goals>
+                                    <goal>report</goal>
+                                    <goal>check</goal>
+                                </goals>
+                                <phase>post-integration-test</phase>
+                                <configuration>
+                                    
<dataFile>${project.build.directory}/${project.build.finalName}-merged.exec</dataFile>
+                                    
<outputDirectory>${project.build.directory}/jacoco-merged-reports</outputDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <!-- overwrite argLine-->
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <argLine>${argLine} @{surefire.jacoco.args} 
-Xmx1024m</argLine>
+                        </configuration>
+                    </plugin>
+                    <!-- for IT-->
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <argLine>${argLine} @{failsafe.jacoco.args} 
-Xmx1024m</argLine>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
         <profile>
             <id>enforce</id>
             <properties>

Reply via email to