Skip to content

Include Sonar analysis on PRs #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches-ignore:
- master
pull_request:

types: [opened, synchronize, reopened]
jobs:
validation:
name: Gradle Wrapper Validation
Expand Down Expand Up @@ -49,3 +49,32 @@ jobs:
if: matrix.os == 'windows-latest'
shell: cmd
run: gradlew --info check
build:
name: Sonar analysis
needs: validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonarqube --info
29 changes: 29 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,32 @@ jobs:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_PASS: ${{ secrets.BINTRAY_PASSWORD }}
run: ./gradlew artifactoryPublish -Dsnapshot=true -Dbuild.number=${{ env.GITHUB_RUN_NUMBER }}
sonar:
name: Sonar analysis
needs: validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonarqube --info
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ plugins {
id 'io.franzbecker.gradle-lombok' version '3.2.0' apply false
id "com.jfrog.artifactory" version "4.11.0" apply false
id "biz.aQute.bnd.builder" version "5.1.2" apply false
id "org.sonarqube" version "3.0"
id "jacoco"
}

sonarqube {
properties {
property "sonar.projectKey", "graphql-java-kickstart_graphql-java-servlet"
property "sonar.organization", "graphql-java-kickstart"
property "sonar.host.url", "https://sonarcloud.io"
}
}

subprojects {
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.bintray"
Expand Down Expand Up @@ -75,6 +87,13 @@ subprojects {
sha256 = ""
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = false
csv.enabled = false
}
}

if (!it.name.startsWith('example')) {

Expand Down