run sonarqube as part of the CI

This commit is contained in:
Athou
2025-07-19 11:11:05 +02:00
parent 78d2e66c56
commit 3f2b93f1f8
2 changed files with 47 additions and 1 deletions

38
.github/workflows/sonar.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: SonarQube
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
env:
JAVA_VERSION: 21
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
# Setup
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "temurin"
cache: "maven"
- name: Install Playwright dependencies
run: sudo apt-get install -y libgbm1
# Run test coverage and SonarQube analysis
- name: Analyze with SonarQube
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn --batch-mode verify sonar:sonar -Dsonar.projectKey=Athou_commafeed

10
pom.xml
View File

@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -12,6 +12,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<sonar.organization>athou</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<build>
@@ -38,6 +41,11 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.1.0.4751</version>
</plugin>
</plugins>
</build>