Skip to content

Commit

Permalink
add in sonar task for hooking into SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkorynta committed Jun 13, 2024
1 parent e9ea0fa commit 9bee654
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Build cwms-data-api-client
on:
push:
pull_request:
branches:
- main
Expand All @@ -18,6 +17,12 @@ jobs:
java-version: '21'
java-package: jdk
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/[email protected]
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: build and test
id: thebuild
run: ./gradlew build --info --init-script init.gradle
Expand All @@ -26,6 +31,11 @@ jobs:
with:
dotnet-version: 6.x
dotnet-quality: 'ga'
- name: Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar
- name: ReportGenerator
uses: danielpalme/[email protected]
with:
Expand Down
43 changes: 43 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
/*
* MIT License
*
* Copyright (c) 2024 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

plugins {
id "com.palantir.git-version" version "3.1.0"
id("org.sonarqube") version "5.0.0.4638"
}

def versionLabel(gitInfo) {
Expand Down Expand Up @@ -43,4 +68,22 @@ subprojects {
html.outputLocation = layout.buildDirectory.dir('jacoco')
}
}
sonarqube {
properties {
property "sonar.sources", "src/main/java"
property "sonar.tests", "src/test/java"
property 'sonar.coverage.jacoco.xmlReportPaths', "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}
}

sonar {
properties {
property "sonar.projectKey", "cwms_data_api_client"
property "sonar.organization", "HydrologicEngineeringCenter"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.pullrequest.provider", "GitHub"
property "sonar.pullrequest.github.repository", "HydrologicEngineeringCenter/cwms-data-api-client"
property "sonar.projectVersion", versionDetails().lastTag + "+"
}
}

0 comments on commit 9bee654

Please sign in to comment.