maven: support JaCoCo and other quality checks (#6228)

This enables jacoco, which didn't run before with the -P quality due to
missing passing of jacoco arg line to surefire plugin.

This also adds support for jacoco/quality builds using Github action and
posting of the PR coverage data using a new action step.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2022-04-07 20:48:48 +05:30 committed by GitHub
parent 676fe31ca9
commit 1cdacccdc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 5 deletions

View File

@ -15,17 +15,44 @@
# specific language governing permissions and limitations
# under the License.
name: Lint Code Base
name: Check Pull Request
on: [pull_request]
jobs:
build:
name: GitHub Super Linter
name: Check Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: github/super-linter@v4
- name: Set up JDK11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Install nonoss jar dependencies
run: |
git clone https://github.com/shapeblue/cloudstack-nonoss.git nonoss
cd nonoss && bash -x install-non-oss.sh && cd ..
- name: Run Build and Tests with Coverage
run: mvn -P quality -Dsimulator -Dnoredist clean install
- name: Generate JaCoCo Report
uses: Madrapps/jacoco-report@v1.2
with:
paths: ${{ github.workspace }}/client/target/site/jacoco-aggregate/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 0
min-coverage-changed-files: 80
title: PR Code Coverage
debug-mode: true
- name: SuperLinter Lint Checks
uses: github/super-linter@v4
env:
VALIDATE_PYTHON_FLAKE8: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1001,5 +1001,31 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>quality</id>
<activation>
<property>
<name>quality</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${cs.jacoco-plugin.version}</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -39,6 +39,9 @@ import org.powermock.modules.junit4.PowerMockRunner;
public class KVMHostInfoTest {
@Test
public void getCpuSpeed() {
if (!System.getProperty("os.name").equals("Linux")) {
return;
}
Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
NodeInfo nodeInfo = Mockito.mock(NodeInfo.class);
nodeInfo.mhz = 1000;
@ -47,6 +50,9 @@ public class KVMHostInfoTest {
@Test
public void manualCpuSpeedTest() throws Exception {
if (!System.getProperty("os.name").equals("Linux")) {
return;
}
PowerMockito.mockStatic(LibvirtConnection.class);
Connect conn = Mockito.mock(Connect.class);
NodeInfo nodeInfo = Mockito.mock(NodeInfo.class);

View File

@ -55,12 +55,13 @@
<cs.jdk.version>11</cs.jdk.version>
<cs.target.dir>target</cs.target.dir>
<cs.replace.properties>build/replace.properties</cs.replace.properties>
<argLine>-Djava.security.egd=file:/dev/./urandom -noverify</argLine>
<!-- Plugins versions -->
<cs.antrun-plugin.version>1.8</cs.antrun-plugin.version>
<cs.builder-helper-plugin.version>3.0.0</cs.builder-helper-plugin.version>
<cs.checkstyle-plugin.version>3.1.0</cs.checkstyle-plugin.version>
<cs.jacoco-plugin.version>0.8.3</cs.jacoco-plugin.version>
<cs.jacoco-plugin.version>0.8.8</cs.jacoco-plugin.version>
<cs.compiler-plugin.version>3.8.1</cs.compiler-plugin.version>
<cs.dependency-plugin.version>3.1.1</cs.dependency-plugin.version>
<cs.failsafe-plugin.version>2.22.2</cs.failsafe-plugin.version>
@ -1152,7 +1153,6 @@
<version>${cs.surefire-plugin.version}</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>-Djava.security.egd=file:/dev/./urandom -noverify</argLine>
</configuration>
</plugin>
<plugin>