Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 88ed986

Browse files
committed
Include sonar analysis in pipeline
1 parent 8ea2101 commit 88ed986

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/ci.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

.github/workflows/pull-request.yml

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

build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,22 @@ plugins {
2525
id 'net.researchgate.release' version "$LIB_RELEASE_PLUGIN_VER"
2626
id "org.springframework.boot" version "$LIB_SPRING_BOOT_VER" apply false
2727
id "com.jfrog.artifactory" version "4.15.1" apply false
28+
id "org.sonarqube" version "3.0"
29+
id "jacoco"
30+
}
31+
32+
sonarqube {
33+
properties {
34+
property "sonar.projectKey", "graphql-java-kickstart_graphql-spring-boot"
35+
property "sonar.organization", "graphql-java-kickstart"
36+
property "sonar.host.url", "https://sonarcloud.io"
37+
}
2838
}
2939

3040
subprojects {
3141
apply plugin: 'idea'
42+
apply plugin: 'jacoco'
43+
apply plugin: 'org.sonarqube'
3244
apply plugin: 'java'
3345
apply plugin: 'java-library'
3446
apply plugin: 'maven-publish'
@@ -76,6 +88,14 @@ subprojects {
7688
}
7789
}
7890

91+
jacocoTestReport {
92+
reports {
93+
xml.enabled = true
94+
html.enabled = false
95+
csv.enabled = false
96+
}
97+
}
98+
7999
idea {
80100
module {
81101
downloadJavadoc = true

0 commit comments

Comments
 (0)