mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:25:50 +00:00
Update sonarcloud.yml [skip ci]
This commit is contained in:
parent
15ebe2c3f3
commit
1a193e0ed2
1 changed files with 7 additions and 8 deletions
15
.github/workflows/sonarcloud.yml
vendored
15
.github/workflows/sonarcloud.yml
vendored
|
@ -13,43 +13,36 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 17
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
|
|
||||||
- name: Cache SonarQube packages
|
- name: Cache SonarQube packages
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.sonar/cache
|
path: ~/.sonar/cache
|
||||||
key: ${{ runner.os }}-sonar
|
key: ${{ runner.os }}-sonar
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
restore-keys: ${{ runner.os }}-m2
|
restore-keys: ${{ runner.os }}-m2
|
||||||
|
|
||||||
- name: Build and Test with Coverage
|
- name: Build and Test with Coverage
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
run: mvn -B verify jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=adhl-0216_MTU-DevOps-spring-petclinic
|
run: mvn -B verify jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=adhl-0216_MTU-DevOps-spring-petclinic
|
||||||
|
|
||||||
- name: Check Code Coverage
|
- name: Check Code Coverage
|
||||||
run: |
|
run: |
|
||||||
# Extract coverage percentage from JaCoCo report
|
|
||||||
COVERAGE=$(mvn jacoco:report -q -Dquiet=true && grep -oP '(?<=<td class="right" data-value=")[0-9.]+(?=")' target/site/jacoco/index.html | head -1)
|
COVERAGE=$(mvn jacoco:report -q -Dquiet=true && grep -oP '(?<=<td class="right" data-value=")[0-9.]+(?=")' target/site/jacoco/index.html | head -1)
|
||||||
echo "Code Coverage: $COVERAGE%"
|
echo "Code Coverage: $COVERAGE%"
|
||||||
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
|
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
|
||||||
echo "Coverage $COVERAGE% is below 80%. Failing the build."
|
echo "Coverage $COVERAGE% is below 80%. Failing the build."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check SonarCloud Quality Gate
|
- name: Check SonarCloud Quality Gate
|
||||||
uses: SonarSource/sonarcloud-github-action@master
|
uses: SonarSource/sonarcloud-github-action@master
|
||||||
with:
|
with:
|
||||||
|
@ -58,3 +51,9 @@ jobs:
|
||||||
-Dsonar.qualitygate.wait=true
|
-Dsonar.qualitygate.wait=true
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
- name: Send Slack Notification (SonarCloud Complete, Pending Docker Push Review)
|
||||||
|
uses: slackapi/slack-github-action@v1.24.0
|
||||||
|
with:
|
||||||
|
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||||
|
channel-id: 'ci-notifications'
|
||||||
|
text: "SonarCloud Analysis Complete: ${{ job.status }} for commit ${{ github.sha }}. Docker Hub push is pending review in GitHub Actions."
|
||||||
|
|
Loading…
Reference in a new issue