Skip to content

Commit 6ca9d34

Browse files
committed
Build sonar
1 parent f85a8f2 commit 6ca9d34

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

.github/workflows/pull-request.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches-ignore:
55
- master
66
pull_request:
7+
types: [opened, synchronize, reopened]
78

89
jobs:
910
validation:
@@ -49,3 +50,39 @@ jobs:
4950
if: matrix.os == 'windows-latest'
5051
shell: cmd
5152
run: gradlew --info check
53+
build:
54+
name: Sonar analysis
55+
needs: validation
56+
runs-on: ubuntu-latest
57+
env:
58+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
59+
steps:
60+
- uses: actions/checkout@v2
61+
if: env.SONAR_TOKEN != null
62+
with:
63+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
64+
- name: Set up JDK 11
65+
if: env.SONAR_TOKEN != null
66+
uses: actions/setup-java@v1
67+
with:
68+
java-version: 11
69+
- name: Cache SonarCloud packages
70+
if: env.SONAR_TOKEN != null
71+
uses: actions/cache@v1
72+
with:
73+
path: ~/.sonar/cache
74+
key: ${{ runner.os }}-sonar
75+
restore-keys: ${{ runner.os }}-sonar
76+
- name: Cache Gradle packages
77+
if: env.SONAR_TOKEN != null
78+
uses: actions/cache@v1
79+
with:
80+
path: ~/.gradle/caches
81+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
82+
restore-keys: ${{ runner.os }}-gradle
83+
- name: Build and analyze
84+
if: env.SONAR_TOKEN != null
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
87+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
88+
run: ./gradlew build jacocoTestReport sonarqube --info

.github/workflows/snapshot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,32 @@ jobs:
6666
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
6767
BINTRAY_PASS: ${{ secrets.BINTRAY_PASSWORD }}
6868
run: ./gradlew artifactoryPublish -Dsnapshot=true -Dbuild.number=${{ env.GITHUB_RUN_NUMBER }}
69+
sonar:
70+
name: Sonar analysis
71+
needs: validation
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
with:
76+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
77+
- name: Set up JDK 11
78+
uses: actions/setup-java@v1
79+
with:
80+
java-version: 11
81+
- name: Cache SonarCloud packages
82+
uses: actions/cache@v1
83+
with:
84+
path: ~/.sonar/cache
85+
key: ${{ runner.os }}-sonar
86+
restore-keys: ${{ runner.os }}-sonar
87+
- name: Cache Gradle packages
88+
uses: actions/cache@v1
89+
with:
90+
path: ~/.gradle/caches
91+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
92+
restore-keys: ${{ runner.os }}-gradle
93+
- name: Build and analyze
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
96+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
97+
run: ./gradlew build jacocoTestReport sonarqube --info

build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ plugins {
33
id 'net.researchgate.release' version "$LIB_RELEASE_PLUGIN_VER"
44
id "org.springframework.boot" version "$LIB_SPRING_BOOT_VER" apply false
55
id "com.jfrog.artifactory" version "4.15.1" apply false
6+
id "org.sonarqube" version "3.0"
7+
id "jacoco"
8+
}
9+
10+
sonarqube {
11+
properties {
12+
property "sonar.projectKey", "graphql-java-kickstart_graphql-spring-webclient"
13+
property "sonar.organization", "graphql-java-kickstart"
14+
property "sonar.host.url", "https://sonarcloud.io"
15+
}
616
}
717

818
subprojects {
@@ -71,6 +81,14 @@ subprojects {
7181
withJavadocJar()
7282
}
7383

84+
jacocoTestReport {
85+
reports {
86+
xml.enabled = true
87+
html.enabled = false
88+
csv.enabled = false
89+
}
90+
}
91+
7492
publishing {
7593
publications {
7694
mainProjectPublication(MavenPublication) {

0 commit comments

Comments
 (0)