diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..b4464c0 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,24 @@ +name: SonarCloud + +on: + pull_request: + push: + branches: [ main ] + +jobs: + sonar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '17' + - uses: gradle/actions/setup-gradle@v6 + - run: ./gradlew test jacocoTestReport + - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + run: ./gradlew sonar + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/README.md b/README.md index 87d21b9..a9d94ee 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=BitWeb_montonio-java-sdk&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=BitWeb_montonio-java-sdk) + # Montonio Java SDK A type-safe Java client for the [Montonio](https://montonio.com) payment gateway REST API (V2 + Stargate). Covers payment order lifecycle, payment method discovery, and JWT webhook/return validation. diff --git a/build.gradle b/build.gradle index 88f2c57..ff55dc4 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ plugins { id "org.owasp.dependencycheck" version "12.2.0" id "io.freefair.lombok" version "9.2.0" id "io.github.gradle-nexus.publish-plugin" version "2.0.0" + id "org.sonarqube" version "7.2.3.7755" } group 'ee.bitweb' @@ -35,3 +36,13 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } + +sonar { + properties { + property "sonar.projectKey", "BitWeb_montonio-java-sdk" + property "sonar.organization", "bitweb-oss" + property "sonar.host.url", "https://sonarcloud.io" + property "sonar.coverage.jacoco.xmlReportPaths", + "${layout.buildDirectory.get()}/reports/jacoco/test/jacocoTestReport.xml" + } +} diff --git a/test.gradle b/test.gradle index 5d97125..34ad05d 100644 --- a/test.gradle +++ b/test.gradle @@ -2,6 +2,13 @@ apply plugin: 'jacoco' test { useJUnitPlatform() + finalizedBy jacocoTestReport +} + +jacocoTestReport { + reports { + xml.required = true + } } tasks.register('unitTest', Test) {