Skip to content

Commit

Permalink
Trigger Sonarcloud analysis from GHA (#143)
Browse files Browse the repository at this point in the history
Only generate coverage info conditionally (with profile "code-coverage")
This closes #140
  • Loading branch information
kwin authored Jun 3, 2024
1 parent a747eb8 commit 43a200d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
java: [ '11', '17', '21' ]
include:
# lengthy build steps should only be performed on linux with Java 17 (Sonarcloud analysis, deployment)
- os: ubuntu-latest
java: '17'
isMainBuildEnv: true
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -27,5 +32,12 @@ jobs:
cache: 'maven'

- name: Build with Maven
if: '!matrix.isMainBuildEnv'
run: ./mvnw verify -e -B -V

- name: Build with Maven (incl. Sonarcloud analysis)
if: 'matrix.isMainBuildEnv'
env:
# SonarCloud access token and project coordinates provided in context of https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/4700
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw verify -Pcode-coverage -e -B -V org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
```

[![build](https://github.com/eclipse/sisu.inject/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/eclipse/sisu.inject/actions/workflows/build.yml)
[![maintainability](https://sonarcloud.io/api/project_badges/measure?project=org.eclipse.sisu%3Asisu-inject&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=org.eclipse.sisu%3Asisu-inject)
[![maintainability](https://sonarcloud.io/api/project_badges/measure?project=eclipse-sisu_sisu.inject&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=eclipse-sisu_sisu.inject)
[![license](https://img.shields.io/badge/license-EPL_1.0-blue.svg)](https://www.eclipse.org/legal/epl-v10.html)

Sisu is a modular [JSR330](https://javax-inject.github.io/javax-inject/)-based container that supports classpath scanning, auto-binding, and dynamic auto-wiring.
Expand Down
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,6 @@ Bundle-DocURL: http://www.eclipse.org/sisu/
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -689,5 +685,16 @@ Bundle-DocURL: http://www.eclipse.org/sisu/
</plugins>
</build>
</profile>
<profile>
<id>code-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 43a200d

Please sign in to comment.