From 52896819c14f4879b257ce49b606f8c0c2c1fd27 Mon Sep 17 00:00:00 2001 From: Drew Johnston <31270488+drewjj@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:13:46 -0700 Subject: [PATCH] Completely rework the sonar CI --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68d92fd4b..d28c9d7b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,22 +10,66 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build uses: docker/build-push-action@v5 - - sonar: + jpo-ode: runs-on: ubuntu-latest container: image: eclipse-temurin:21-jdk-alpine options: --user root steps: - - uses: actions/checkout@v4 + - name: Checkout ${{ github.event.repository.name }} + uses: actions/checkout@v4 - name: Set up Maven uses: stCarolas/setup-maven@v4.5 with: maven-version: 3.9.6 - - name: Run Sonar - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Build run: | cd $GITHUB_WORKSPACE - ls -la && pwd - mvn -e -X clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.projectBaseDir="repository-path" -Dsonar.projectKey=usdot.jpo.ode:jpo-ode -Dsonar.projectName=jpo-ode -Dsonar.organization=usdot-jpo-ode -Dsonar.host.url=https://sonarcloud.io -Dsonar.branch.name=$GITHUB_REF_NAME + ls -ls && pwd + mvn -e -X clean org.jacoco:jacoco-maven-plugin:prepare-agent package + mvn -e -X clean org.jacoco:jacoco-maven-plugin:report package + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: jpo-ode + path: /__w/jpo-ode/jpo-ode/target + if-no-files-found: error + sonar: + needs: [jpo-ode] + runs-on: ubuntu-latest + steps: + - name: Checkout ${{ github.event.repository.name }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download code coverage results + uses: actions/download-artifact@v4 + with: + name: jpo-ode + path: home/runner/work/jpo-ode/jpo-ode/target + - name: Find jacoco.xml + shell: bash + run: | + find "$GITHUB_WORKSPACE" -name "jacoco.xml" + - name: Setup SonarScanner + uses: warchant/setup-sonar-scanner@v7 + - name: Generate sonar properties file + run: | + cat < /tmp/sonar-scanner.properties + sonar.host.url=https://sonarcloud.io + sonar.coverage.jacoco.xmlReportPaths=/home/runner/work/jpo-ode/jpo-ode/home/runner/work/jpo-ode/jpo-ode/target/site/jacoco/jacoco.xml + sonar.java.binaries=home/runner/work/jpo-ode/jpo-ode/target + sonar.projectName=jpo-ode + sonar.projectKey=usdot.jpo.ode:jpo-ode + sonar.organization=usdot-jpo-ode + jpo-ode.sonar.projectBaseDir=home/runner/work/jpo-ode/jpo-ode + jpo-ode.sonar.sources=jpo-ode-common/src,jpo-ode-core/src,jpo-ode-plugins/src,jpo-ode-svcs/src + jpo-ode.sonar.tests=jpo-ode-common/src/test,jpo-ode-core/src/test,jpo-ode-plugins/src/test,jpo-ode-svcs/src/test + jpo-ode.sonar.test.inclusions=jpo-ode-common/src/test/**,jpo-ode-core/src/test/**,jpo-ode-plugins/src/test/**,jpo-ode-svcs/src/test/** + EOF + - name: Run SonarScanner + uses: usdot-fhwa-stol/actions/sonar-scanner@main + with: + sonar-properties-path: /tmp/sonar-scanner.properties + sonar-token: ${{ secrets.SONAR_TOKEN }} + working-dir: $GITHUB_WORKSPACE