Skip to content

Commit

Permalink
Move Sonar to common build
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Aug 13, 2024
1 parent 83ddef5 commit 74e60ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
required: true
type: string
default: '17'
run-sonar:
required: false
type: boolean
default: false
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,6 +48,23 @@ jobs:
- name: Execute Gradle build
run: ./gradlew clean check integrationTest --scan --stacktrace

- name: Cache SonarCloud packages
uses: actions/cache@v4
if: ${{ inputs.run-sonar }}
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Analyze with SonarCloud
if: ${{ inputs.run-sonar }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
./gradlew sonar -Psonar.branch.name=${BRANCH_NAME} --info --scan
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
uses: ./.github/workflows/build-artifacts.yml
with:
java-version: '17'
run-sonar: true

post-build:
needs: build-artifacts
Expand Down Expand Up @@ -45,21 +46,6 @@ jobs:
with:
workflow: test-java-os-mix.yml

- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
./gradlew sonar -Psonar.branch.name=${BRANCH_NAME} --info --scan
- name: Collect state upon failure
if: failure()
run: |
Expand Down

0 comments on commit 74e60ef

Please sign in to comment.