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

Prepare Sonar scan with Jacoco integration #241

Merged
merged 1 commit into from
Oct 12, 2023
Merged
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
14 changes: 10 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Multiapps Main

on:
push:
branches: [ master,rel-1.73 ]
branches: [ "master" ]

jobs:
build:
Expand All @@ -13,7 +13,13 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
distribution: 'zulu'

- name: Build with Maven
run: mvn clean install
- name: Build and Analyze Code Coverage
run: mvn clean install -Pcoverage

- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn sonar:sonar -Dsonar.projectKey=cloudfoundry_multiapps
33 changes: 28 additions & 5 deletions .github/workflows/pull-request-build.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
name: Multiapps Maven build
name: Multiapps PR Workflow

on:
pull_request:
branches: [ master,rel-1.67 ]
branches: [ master ]
types: [opened, synchronize, reopened]

jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
distribution: 'zulu'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: mvn clean install
- name: Build and Analyze Code Coverage
run: mvn clean install -Pcoverage

- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn sonar:sonar -Dsonar.projectKey=cloudfoundry_multiapps
52 changes: 52 additions & 0 deletions multiapps-coverage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<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>

<artifactId>multiapps-coverage</artifactId>
<packaging>pom</packaging>
<name>MultiApps Coverage</name>

<parent>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-parent</artifactId>
<version>2.17.0-SNAPSHOT</version>
</parent>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<module>multiapps-common</module>
<module>multiapps-common-test</module>
<module>multiapps-mta</module>
<dependencies>
<dependency>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-common-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-mta</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
48 changes: 25 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>cloudfoundry</sonar.organization>
<sonar.coverage.jacoco.xmlReportPaths>../multiapps-coverage/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<junit.version>5.9.2</junit.version>
<junit-platform.version>1.9.2</junit-platform.version>
<mockito.version>4.11.0</mockito.version>
Expand All @@ -35,6 +38,7 @@
<module>multiapps-common</module>
<module>multiapps-common-test</module>
<module>multiapps-mta</module>
<module>multiapps-coverage</module>
</modules>

<organization>
Expand Down Expand Up @@ -140,34 +144,13 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
<version>3.10.0.2594</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<version>0.8.10</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down Expand Up @@ -400,6 +383,25 @@
</plugins>
</build>
</profile>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>sonar</id>
<build>
Expand Down
Loading