Skip to content

Commit

Permalink
[AAE-28943] Add sonar scanner action
Browse files Browse the repository at this point in the history
  • Loading branch information
mavotto committed Dec 19, 2024
1 parent bd04854 commit 0931220
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 77 deletions.
3 changes: 0 additions & 3 deletions .github/actions/process-coverage-report/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
82 changes: 8 additions & 74 deletions .github/actions/sonar-scanner/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/[email protected]
# 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 }}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0931220

Please sign in to comment.