From c289cc23ee9079d095d3d80b359a9a14a5c63d19 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Fri, 29 Nov 2024 17:07:25 +0100 Subject: [PATCH 01/16] [AAE-28943] Added SonarCloud Scan --- .../process-coverage-report/action.yml | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 94d301463..f3ced988e 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -54,19 +54,23 @@ outputs: runs: using: composite steps: - - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 - id: jacoco-aggregate - with: - paths: ${{ inputs.paths }} - token: ${{ inputs.token }} - min-coverage-overall: ${{ inputs.min-coverage-overall }} - min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} - title: ${{ inputs.title }} - update-comment: ${{ inputs.update-comment }} - skip-if-no-changes: ${{ inputs.skip-if-no-changes }} - pass-emoji: ${{ inputs.pass-emoji }} - fail-emoji: ${{ inputs.fail-emoji }} - continue-on-error: ${{ inputs.continue-on-error }} - debug-mode: ${{ inputs.debug-mode }} - coverage-overall: ${{ inputs.coverage-overall }} - coverage-changed-files: ${{ inputs.coverage-changed-files }} + - name: SonarCloud Scan + - uses: sonarsource/sonarcloud-github-action@v3.1.0 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 +# id: jacoco-aggregate +# with: +# paths: ${{ inputs.paths }} +# token: ${{ inputs.token }} +# min-coverage-overall: ${{ inputs.min-coverage-overall }} +# min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} +# title: ${{ inputs.title }} +# update-comment: ${{ inputs.update-comment }} +# skip-if-no-changes: ${{ inputs.skip-if-no-changes }} +# pass-emoji: ${{ inputs.pass-emoji }} +# fail-emoji: ${{ inputs.fail-emoji }} +# continue-on-error: ${{ inputs.continue-on-error }} +# debug-mode: ${{ inputs.debug-mode }} +# coverage-overall: ${{ inputs.coverage-overall }} +# coverage-changed-files: ${{ inputs.coverage-changed-files }} From 63cde62ecdb74eb80de875c815bda0335f9a8962 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Fri, 29 Nov 2024 17:22:04 +0100 Subject: [PATCH 02/16] [AAE-28943] Added sonar_token as an input field --- .github/actions/process-coverage-report/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index f3ced988e..191b0f370 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -1,6 +1,9 @@ name: 'Process Coverage Report' description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' inputs: + sonar_token: + description: 'SonarCloud token to upload the coverage report' + required: true paths: description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' required: true @@ -57,7 +60,7 @@ runs: - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v3.1.0 env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_TOKEN: ${{ inputs.sonar_token }} # - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 # id: jacoco-aggregate # with: From e2ccba31b21f3d323115d4ab591d427459f54dfc Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Fri, 29 Nov 2024 17:28:31 +0100 Subject: [PATCH 03/16] [AAE-28943] fix --- .github/actions/process-coverage-report/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 191b0f370..5e2d50b88 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -58,7 +58,7 @@ runs: using: composite steps: - name: SonarCloud Scan - - uses: sonarsource/sonarcloud-github-action@v3.1.0 + uses: sonarsource/sonarcloud-github-action@v3.1.0 env: SONAR_TOKEN: ${{ inputs.sonar_token }} # - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 From 95ac0a31e7adb28c5c8d6715d00dac622af5bc76 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Mon, 2 Dec 2024 10:58:32 +0100 Subject: [PATCH 04/16] [AAE-28943] add report location --- .github/actions/process-coverage-report/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 5e2d50b88..f880608ca 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -61,6 +61,9 @@ runs: uses: sonarsource/sonarcloud-github-action@v3.1.0 env: SONAR_TOKEN: ${{ inputs.sonar_token }} + with: + args: > + -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} # - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 # id: jacoco-aggregate # with: From dd474cc648b76c52e16b04ca9fccf525a53d6dff Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Mon, 2 Dec 2024 17:09:45 +0100 Subject: [PATCH 05/16] [AAE-28943] use mvn sonar --- .../process-coverage-report/action.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index f880608ca..5e89beb6e 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -57,13 +57,18 @@ outputs: runs: using: composite steps: - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v3.1.0 - env: - SONAR_TOKEN: ${{ inputs.sonar_token }} - with: - args: > - -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} + - name: Load JaCoCo report on SonarCloud + shell: bash + run: | + mvn sonar:sonar -Dsonar.token=${{ inputs.sonar_token }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services + +# - name: SonarCloud Scan +# uses: sonarsource/sonarcloud-github-action@v3.1.0 +# env: +# SONAR_TOKEN: ${{ inputs.sonar_token }} +# with: +# args: > +# -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} # - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 # id: jacoco-aggregate # with: From 4ac35f0f1ad35805d33fe8fe073c2763ad7bd0a3 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Mon, 2 Dec 2024 17:57:18 +0100 Subject: [PATCH 06/16] [AAE-28943] move uploading coverage inside the build --- .github/actions/maven-build-and-tag/action.yml | 6 ++++++ .github/actions/process-coverage-report/action.yml | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/actions/maven-build-and-tag/action.yml b/.github/actions/maven-build-and-tag/action.yml index ba726dc05..55763beea 100644 --- a/.github/actions/maven-build-and-tag/action.yml +++ b/.github/actions/maven-build-and-tag/action.yml @@ -248,6 +248,12 @@ runs: MAVEN_USERNAME: ${{ inputs.maven-username }} MAVEN_PASSWORD: ${{ inputs.maven-password }} + - name: Load JaCoCo report on SonarCloud + shell: bash + run: | + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services + + - name: Remove running docker containers if: inputs.reuse-testcontainers == 'true' shell: bash diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 5e89beb6e..eb9819f4b 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -58,9 +58,11 @@ runs: using: composite steps: - name: Load JaCoCo report on SonarCloud + env: + SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn sonar:sonar -Dsonar.token=${{ inputs.sonar_token }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services # - name: SonarCloud Scan # uses: sonarsource/sonarcloud-github-action@v3.1.0 From 49f61c8847a9fecd5da17f7d1827217328036dd4 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Mon, 2 Dec 2024 18:01:29 +0100 Subject: [PATCH 07/16] [AAE-28943] add xml report paths --- .github/actions/process-coverage-report/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index eb9819f4b..62f7ecc17 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -62,7 +62,7 @@ runs: SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} # - name: SonarCloud Scan # uses: sonarsource/sonarcloud-github-action@v3.1.0 From 8cdf8db7c0282434301a8a25fbf95bec9fa89292 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Wed, 18 Dec 2024 14:22:08 +0100 Subject: [PATCH 08/16] [AAE-28943] add coverage parameter --- .github/actions/process-coverage-report/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 62f7ecc17..ae897f9c5 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -62,7 +62,7 @@ runs: SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} -Pcoverage # - name: SonarCloud Scan # uses: sonarsource/sonarcloud-github-action@v3.1.0 From 8c7dfae916f6b1bd92c454947d66c62254a35805 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Wed, 18 Dec 2024 17:15:45 +0100 Subject: [PATCH 09/16] [AAE-28943] test --- .github/actions/process-coverage-report/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index ae897f9c5..fb2df142b 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -62,7 +62,7 @@ runs: SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} -Pcoverage + mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Alfresco_hxp-studio-services # - name: SonarCloud Scan # uses: sonarsource/sonarcloud-github-action@v3.1.0 From ee32bcacf8a4cb81042511994106b5fc8e3f5e54 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Wed, 18 Dec 2024 18:07:00 +0100 Subject: [PATCH 10/16] [AAE-28943] restore --- .github/actions/process-coverage-report/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index fb2df142b..62f7ecc17 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -62,7 +62,7 @@ runs: SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Alfresco_hxp-studio-services + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} # - name: SonarCloud Scan # uses: sonarsource/sonarcloud-github-action@v3.1.0 From 1db7b978eb7e704ab54b68fb38d1219d6fdb9bae Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Thu, 19 Dec 2024 10:22:12 +0100 Subject: [PATCH 11/16] [AAE-28943] restore old action and create a specific one for sonar --- .../process-coverage-report/action.yml | 49 ++++------ .github/actions/sonar-scanner/action.yml | 89 +++++++++++++++++++ 2 files changed, 105 insertions(+), 33 deletions(-) create mode 100644 .github/actions/sonar-scanner/action.yml diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 62f7ecc17..94d301463 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -1,9 +1,6 @@ name: 'Process Coverage Report' description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' inputs: - sonar_token: - description: 'SonarCloud token to upload the coverage report' - required: true paths: description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' required: true @@ -57,33 +54,19 @@ outputs: runs: using: composite steps: - - name: Load JaCoCo report on SonarCloud - env: - SONAR_TOKEN: ${{ inputs.sonar_token }} - shell: bash - run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} - -# - name: SonarCloud Scan -# uses: sonarsource/sonarcloud-github-action@v3.1.0 -# env: -# SONAR_TOKEN: ${{ inputs.sonar_token }} -# with: -# args: > -# -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} -# - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 -# id: jacoco-aggregate -# with: -# paths: ${{ inputs.paths }} -# token: ${{ inputs.token }} -# min-coverage-overall: ${{ inputs.min-coverage-overall }} -# min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} -# title: ${{ inputs.title }} -# update-comment: ${{ inputs.update-comment }} -# skip-if-no-changes: ${{ inputs.skip-if-no-changes }} -# pass-emoji: ${{ inputs.pass-emoji }} -# fail-emoji: ${{ inputs.fail-emoji }} -# continue-on-error: ${{ inputs.continue-on-error }} -# debug-mode: ${{ inputs.debug-mode }} -# coverage-overall: ${{ inputs.coverage-overall }} -# coverage-changed-files: ${{ inputs.coverage-changed-files }} + - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 + id: jacoco-aggregate + with: + paths: ${{ inputs.paths }} + token: ${{ inputs.token }} + min-coverage-overall: ${{ inputs.min-coverage-overall }} + min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} + title: ${{ inputs.title }} + update-comment: ${{ inputs.update-comment }} + skip-if-no-changes: ${{ inputs.skip-if-no-changes }} + pass-emoji: ${{ inputs.pass-emoji }} + fail-emoji: ${{ inputs.fail-emoji }} + continue-on-error: ${{ inputs.continue-on-error }} + debug-mode: ${{ inputs.debug-mode }} + coverage-overall: ${{ inputs.coverage-overall }} + coverage-changed-files: ${{ inputs.coverage-changed-files }} diff --git a/.github/actions/sonar-scanner/action.yml b/.github/actions/sonar-scanner/action.yml new file mode 100644 index 000000000..62f7ecc17 --- /dev/null +++ b/.github/actions/sonar-scanner/action.yml @@ -0,0 +1,89 @@ +name: 'Process Coverage Report' +description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' +inputs: + sonar_token: + description: 'SonarCloud token to upload the coverage report' + required: true + paths: + description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' + required: true + token: + description: 'Github personal token to add commits to Pull Request' + required: true + min-coverage-overall: + description: 'The minimum code coverage that is required to pass for overall project' + required: false + default: '80' + min-coverage-changed-files: + description: 'The minimum code coverage that is required to pass for changed files' + required: false + default: '80' + title: + description: 'Optional title for the Pull Request comment' + required: false + update-comment: + description: 'Update the coverage report comment instead of creating new ones. Requires title to works properly.' + required: false + default: 'false' + skip-if-no-changes: + description: "Comment won't be added if there is no coverage information present for the files changed" + required: false + default: 'false' + pass-emoji: + description: 'Github emoji to use for pass status shown when coverage greater than min coverage (should be a Github supported emoji)' + required: false + default: ':green_apple:' + fail-emoji: + description: 'Github emoji to use for fail status shown when coverage lesser than min coverage (should be a Github supported emoji)' + required: false + default: ':x:' + continue-on-error: + description: 'When there is an error do not fail the action, but log a warning' + required: false + default: 'true' + debug-mode: + description: 'Run the action in debug mode and get debug logs printed in console' + required: false + default: 'false' + +outputs: + coverage-overall: + description: 'The overall coverage of the project' + value: ${{ steps.jacoco-aggregate.outputs.coverage-overall }} + coverage-changed-files: + description: 'The total coverage of all changed files' + value: ${{ steps.jacoco-aggregate.outputs.coverage-changed-files }} + +runs: + using: composite + steps: + - name: Load JaCoCo report on SonarCloud + env: + SONAR_TOKEN: ${{ inputs.sonar_token }} + shell: bash + run: | + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} + +# - name: SonarCloud Scan +# uses: sonarsource/sonarcloud-github-action@v3.1.0 +# env: +# SONAR_TOKEN: ${{ inputs.sonar_token }} +# with: +# args: > +# -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} +# - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 +# id: jacoco-aggregate +# with: +# paths: ${{ inputs.paths }} +# token: ${{ inputs.token }} +# min-coverage-overall: ${{ inputs.min-coverage-overall }} +# min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} +# title: ${{ inputs.title }} +# update-comment: ${{ inputs.update-comment }} +# skip-if-no-changes: ${{ inputs.skip-if-no-changes }} +# pass-emoji: ${{ inputs.pass-emoji }} +# fail-emoji: ${{ inputs.fail-emoji }} +# continue-on-error: ${{ inputs.continue-on-error }} +# debug-mode: ${{ inputs.debug-mode }} +# coverage-overall: ${{ inputs.coverage-overall }} +# coverage-changed-files: ${{ inputs.coverage-changed-files }} From bd04854560c90e70d588ed396d08dcb9bebafdbf Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Thu, 19 Dec 2024 10:28:44 +0100 Subject: [PATCH 12/16] Revert "[AAE-28943] move uploading coverage inside the build" This reverts commit 0c5de41b --- .github/actions/maven-build-and-tag/action.yml | 6 ------ .github/actions/process-coverage-report/action.yml | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/actions/maven-build-and-tag/action.yml b/.github/actions/maven-build-and-tag/action.yml index 55763beea..ba726dc05 100644 --- a/.github/actions/maven-build-and-tag/action.yml +++ b/.github/actions/maven-build-and-tag/action.yml @@ -248,12 +248,6 @@ runs: MAVEN_USERNAME: ${{ inputs.maven-username }} MAVEN_PASSWORD: ${{ inputs.maven-password }} - - name: Load JaCoCo report on SonarCloud - shell: bash - run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services - - - name: Remove running docker containers if: inputs.reuse-testcontainers == 'true' shell: bash diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 94d301463..174d9f91e 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -1,6 +1,9 @@ name: 'Process Coverage Report' description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' inputs: + sonar_token: + description: 'SonarCloud token to upload the coverage report' + required: true paths: description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' required: true From 09312209aff8b509953bfea42a57f1e887c4906b Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Thu, 19 Dec 2024 10:55:43 +0100 Subject: [PATCH 13/16] [AAE-28943] Add sonar scanner action --- .../process-coverage-report/action.yml | 3 - .github/actions/sonar-scanner/action.yml | 82 ++----------------- .github/dependabot.yml | 8 ++ 3 files changed, 16 insertions(+), 77 deletions(-) diff --git a/.github/actions/process-coverage-report/action.yml b/.github/actions/process-coverage-report/action.yml index 174d9f91e..94d301463 100644 --- a/.github/actions/process-coverage-report/action.yml +++ b/.github/actions/process-coverage-report/action.yml @@ -1,9 +1,6 @@ name: 'Process Coverage Report' description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' inputs: - sonar_token: - description: 'SonarCloud token to upload the coverage report' - required: true paths: description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' required: true diff --git a/.github/actions/sonar-scanner/action.yml b/.github/actions/sonar-scanner/action.yml index 62f7ecc17..7d2ffc992 100644 --- a/.github/actions/sonar-scanner/action.yml +++ b/.github/actions/sonar-scanner/action.yml @@ -1,58 +1,16 @@ -name: 'Process Coverage Report' -description: 'Process the generated coverage for further reporting, uses JaCoCo-report plugin' +name: 'Sonar Scanner' +description: 'Run Sonar Scanner to load JaCoCo report on SonarCloud' inputs: sonar_token: - description: 'SonarCloud token to upload the coverage report' + description: 'SonarCloud token' required: true - paths: - description: 'Comma separated paths of the generated JaCoCo xml files (supports wildcard glob pattern)' + aggregate-report-path: + description: 'Path of the aggregated JaCoCo report' required: true - token: - description: 'Github personal token to add commits to Pull Request' + project_key: + description: 'SonarCloud project key' required: true - min-coverage-overall: - description: 'The minimum code coverage that is required to pass for overall project' - required: false - default: '80' - min-coverage-changed-files: - description: 'The minimum code coverage that is required to pass for changed files' - required: false - default: '80' - title: - description: 'Optional title for the Pull Request comment' - required: false - update-comment: - description: 'Update the coverage report comment instead of creating new ones. Requires title to works properly.' - required: false - default: 'false' - skip-if-no-changes: - description: "Comment won't be added if there is no coverage information present for the files changed" - required: false - default: 'false' - pass-emoji: - description: 'Github emoji to use for pass status shown when coverage greater than min coverage (should be a Github supported emoji)' - required: false - default: ':green_apple:' - fail-emoji: - description: 'Github emoji to use for fail status shown when coverage lesser than min coverage (should be a Github supported emoji)' - required: false - default: ':x:' - continue-on-error: - description: 'When there is an error do not fail the action, but log a warning' - required: false - default: 'true' - debug-mode: - description: 'Run the action in debug mode and get debug logs printed in console' - required: false - default: 'false' -outputs: - coverage-overall: - description: 'The overall coverage of the project' - value: ${{ steps.jacoco-aggregate.outputs.coverage-overall }} - coverage-changed-files: - description: 'The total coverage of all changed files' - value: ${{ steps.jacoco-aggregate.outputs.coverage-changed-files }} runs: using: composite @@ -62,28 +20,4 @@ runs: SONAR_TOKEN: ${{ inputs.sonar_token }} shell: bash run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=Alfresco_hxp-studio-services -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} - -# - name: SonarCloud Scan -# uses: sonarsource/sonarcloud-github-action@v3.1.0 -# env: -# SONAR_TOKEN: ${{ inputs.sonar_token }} -# with: -# args: > -# -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.paths }} -# - uses: madrapps/jacoco-report@7c362aca34caf958e7b1c03464bd8781db9f8da7 # v1.7.1 -# id: jacoco-aggregate -# with: -# paths: ${{ inputs.paths }} -# token: ${{ inputs.token }} -# min-coverage-overall: ${{ inputs.min-coverage-overall }} -# min-coverage-changed-files: ${{ inputs.min-coverage-changed-files }} -# title: ${{ inputs.title }} -# update-comment: ${{ inputs.update-comment }} -# skip-if-no-changes: ${{ inputs.skip-if-no-changes }} -# pass-emoji: ${{ inputs.pass-emoji }} -# fail-emoji: ${{ inputs.fail-emoji }} -# continue-on-error: ${{ inputs.continue-on-error }} -# debug-mode: ${{ inputs.debug-mode }} -# coverage-overall: ${{ inputs.coverage-overall }} -# coverage-changed-files: ${{ inputs.coverage-changed-files }} + mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=${{ inputs.project_key}} -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.aggregate-report-path }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7c77b16f0..b9747dbf6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -585,6 +585,14 @@ updates: catch-all: patterns: - "*" + - package-ecosystem: "github-actions" + directory: "/.github/actions/sonar-scanner" + schedule: + interval: "weekly" + groups: + catch-all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/update-deployment-runtime-versions" schedule: From 8b2f916d41c159dce35f5dab1dd594882f1a099f Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Thu, 19 Dec 2024 11:08:14 +0100 Subject: [PATCH 14/16] [AAE-28943] Update README.md --- docs/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/README.md b/docs/README.md index 652781ed6..8e08e6825 100644 --- a/docs/README.md +++ b/docs/README.md @@ -98,6 +98,7 @@ Here follows the list of GitHub Actions topics available in the current document - [setup-terraform-docs](#setup-terraform-docs) - [setup-updatebot](#setup-updatebot) - [slack-file-upload](#slack-file-upload) + - [sonar-scanner](#sonar-scanner) - [update-deployment-runtime-versions](#update-deployment-runtime-versions) - [update-pom-to-next-pre-release](#update-pom-to-next-pre-release) - [update-project-base-tag](#update-project-base-tag) @@ -1654,6 +1655,19 @@ Uploads a file to a Slack channel. file-title: 'file description' # optional ``` +### sonar-scanner + +Run Sonar Scanner to load JaCoCo report on SonarCloud. + +```yaml + - uses: Alfresco/alfresco-build-tools/.github/actions/sonar-scanner@ref + with: + sonar-token: ${{ secrets.SONAR_TOKEN }} + aggregate-report-path: ${{ github.workspace }}/coverage-folder/target/site/jacoco-aggregate/jacoco.xml + project-key: sonar-project-key + +``` + ### update-deployment-runtime-versions For more information, see [update-deployment-runtime-versions](../.github/actions/update-deployment-runtime-versions/action.yml). From a5a6fd2e81588dc104535bbccee34eb04b1ee4fd Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Fri, 20 Dec 2024 15:33:39 +0100 Subject: [PATCH 15/16] [AAE-28943] required changes --- .github/actions/sonar-scanner/action.yml | 16 ++++++++++++---- docs/README.md | 2 ++ version.txt | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/actions/sonar-scanner/action.yml b/.github/actions/sonar-scanner/action.yml index 7d2ffc992..db9715aac 100644 --- a/.github/actions/sonar-scanner/action.yml +++ b/.github/actions/sonar-scanner/action.yml @@ -1,15 +1,23 @@ name: 'Sonar Scanner' description: 'Run Sonar Scanner to load JaCoCo report on SonarCloud' inputs: - sonar_token: + sonar-token: description: 'SonarCloud token' required: true aggregate-report-path: description: 'Path of the aggregated JaCoCo report' required: true - project_key: + project-key: description: 'SonarCloud project key' required: true + sonar-host-url: + description: 'SonarCloud host url' + required: false + default: 'https://sonarcloud.io' + sonar-organization: + description: 'SonarCloud organization' + required: false + default: 'alfresco' runs: @@ -17,7 +25,7 @@ runs: steps: - name: Load JaCoCo report on SonarCloud env: - SONAR_TOKEN: ${{ inputs.sonar_token }} + SONAR_TOKEN: ${{ inputs.sonar-token }} shell: bash run: | - mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=alfresco -Dsonar.projectKey=${{ inputs.project_key}} -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.aggregate-report-path }} + mvn sonar:sonar -Dsonar.host.url=${{ inputs.sonar-host-url }} -Dsonar.organization=${{ inputs.sonar-organization }} -Dsonar.projectKey=${{ inputs.project-key }} -Dsonar.coverage.jacoco.xmlReportPaths=${{ inputs.aggregate-report-path }} diff --git a/docs/README.md b/docs/README.md index 8e08e6825..a3f5db464 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1668,6 +1668,8 @@ Run Sonar Scanner to load JaCoCo report on SonarCloud. ``` +sonar-host-url and sonar-organization are optional inputs. If not provided, the default values will be used. + ### update-deployment-runtime-versions For more information, see [update-deployment-runtime-versions](../.github/actions/update-deployment-runtime-versions/action.yml). diff --git a/version.txt b/version.txt index 9127c00fe..8db18fe32 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v8.6.3 +v8.6.4 From fc04757063db56b6a82fde0374e7a74caebce2d7 Mon Sep 17 00:00:00 2001 From: Federico D'Ulizia Date: Fri, 20 Dec 2024 15:42:34 +0100 Subject: [PATCH 16/16] Update version.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Maciusiak <158472457+pmacius@users.noreply.github.com> --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 8db18fe32..c78ac6140 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v8.6.4 +v8.7.0