Skip to content

Commit b924c59

Browse files
authored
ci: migrate test coverage from CodeClimate to SonarCloud (#140)
1 parent 4e8d1aa commit b924c59

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ name: Publish Test Coverage Report
33
on:
44
push:
55
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
68

79
jobs:
810
publish-code-coverage-report:
9-
name: JAVA
11+
name: JAVA
1012
runs-on: ubuntu-latest
1113
if: "! contains(toJSON(github.event.head_commit.message), 'skip ci')"
1214
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up JDK 8
15-
uses: actions/setup-java@v3
16-
with:
17-
java-version: '8'
18-
distribution: 'temurin'
19-
cache: maven
20-
- name: Upload coverage report
21-
uses: paambaati/[email protected]
22-
env:
23-
# Set CC_TEST_REPORTER_ID as secret of your repo
24-
CC_TEST_REPORTER_ID: ${{secrets.CODE_CLIMATE_TEST_REPORTER_ID}}
25-
JACOCO_SOURCE_PATH: "${{github.workspace}}/src/main/java"
26-
with:
27-
# The report file must be there, otherwise Code Climate won't find it
28-
coverageCommand: mvn test
29-
coverageLocations: ${{github.workspace}}/target/site/jacoco/jacoco.xml:jacoco
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up JDK 8
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '8'
22+
distribution: 'temurin'
23+
cache: maven
24+
25+
- name: Build and Run Tests with Coverage
26+
run: mvn test
27+
28+
- name: SonarQube Scan
29+
if: ${{ github.actor != 'dependabot[bot]' }}
30+
uses: SonarSource/[email protected]
31+
env:
32+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
[![Maven Central][maven-badge]][maven-url]
44
[![Tests][test-badge]][test-url]
55
[![Lint Code][lint-badge]][lint-url]
6-
[![Test Coverage][test-coverage-url]][code-climate-url]
6+
[![Test Coverage][coverage-badge]][coverage-url]
7+
[![Maintainability Rating][maintainability-badge]][maintainability-url]
8+
[![Vulnerabilities][vulnerabilities-badge]][vulnerabilities-url]
79
[![Licence][license-badge]][license-url]
810

911
## Introduction
@@ -100,11 +102,17 @@ Core lib's Maven group ID is `io.apimatic`, and its artifact ID is `core`.
100102

101103
[test-url]: https://github.com/apimatic/core-lib-java/actions/workflows/build-and-test.yml
102104

103-
[code-climate-url]: https://codeclimate.com/github/apimatic/core-lib-java
105+
[coverage-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-java&metric=coverage
104106

105-
[maintainability-url]: https://api.codeclimate.com/v1/badges/74e497222508f9e858d6/maintainability
107+
[coverage-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-java
106108

107-
[test-coverage-url]: https://api.codeclimate.com/v1/badges/74e497222508f9e858d6/test_coverage
109+
[maintainability-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-java&metric=sqale_rating
110+
111+
[maintainability-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-java
112+
113+
[vulnerabilities-badge]: https://sonarcloud.io/api/project_badges/measure?project=apimatic_core-lib-java&metric=vulnerabilities
114+
115+
[vulnerabilities-url]: https://sonarcloud.io/summary/new_code?id=apimatic_core-lib-java
108116

109117
[lint-badge]: https://github.com/apimatic/core-lib-java/actions/workflows/linter.yml/badge.svg
110118

sonar-project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sonar.projectKey=apimatic_core-lib-java
2+
sonar.projectName=APIMatic Core Library for JAVA
3+
sonar.organization=apimatic
4+
sonar.host.url=https://sonarcloud.io
5+
sonar.sourceEncoding=UTF-8
6+
7+
sonar.sources=src/main/java
8+
sonar.tests=src/test/java
9+
10+
sonar.java.binaries=target/classes
11+
12+
sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml

0 commit comments

Comments
 (0)