Skip to content

Commit

Permalink
chore(ZCH-127): added missing sonar change_detections
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-sartori-zupit committed Nov 17, 2024
1 parent 75e0df1 commit e79ef12
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 1 deletion.
43 changes: 42 additions & 1 deletion .github/workflows/sonar-step-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,46 @@ on:
required: false
type: string
default: ".coverage-reports/"

CHECK_WORKDIR_CHANGES:
required: true
type: boolean
default: false
CHECK_CUSTOM_DIR:
required: false
type: string
default: ""
CHECK_CHANGES_BY_JOBS:
required: false
type: string
default: "all"
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }}

jobs:
workdir-has-changes:
runs-on: ubuntu-latest
outputs:
changes-detected: ${{ steps.filter.outputs.changes-detected }}
steps:
- name: Set CHECK_DIR to custom directory if provided
if: ${{ inputs.CHECK_CUSTOM_DIR != '' }}
run: echo "CHECK_DIR=${{ inputs.CHECK_CUSTOM_DIR }}" >> $GITHUB_ENV
- name: Set default CHECK_DIR
if: ${{ inputs.CHECK_CUSTOM_DIR == '' }}
run: echo "CHECK_DIR=${{ inputs.WORKING_DIRECTORY }}" >> $GITHUB_ENV

- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changes-detected:
- "${{ env.CHECK_DIR }}/**"
sonar-analyze:
needs: workdir-has-changes
if: ${{ !inputs.CHECK_WORKDIR_CHANGES || (needs.workdir-has-changes.outputs.changes-detected == 'true' && (inputs.CHECK_CHANGES_BY_JOBS == 'all' || contains(fromJson(inputs.CHECK_CHANGES_BY_JOBS), github.job)))}}
runs-on:
labels: ${{ inputs.RUN_ON }}
group: ${{ inputs.RUNNERS_CONTAINER_GROUP }}
Expand Down Expand Up @@ -68,3 +101,11 @@ jobs:
ARTIFACT_FILENAME: ${{ inputs.ARTIFACT_FILENAME }}
ARTIFACT_PATH: ${{ inputs.ARTIFACT_PATH }}
env: "${{secrets}}"

jobs-succeded:
needs: ["sonar-analyze"]
runs-on: ubuntu-latest
if: ${{ always()}}
steps:
- name: "Jobs: sonar-analyze didn't fail."
run: if [[ "${{ needs.sonar-analyze.result }}" == "failure" ]]; then exit 1; fi
43 changes: 43 additions & 0 deletions .github/workflows/sonar-step-flutter-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,48 @@ on:
required: false
type: boolean
default: false
CHECK_WORKDIR_CHANGES:
required: true
type: boolean
default: false
CHECK_CUSTOM_DIR:
required: false
type: string
default: ""
CHECK_CHANGES_BY_JOBS:
required: false
type: string
default: "all"

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }}

jobs:
workdir-has-changes:
runs-on: ubuntu-latest
outputs:
changes-detected: ${{ steps.filter.outputs.changes-detected }}
steps:
- name: Set CHECK_DIR to custom directory if provided
if: ${{ inputs.CHECK_CUSTOM_DIR != '' }}
run: echo "CHECK_DIR=${{ inputs.CHECK_CUSTOM_DIR }}" >> $GITHUB_ENV
- name: Set default CHECK_DIR
if: ${{ inputs.CHECK_CUSTOM_DIR == '' }}
run: echo "CHECK_DIR=${{ inputs.WORKING_DIRECTORY }}" >> $GITHUB_ENV

- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changes-detected:
- "${{ env.CHECK_DIR }}/**"
sonar-analyze:
needs: workdir-has-changes
if: ${{ !inputs.CHECK_WORKDIR_CHANGES || (needs.workdir-has-changes.outputs.changes-detected == 'true' && (inputs.CHECK_CHANGES_BY_JOBS == 'all' || contains(fromJson(inputs.CHECK_CHANGES_BY_JOBS), github.job)))}}
runs-on:
labels: ${{ inputs.RUN_ON }}
group: ${{ inputs.RUNNERS_CONTAINER_GROUP }}
Expand All @@ -71,3 +106,11 @@ jobs:

- 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 }}

jobs-succeded:
needs: ["sonar-analyze"]
runs-on: ubuntu-latest
if: ${{ always()}}
steps:
- name: "Jobs: sonar-analyze didn't fail."
run: if [[ "${{ needs.sonar-analyze.result }}" == "failure" ]]; then exit 1; fi
43 changes: 43 additions & 0 deletions .github/workflows/sonar-step-springboot-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,48 @@ on:
required: false
type: string
default: ""
CHECK_WORKDIR_CHANGES:
required: true
type: boolean
default: false
CHECK_CUSTOM_DIR:
required: false
type: string
default: ""
CHECK_CHANGES_BY_JOBS:
required: false
type: string
default: "all"

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
CHECK_DIR: ${{ inputs.WORKING_DIRECTORY }}

jobs:
workdir-has-changes:
runs-on: ubuntu-latest
outputs:
changes-detected: ${{ steps.filter.outputs.changes-detected }}
steps:
- name: Set CHECK_DIR to custom directory if provided
if: ${{ inputs.CHECK_CUSTOM_DIR != '' }}
run: echo "CHECK_DIR=${{ inputs.CHECK_CUSTOM_DIR }}" >> $GITHUB_ENV
- name: Set default CHECK_DIR
if: ${{ inputs.CHECK_CUSTOM_DIR == '' }}
run: echo "CHECK_DIR=${{ inputs.WORKING_DIRECTORY }}" >> $GITHUB_ENV

- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
changes-detected:
- "${{ env.CHECK_DIR }}/**"
sonar-analyze:
needs: workdir-has-changes
if: ${{ !inputs.CHECK_WORKDIR_CHANGES || (needs.workdir-has-changes.outputs.changes-detected == 'true' && (inputs.CHECK_CHANGES_BY_JOBS == 'all' || contains(fromJson(inputs.CHECK_CHANGES_BY_JOBS), github.job)))}}
runs-on:
labels: ${{ inputs.RUN_ON }}
group: ${{ inputs.RUNNERS_CONTAINER_GROUP }}
Expand All @@ -76,3 +111,11 @@ jobs:

- name: Run Sonar
run: ./mvnw -ntp initialize sonar:sonar -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.qualitygate.wait=${{ inputs.CHECK_QUALITY_GATE }}

jobs-succeded:
needs: ["sonar-analyze"]
runs-on: ubuntu-latest
if: ${{ always()}}
steps:
- name: "Jobs: sonar-analyze didn't fail."
run: if [[ "${{ needs.sonar-analyze.result }}" == "failure" ]]; then exit 1; fi

0 comments on commit e79ef12

Please sign in to comment.