diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index e6f3777..8ff5094 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -21,7 +21,55 @@ jobs: java-version: '25' - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d - name: Build with Gradle - run: ./gradlew clean build \ No newline at end of file + run: ./gradlew clean build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: | + build/classes + build/libs + build/test-results + retention-days: 1 + + sonarcloud: + name: SonarCloud Analysis + needs: build-and-test + runs-on: ubuntu-latest + + steps: + - name: Checkout code (full history for PR analysis) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 25 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '25' + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifact + path: build + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: > + -Dsonar.host.url=https://sonarcloud.io + -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} + -Dsonar.sources=. + -Dsonar.java.binaries=build/classes/java/main + -Dsonar.java.test.binaries=build/classes/java/test + -Dsonar.junit.reportPaths=build/test-results/test \ No newline at end of file diff --git a/src/main/java/com/devoops/backend_poc/controller/TestController.java b/src/main/java/com/devoops/backend_poc/controller/TestController.java index be5de38..4c973cc 100644 --- a/src/main/java/com/devoops/backend_poc/controller/TestController.java +++ b/src/main/java/com/devoops/backend_poc/controller/TestController.java @@ -33,4 +33,5 @@ public String test() { MDC.remove("requestId"); } } + } \ No newline at end of file