Skip to content

Commit

Permalink
feat(ZCH-66): cleanup sonar scan and quality gate steps (#84)
Browse files Browse the repository at this point in the history
* feat(ZCH-66): pass working dir

* fix: fix basedir

* fix: update step

* chore: simplify pipeline

* chore: change default

* chore: remove deprecated code

* chore: add var for quality gate

* chore: restore old sonar flutter

* chore: remove old vars

* chore: rename to flutter
  • Loading branch information
davide-bontempelli-zupit authored Apr 2, 2024
1 parent 119a6b8 commit 4881e51
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 77 deletions.
33 changes: 5 additions & 28 deletions .github/workflows/sonar-step-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,15 @@ on:
SONAR_IMAGE:
required: false
type: string
default: "ghcr.io/zupit-it/pipeline-templates/flutter-sonar-scanner-cli:5.0.1"
default: "sonarsource/sonar-scanner-cli"
SONAR_HOST_URL:
required: false
type: string
default: "https://sonarqube.zupit.software"
DOWNLOAD_ARTIFACT:
CHECK_QUALITY_GATE:
required: false
type: boolean
default: true
ARTIFACT_FILENAME:
required: false
type: string
default: ""
ARTIFACT_PATH:
required: false
type: string
default: ".coverage-reports/"
PRE_SCAN_COMMANDS:
required: false
type: string
default: ""
default: false

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -64,17 +52,6 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
projectBaseDir: ${{ inputs.WORKING_DIRECTORY }}
args: >
-Dsonar.qualitygate.wait=true
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
# Force to fail step after specific time.
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: "Example show SonarQube Quality Gate Status value"
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
-Dsonar.qualitygate.wait=${{ inputs.CHECK_QUALITY_GATE }}
68 changes: 68 additions & 0 deletions .github/workflows/sonar-step-flutter-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Sonar analyze with artifacts

on:
workflow_call:
inputs:
LABELS:
required: true
type: string
WORKING_DIRECTORY:
required: true
type: string
SONAR_IMAGE:
required: false
type: string
default: "sonarsource/sonar-scanner-cli"
SONAR_HOST_URL:
required: false
type: string
default: "https://sonarqube.zupit.software"
DOWNLOAD_ARTIFACT:
required: false
type: boolean
default: true
ARTIFACT_FILENAME:
required: false
type: string
default: ""
ARTIFACT_PATH:
required: false
type: string
default: ".coverage-reports/"
PRE_SCAN_COMMANDS:
required: false
type: string
default: ""
CHECK_QUALITY_GATE:
required: false
type: boolean
default: false

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

jobs:
sonar-analyze:
runs-on: ${{ fromJson(inputs.LABELS) }}
container: ${{ inputs.SONAR_IMAGE }}
defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- 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=${{ inputs.SONAR_HOST_URL }} -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.qualitygate.wait=${{ inputs.CHECK_QUALITY_GATE }}
File renamed without changes.
5 changes: 5 additions & 0 deletions docker/flutter-sonar-scanner-cli/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

docker buildx build -t ghcr.io/zupit-it/pipeline-templates/flutter-sonar-scanner-cli:5.0.1 -t ghcr.io/zupit-it/pipeline-templates/flutter-sonar-scanner-cli:latest -f Dockerfile .
docker push ghcr.io/zupit-it/pipeline-templates/flutter-sonar-scanner-cli:5.0.1
docker push ghcr.io/zupit-it/pipeline-templates/flutter-sonar-scanner-cli:latest
39 changes: 0 additions & 39 deletions docker/sonar-scanner-cli-luca/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions docker/sonar-scanner-cli-luca/build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions docker/sonar-scanner-cli/build.sh

This file was deleted.

0 comments on commit 4881e51

Please sign in to comment.