From c2f76757bad085d86a19277c6f4f00ddd56a3d18 Mon Sep 17 00:00:00 2001 From: Armando Capozza Date: Wed, 22 May 2024 10:17:48 +0200 Subject: [PATCH] chore: add springboot sonar support --- .../sonar-step-springboot-analyze.yml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/sonar-step-springboot-analyze.yml diff --git a/.github/workflows/sonar-step-springboot-analyze.yml b/.github/workflows/sonar-step-springboot-analyze.yml new file mode 100644 index 00000000..5e59ec4a --- /dev/null +++ b/.github/workflows/sonar-step-springboot-analyze.yml @@ -0,0 +1,67 @@ +name: Sonar analyze with artifacts + +on: + workflow_call: + inputs: + RUN_ON: + required: false + type: string + default: "zupit-agents" + RUNNERS_CONTAINER_GROUP: + required: false + type: string + default: "Container" + WORKING_DIRECTORY: + required: true + type: string + SONAR_IMAGE: + required: false + type: string + default: "sonarsource/sonar-scanner-cli" + CHECK_QUALITY_GATE: + required: false + type: boolean + default: false + DOWNLOAD_ARTIFACT: + required: false + type: boolean + default: true + ARTIFACT_FILENAME: + required: false + type: string + default: "" + ARTIFACT_PATH: + required: false + type: string + default: ".coverage-reports/" + +env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + +jobs: + sonar-analyze: + runs-on: + labels: ${{ inputs.RUN_ON }} + group: ${{ inputs.RUNNERS_CONTAINER_GROUP }} + container: ${{ inputs.SONAR_IMAGE }} + defaults: + run: + working-directory: ${{ inputs.WORKING_DIRECTORY }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download coverage artifact + if: ${{ inputs.DOWNLOAD_ARTIFACT }} + uses: actions/download-artifact@v3 + with: + name: ${{inputs.ARTIFACT_FILENAME}} + path: ${{ inputs.WORKING_DIRECTORY }}/${{ inputs.ARTIFACT_PATH }} + + - name: Run PRE_SCAN_COMMANDS commands + if: ${{ inputs.PRE_SCAN_COMMANDS != '' }} + run: ${{ inputs.PRE_SCAN_COMMANDS }} + + - name: Run Sonar + run: sonar-scanner -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.qualitygate.wait=${{ inputs.CHECK_QUALITY_GATE }}