|
| 1 | +name: "Pull request" |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, synchronize, reopened] |
| 5 | +jobs: |
| 6 | + validation: |
| 7 | + name: Gradle Wrapper Validation |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v2 |
| 11 | + - uses: gradle/wrapper-validation-action@v1 |
| 12 | + test: |
| 13 | + name: Test run |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ ubuntu-latest, macos-latest, windows-latest ] |
| 18 | + java: [ 8, 11, 15 ] |
| 19 | + needs: validation |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + - name: Setup Java |
| 25 | + uses: actions/setup-java@v1 |
| 26 | + with: |
| 27 | + java-version: ${{ matrix.java }} |
| 28 | + - name: Cache Gradle |
| 29 | + uses: actions/cache@v2 |
| 30 | + env: |
| 31 | + java-version: ${{ matrix.java }} |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.gradle/caches |
| 35 | + ~/.gradle/wrapper |
| 36 | + key: ${{ runner.os }}-${{ env.java-version }}-gradle-${{ hashFiles('**/*.gradle*') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-${{ env.java-version }}-gradle- |
| 39 | + - name: Make gradlew executable (non-Windows only) |
| 40 | + if: matrix.os != 'windows-latest' |
| 41 | + run: chmod +x ./gradlew |
| 42 | + - name: Gradle Check (non-Windows) |
| 43 | + if: matrix.os != 'windows-latest' |
| 44 | + run: ./gradlew --info check |
| 45 | + - name: Gradle Check (Windows) |
| 46 | + if: matrix.os == 'windows-latest' |
| 47 | + shell: cmd |
| 48 | + run: gradlew --info check |
| 49 | + build: |
| 50 | + name: Sonar analysis |
| 51 | + needs: validation |
| 52 | + runs-on: ubuntu-latest |
| 53 | + env: |
| 54 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v2 |
| 57 | + if: env.SONAR_TOKEN != null |
| 58 | + with: |
| 59 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 60 | + - name: Set up JDK 11 |
| 61 | + if: env.SONAR_TOKEN != null |
| 62 | + uses: actions/setup-java@v1 |
| 63 | + with: |
| 64 | + java-version: 11 |
| 65 | + - name: Cache SonarCloud packages |
| 66 | + if: env.SONAR_TOKEN != null |
| 67 | + uses: actions/cache@v1 |
| 68 | + with: |
| 69 | + path: ~/.sonar/cache |
| 70 | + key: ${{ runner.os }}-sonar |
| 71 | + restore-keys: ${{ runner.os }}-sonar |
| 72 | + - name: Cache Gradle packages |
| 73 | + if: env.SONAR_TOKEN != null |
| 74 | + uses: actions/cache@v1 |
| 75 | + with: |
| 76 | + path: ~/.gradle/caches |
| 77 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 78 | + restore-keys: ${{ runner.os }}-gradle |
| 79 | + - name: Build and analyze |
| 80 | + if: env.SONAR_TOKEN != null |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 83 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 84 | + run: ./gradlew build jacocoTestReport sonarqube --info |
0 commit comments