diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5a1c2c5..1d4e027 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,6 +31,7 @@ on: permissions: contents: read + pull-requests: read env: MAVEN_CLI_OPTS: "--batch-mode --no-transfer-progress" @@ -40,6 +41,9 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v5 + with: + # Full history is recommended for accurate Sonar analysis and PR decoration + fetch-depth: 0 - name: Set up JDK 21 uses: actions/setup-java@v5 with: @@ -51,13 +55,11 @@ jobs: env: GH_PACKAGES_PAT: ${{ secrets.GH_PACKAGES_PAT }} run: ./mvnw $MAVEN_CLI_OPTS verify - - name: Upload JaCoCo HTML report - if: always() - uses: actions/upload-artifact@v4 - with: - name: jacoco-report - path: target/site/jacoco - if-no-files-found: warn + - name: run code coverage + env: + GH_PACKAGES_PAT: ${{ secrets.GH_PACKAGES_PAT }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./mvnw $MAVEN_CLI_OPTS -Dsonar.projectKey=National-Digital-Twin_management-node -Dsonar.organization=national-digital-twin -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage lint: runs-on: ubuntu-latest steps: diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..2d780d8 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.projectKey=National-Digital-Twin_management-node +sonar.organization=national-digital-twin +sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \ No newline at end of file