Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RATIS-1314. Add JaCoCo coverity tests to Github actions #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions .github/workflows/post-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,47 @@ jobs:
- name: Delete temporary build artifacts
run: rm -rf ~/.m2/repository/org/apache/ratis
if: always()
coverity:
name: coverity
runs-on: ubuntu-18.04
if: (github.repository == 'apache/ratis' || github.repository == 'apache/incubator-ratis') && github.event_name != 'pull_request'
strategy:
matrix:
profile:
- grpc
- server
- misc
steps:
- uses: actions/checkout@master
- name: Cache for maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
restore-keys: |
maven-repo-${{ hashFiles('**/pom.xml') }}
maven-repo-
- run: >-
./dev-support/checks/unit.sh -P${{ matrix.profile }}-tests
-Dmaven.test.failure.ignore=true
-Djacoco.skip=false
-Dsurefire.rerunFailingTestsCount=3
continue-on-error: true
- name: Merge JaCoCo results
run: mvn -DskipTests -Djacoco.skip=false verify
- name: Copy JaCoCo XML report to artifacts
run: cp ./ratis-coverage/target/site/jacoco-aggregate/jacoco.xml ./target/unit
- name: Summary of failures
run: cat target/unit/summary.txt
if: ${{ !cancelled() }}
- uses: actions/upload-artifact@master
if: ${{ !cancelled() }}
with:
name: coverity-${{ matrix.profile }}
path: target/unit
- name: Delete temporary build artifacts
run: rm -rf ~/.m2/repository/org/apache/ratis
if: always()
checkstyle:
name: checkstyle
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -161,9 +202,12 @@ jobs:
sonar:
name: sonar
runs-on: ubuntu-18.04
needs: [coverity]
if: (github.repository == 'apache/ratis' || github.repository == 'apache/incubator-ratis') && github.event_name != 'pull_request'
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache for maven dependencies
uses: actions/cache@v2
with:
Expand All @@ -172,6 +216,9 @@ jobs:
restore-keys: |
maven-repo-${{ hashFiles('**/pom.xml') }}
maven-repo-
- name: Download test artifacts for coverity analysis
uses: actions/download-artifact@v2
if: always()
- name: Setup java 11
uses: actions/setup-java@v1
with:
Expand All @@ -182,4 +229,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete temporary build artifacts
run: rm -rf ~/.m2/repository/org/apache/ratis
if: always()
if: always()
5 changes: 4 additions & 1 deletion dev-support/checks/sonar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ if [ ! "$SONAR_TOKEN" ]; then
echo "SONAR_TOKEN environment variable should be set"
exit 1
fi
mvn -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache-ratis
mvn -B verify -DskipShade -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=$(find "$(pwd)" -path '*jacoco.xml' | tr '\n' ',') \
-Dsonar.organization=apache -Dsonar.projectKey=apache-ratis
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<module>ratis-resource-bundle</module>
<module>ratis-grpc</module>
<module>ratis-netty</module>
<module>ratis-coverage</module>
<module>ratis-hadoop</module>

<module>ratis-test</module>
Expand Down Expand Up @@ -249,6 +250,8 @@
<!-- LOG4J version -->
<log4j.version>1.2.17</log4j.version>

<!-- Skip JaCoCo coverity reports by default -->
<jacoco.skip>true</jacoco.skip>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -703,7 +706,7 @@
<reuseForks>false</reuseForks>
<trimStackTrace>false</trimStackTrace>
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
<argLine>-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError</argLine>
<argLine>@{argLine} -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError</argLine>
<systemPropertyVariables>
<ratis.log.dir>${project.build.directory}/log</ratis.log.dir>
<ratis.tmp.dir>${project.build.directory}/tmp</ratis.tmp.dir>
Expand Down Expand Up @@ -907,6 +910,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ static void printAll(Class<?> confClass, Consumer<Object> out) {

static void printField(Class<?> confClass, Consumer<Object> out, Field f) {
final int modifiers = f.getModifiers();
// Ignore synthetic fields. Required by JaCoCo coverity reports
if (f.isSynthetic()) {
return;
}
if (!Modifier.isStatic(modifiers)) {
throw new IllegalStateException("Found non-static field " + f);
}
Expand Down
171 changes: 171 additions & 0 deletions ratis-coverage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed 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. See accompanying LICENSE file.
-->
<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>
<artifactId>ratis</artifactId>
<groupId>org.apache.ratis</groupId>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>report</artifactId>
<name>Apache Ratis Coverity Report</name>


<dependencies>
<!-- Intra-project dependencies -->
<dependency>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-thirdparty-misc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-resource-bundle</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<artifactId>ratis-docs</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-proto</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-common</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-common</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-client</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-client</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>
<dependency>
<artifactId>ratis-server</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-server</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-grpc</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-grpc</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-netty</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-netty</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-hadoop</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-hadoop</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-test</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-test</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-examples</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-examples</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-replicated-map</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-replicated-map</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>

<dependency>
<artifactId>ratis-logservice</artifactId>
<groupId>org.apache.ratis</groupId>
</dependency>
<dependency>
<artifactId>ratis-logservice</artifactId>
<groupId>org.apache.ratis</groupId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-metrics</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-tools</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>