88 - master
99 - experimental/**
1010 pull_request :
11+ types : [opened, synchronize, reopened]
1112 branches-ignore :
1213 - master
1314 - experimental/**
@@ -31,22 +32,35 @@ jobs:
3132 distribution : temurin
3233
3334 steps :
34- # Check out Git repository
3535 - name : Checkout code
3636 uses : actions/checkout@v2
37+ with :
38+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
3739
38- # Set up environment with Java and Maven
3940 - name : Setup JDK
4041 uses : actions/setup-java@v2
4142 with :
4243 distribution : ${{ matrix.distribution }}
4344 java-version : ${{ matrix.java }}
4445 cache : ' maven'
4546
46- # Build & install (required for 2nd build: example)
47+ - name : Cache SonarCloud packages
48+ uses : actions/cache@v1
49+ with :
50+ path : ~/.sonar/cache
51+ key : ${{ runner.os }}-sonar
52+ restore-keys : ${{ runner.os }}-sonar
53+
4754 - name : Build and verify
4855 run : ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B -U clean install
4956
50- # Build & verify example
5157 - name : Build and verify example
5258 run : ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B -U clean verify -f example
59+
60+ - name : Analyze in SonarCloud
61+ env :
62+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
63+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
64+ # SONAR_TOKEN is not present when building for external PR
65+ run : ([ -z $SONAR_TOKEN ] || ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B sonar:sonar -Dsonar.projectKey=${{github.repository_owner}}_${{github.event.repository.name}} -Dsonar.projectName=${{github.event.repository.name}})
66+ if : ${{ matrix.java == '11' && matrix.os == 'ubuntu-latest' }}
0 commit comments