Skip to content

Commit c600e3d

Browse files
dfa1claude
andcommitted
chore(ci): swap Codecov for SonarCloud
SonarCloud covers coverage + bugs + smells + duplication + security hotspots in one dashboard; Codecov only does coverage and now requires a token even for public repos. CI runs `sonar-maven-plugin:sonar` on the Ubuntu + Java 25 matrix entry after the coverage profile produces jacoco.xml. Full checkout (fetch-depth=0) on that entry only so Sonar can compute line blame / new-code metrics. Scanner cache speeds up subsequent runs. Requires repo secret `SONAR_TOKEN` provisioned from sonarcloud.io. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 400e5b0 commit c600e3d

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v6
21+
with:
22+
# Sonar needs full history for line-level blame / new-code computation.
23+
fetch-depth: ${{ (matrix.os == 'ubuntu-latest' && matrix.java-version == '25') && 0 || 1 }}
2124

2225
- name: Set up Azul Zulu JDK ${{ matrix.java-version }}
2326
uses: actions/setup-java@v5
@@ -33,16 +36,32 @@ jobs:
3336
restore-keys: |
3437
${{ runner.os }}-maven-
3538
39+
- name: Cache SonarCloud packages
40+
if: matrix.os == 'ubuntu-latest' && matrix.java-version == '25'
41+
uses: actions/cache@v5
42+
with:
43+
path: ~/.sonar/cache
44+
key: ${{ runner.os }}-sonar
45+
restore-keys: ${{ runner.os }}-sonar
46+
3647
# vortex-jni 0.74.0 ships native libs for darwin-aarch64 + linux-aarch64
3748
# + linux-amd64 only. No Windows binary, so the modules that pull vortex-jni
3849
# (integration, performance) are skipped on Windows. Being the only Vortex
3950
# impl that runs on Windows JVMs is one of vortex-java's selling points —
4051
# see README "Who is this for".
4152
# JaCoCo coverage is collected only on the Ubuntu + Java 25 entry — running it on
4253
# every matrix entry would produce redundant reports and slow the build.
43-
- name: Build and test (Linux + macOS) with coverage
44-
if: runner.os != 'Windows' && matrix.os == 'ubuntu-latest' && matrix.java-version == '25'
45-
run: ./mvnw verify -P coverage
54+
- name: Build, test, and Sonar analysis (Linux)
55+
if: matrix.os == 'ubuntu-latest' && matrix.java-version == '25'
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
59+
run: |
60+
./mvnw verify -P coverage \
61+
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
62+
-Dsonar.projectKey=dfa1_vortex-java \
63+
-Dsonar.organization=dfa1 \
64+
-Dsonar.host.url=https://sonarcloud.io
4665
4766
- name: Build and test (Linux + macOS) without coverage
4867
if: runner.os != 'Windows' && !(matrix.os == 'ubuntu-latest' && matrix.java-version == '25')
@@ -52,11 +71,3 @@ jobs:
5271
if: runner.os == 'Windows'
5372
shell: bash
5473
run: ./mvnw verify -pl '!integration,!performance'
55-
56-
- name: Upload coverage to Codecov
57-
if: matrix.os == 'ubuntu-latest' && matrix.java-version == '25'
58-
uses: codecov/codecov-action@v5
59-
with:
60-
token: ${{ secrets.CODECOV_TOKEN }}
61-
fail_ci_if_error: false
62-
files: ./**/target/site/jacoco/jacoco.xml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# vortex-java
22

33
[![CI](https://github.com/dfa1/vortex-java/actions/workflows/ci.yml/badge.svg)](https://github.com/dfa1/vortex-java/actions)
4-
[![codecov](https://codecov.io/gh/dfa1/vortex-java/branch/main/graph/badge.svg)](https://codecov.io/gh/dfa1/vortex-java)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dfa1_vortex-java&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dfa1_vortex-java)
5+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=dfa1_vortex-java&metric=coverage)](https://sonarcloud.io/summary/new_code?id=dfa1_vortex-java)
56
[![Maven Central](https://img.shields.io/maven-central/v/io.github.dfa1.vortex/vortex-reader.svg)](https://central.sonatype.com/artifact/io.github.dfa1.vortex/vortex-reader)
67
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/license/Apache-2.0)
78

0 commit comments

Comments
 (0)