From a7564d7b8d8b42d29a14db7746f97f5f67fe7eb9 Mon Sep 17 00:00:00 2001 From: Velinov Date: Thu, 12 Oct 2023 17:41:29 +0300 Subject: [PATCH] Prepare Sonar scan with Jacoco integration --- .github/workflows/main.yml | 14 +++++-- .github/workflows/pull-request-build.yml | 33 ++++++++++++--- multiapps-coverage/pom.xml | 52 ++++++++++++++++++++++++ pom.xml | 48 +++++++++++----------- 4 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 multiapps-coverage/pom.xml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9d0a9c6d..f50559a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Multiapps Main on: push: - branches: [ master,rel-1.73 ] + branches: [ "master" ] jobs: build: @@ -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 diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index ad3ce475..3e121502 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -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 \ No newline at end of file diff --git a/multiapps-coverage/pom.xml b/multiapps-coverage/pom.xml new file mode 100644 index 00000000..4b976488 --- /dev/null +++ b/multiapps-coverage/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + multiapps-coverage + pom + MultiApps Coverage + + + org.cloudfoundry.multiapps + multiapps-parent + 2.17.0-SNAPSHOT + + + + + + org.jacoco + jacoco-maven-plugin + + + report-aggregate + verify + + report-aggregate + + + + + + + multiapps-common + multiapps-common-test + multiapps-mta + + + org.cloudfoundry.multiapps + multiapps-common + ${project.version} + + + org.cloudfoundry.multiapps + multiapps-common-test + ${project.version} + + + org.cloudfoundry.multiapps + multiapps-mta + ${project.version} + + + diff --git a/pom.xml b/pom.xml index 0b33d8b8..5cc66955 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,9 @@ UTF-8 + https://sonarcloud.io + cloudfoundry + ../multiapps-coverage/target/site/jacoco-aggregate/jacoco.xml 5.9.2 1.9.2 4.11.0 @@ -35,6 +38,7 @@ multiapps-common multiapps-common-test multiapps-mta + multiapps-coverage @@ -140,34 +144,13 @@ org.sonarsource.scanner.maven sonar-maven-plugin - 3.7.0.1746 + 3.10.0.2594 org.jacoco jacoco-maven-plugin - 0.8.6 - - - prepare-agent - - prepare-agent - - - - prepare-agent-integration - - prepare-agent-integration - - - - report - verify - - report - - - + 0.8.10 @@ -400,6 +383,25 @@ + + coverage + + + + org.jacoco + jacoco-maven-plugin + + + prepare-agent + + prepare-agent + + + + + + + sonar