Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: SonarCloud

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

permissions:
contents: read
pull-requests: read

jobs:
sonar:
name: SonarCloud analysis
runs-on: ubuntu-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

steps:
# Fork PRs and repos without the secret skip analysis instead of failing.
- name: Check for SONAR_TOKEN
id: token
run: |
if [ -n "$SONAR_TOKEN" ]; then echo "present=true" >> "$GITHUB_OUTPUT"; else echo "present=false" >> "$GITHUB_OUTPUT"; echo "SONAR_TOKEN not set; skipping analysis."; fi

- name: Checkout
if: steps.token.outputs.present == 'true'
uses: actions/checkout@v7
with:
fetch-depth: 0 # full history for blame / new-code detection

- name: Set up Java 17
if: steps.token.outputs.present == 'true'
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Cache SonarCloud packages
if: steps.token.outputs.present == 'true'
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Test and analyze
if: steps.token.outputs.present == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn verify -Dgpg.skip=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751:sonar --no-transfer-progress
33 changes: 32 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Empty default so surefire's @{argLine} resolves when JaCoCo is skipped. -->
<argLine></argLine>

<!-- SonarCloud (analysis runs from .github/workflows/sonar.yml) -->
<sonar.organization>seleniumboot</sonar.organization>
<sonar.projectKey>seleniumboot_selenium-boot</sonar.projectKey>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<dependencies>
Expand Down Expand Up @@ -177,7 +186,7 @@
</dependency>
</dependencies>
<configuration>
<argLine>-Dnet.bytebuddy.experimental=true</argLine>
<argLine>@{argLine} -Dnet.bytebuddy.experimental=true</argLine>
<properties>
<property>
<name>listener</name>
Expand All @@ -187,6 +196,28 @@
</configuration>
</plugin>

<!-- Test coverage for SonarCloud: writes target/site/jacoco/jacoco.xml after `mvn test` -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Embed version in MANIFEST.MF for cross-build-tool compatibility -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Loading