Reuse gradle-build cache for Sonar #159
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Gradle Build | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| paths: | |
| - 'gradle/wrapper/**' | |
| - '**/*.gradle.kts' | |
| - '**/*.java' | |
| - '**/gradle-build.yml' | |
| - 'gradle.properties' | |
| pull_request: | |
| branches: [ "master" ] | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - 'gradle/wrapper/**' | |
| - '**/*.gradle.kts' | |
| - '**/*.java' | |
| - '**/gradle-build.yml' | |
| - 'gradle.properties' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check-changes: | |
| name: Check for file changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build-changes: ${{ steps.filter.outputs.build }} | |
| source-changes: ${{ steps.filter.outputs.java }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| build: | |
| - 'gradle/wrapper/**' | |
| - '**/*.gradle.kts' | |
| - '**/gradle-build.yml' | |
| - 'gradle.properties' | |
| java: | |
| - '**/*.java' | |
| gradle-build: | |
| name: Build project with Gradle | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.build-changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build-artifacts: ${{ steps.upload-build-artifacts.outputs.artifact-id }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| add-job-summary-as-pr-comment: on-failure | |
| build-scan-publish: true | |
| build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" | |
| build-scan-terms-of-use-agree: "yes" | |
| cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} | |
| - name: Setup Testcontainers Cloud Client | |
| uses: atomicjar/testcontainers-cloud-setup-action@v1 | |
| with: | |
| token: ${{ secrets.TC_CLOUD_TOKEN }} | |
| - name: Run CI build | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: ./gradlew check --configuration-cache | |
| - name: Terminate Testcontainers Cloud Client active sessions | |
| uses: atomicjar/testcontainers-cloud-setup-action@v1 | |
| with: | |
| action: terminate | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| id: upload-build-artifacts | |
| with: | |
| name: build-artifacts | |
| path: '**/build/' | |
| code-quality: | |
| name: Code Quality with Sonar | |
| needs: [gradle-build, check-changes] | |
| if: ${{ needs.check-changes.outputs.source-changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| add-job-summary-as-pr-comment: on-failure | |
| build-scan-publish: true | |
| build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" | |
| build-scan-terms-of-use-agree: "yes" | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| artifact-ids: ${{ needs.gradle-build.outputs.build-artifacts }} | |
| - name: Publish Sonar report | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: ./gradlew sonar |