Skip to content

Commit

Permalink
Trigger Sonarcloud analysis from GHA
Browse files Browse the repository at this point in the history
Only generate coverage info conditionally (with profile "code-coverage")
  • Loading branch information
kwin committed Jun 3, 2024
1 parent d88c5f0 commit a50291b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 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=org.eclipse.sisu:sisu-inject -Dsonar.organization=eclipse
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 a50291b

Please sign in to comment.