Skip to content

Commit fa29a9b

Browse files
committed
Include Sonar analysis on PRs
1 parent c5609b7 commit fa29a9b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.github/workflows/pull-request.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,31 @@ jobs:
4949
if: matrix.os == 'windows-latest'
5050
shell: cmd
5151
run: gradlew --info check
52+
build:
53+
name: Sonar analysis
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v2
57+
with:
58+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
59+
- name: Set up JDK 11
60+
uses: actions/setup-java@v1
61+
with:
62+
java-version: 11
63+
- name: Cache SonarCloud packages
64+
uses: actions/cache@v1
65+
with:
66+
path: ~/.sonar/cache
67+
key: ${{ runner.os }}-sonar
68+
restore-keys: ${{ runner.os }}-sonar
69+
- name: Cache Gradle packages
70+
uses: actions/cache@v1
71+
with:
72+
path: ~/.gradle/caches
73+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
74+
restore-keys: ${{ runner.os }}-gradle
75+
- name: Build and analyze
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
78+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
79+
run: ./gradlew build sonarqube --info

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ plugins {
3737
id 'io.franzbecker.gradle-lombok' version '3.2.0' apply false
3838
id "com.jfrog.artifactory" version "4.11.0" apply false
3939
id "biz.aQute.bnd.builder" version "5.1.2" apply false
40+
id "org.sonarqube" version "3.0"
41+
}
42+
43+
sonarqube {
44+
properties {
45+
property "sonar.projectKey", "graphql-java-kickstart_graphql-java-servlet"
46+
property "sonar.organization", "graphql-java-kickstart"
47+
property "sonar.host.url", "https://sonarcloud.io"
48+
}
4049
}
4150

4251
subprojects {

0 commit comments

Comments
 (0)