Skip to content

Commit

Permalink
Use sonarqube-action
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Jun 17, 2023
1 parent ec37dc5 commit 370fec9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 50 deletions.
56 changes: 6 additions & 50 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,53 +67,9 @@ jobs:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
#Configuracion inicial recomendada por sonarCloud
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

#compilar antes de restaurar reports y realizar el analisis
- name: Generate classes
run: mvn test-compile
- name: Restore test reports
uses: actions/download-artifact@v3
with:
name: test-reports-for-sonar
path: target

#El plugin de maven no lee el archivo sonar-project.properties ni .sonarcloud.properties, ejecuta el scanner de forma manual
#- name: SonarQube Analysis
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=my:samples-test-java -Dsonar.organization=giis -Dproject.settings=sonar-project.properties
- name: Download sonarscanner
run: curl --insecure -o ./sonarscanner.zip -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip && unzip -q sonarscanner.zip
- name: SonarQube Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=my:samples-test-java -Dsonar.organization=giis
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: javiertuya/sonarqube-action@v1.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
restore-artifact-name1: "test-reports-for-sonar"
restore-artifact-path1: "target"
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sonar.projectKey=my:samples-test-java
sonar.organization=giis
sonar.projectVersion=1.0
sonar.language=java
sonar.java.source=1.8
Expand Down

0 comments on commit 370fec9

Please sign in to comment.