From de3d94c0982fd967796bc8c989e744b52b7889c7 Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:15:56 +0100 Subject: [PATCH 1/8] ci: Add steps before sonarqube analysis --- .github/workflows/sonarqube.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index a1fb952..758dfb8 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -41,6 +41,15 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml - name: Analyze with SonarQube # You can pin the exact commit or the version. From 7d43c63d6a4d5114e825dc4320b8ea99d0f62544 Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:22:08 +0100 Subject: [PATCH 2/8] ci: Add binaries property to sonarqube --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 758dfb8..4df455b 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -66,6 +66,7 @@ jobs: # mandatory -Dsonar.projectKey=Kilowatt-Commando_controller-service -Dsonar.organization=kilowatt-commando + -Dsonar.java.binaries=target/classes # Comma-separated paths to directories containing main source files. #-Dsonar.sources= # optional, default is project base directory # When you need the analysis to take place in a directory other than the one from which it was launched From d730f04b0a5023de946084a140935bccd222d4ad Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:42:13 +0100 Subject: [PATCH 3/8] ci: Change mvn command to run jacoco --- .github/workflows/sonarqube.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 4df455b..36fc285 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -49,7 +49,7 @@ jobs: distribution: 'temurin' cache: maven - name: Build with Maven - run: mvn -B package --file pom.xml + run: mvn clean package jacoco:report - name: Analyze with SonarQube # You can pin the exact commit or the version. From eead1e960821d0800d830f83d0bcd2b013ac01ee Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:49:30 +0100 Subject: [PATCH 4/8] ci: Add test directory property for code analysis --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 36fc285..70ea8d6 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -67,6 +67,7 @@ jobs: -Dsonar.projectKey=Kilowatt-Commando_controller-service -Dsonar.organization=kilowatt-commando -Dsonar.java.binaries=target/classes + -Dsonar.tests=src/test/** # Comma-separated paths to directories containing main source files. #-Dsonar.sources= # optional, default is project base directory # When you need the analysis to take place in a directory other than the one from which it was launched From 6f396b48c97222164ac6bdc4be9e9a57a866aefa Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:51:54 +0100 Subject: [PATCH 5/8] ci: Fix test property --- .github/workflows/sonarqube.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 70ea8d6..eb1020e 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -67,7 +67,7 @@ jobs: -Dsonar.projectKey=Kilowatt-Commando_controller-service -Dsonar.organization=kilowatt-commando -Dsonar.java.binaries=target/classes - -Dsonar.tests=src/test/** + -Dsonar.tests=src/test/ # Comma-separated paths to directories containing main source files. #-Dsonar.sources= # optional, default is project base directory # When you need the analysis to take place in a directory other than the one from which it was launched From 0bffde653c5ccd2eb81152ad6e88f04fe9e00d95 Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:58:35 +0100 Subject: [PATCH 6/8] ci: Add sources property --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index eb1020e..aa47f32 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -68,6 +68,7 @@ jobs: -Dsonar.organization=kilowatt-commando -Dsonar.java.binaries=target/classes -Dsonar.tests=src/test/ + -Dsonar.sources=src/main # Comma-separated paths to directories containing main source files. #-Dsonar.sources= # optional, default is project base directory # When you need the analysis to take place in a directory other than the one from which it was launched From b5512fb466475fd1f5ddc0c02f50b369072bc142 Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:04:27 +0100 Subject: [PATCH 7/8] feat: Add badge to README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21d1b77..517f6d2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Powerplant Controller Service +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Kilowatt-Commando_controller-service&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Kilowatt-Commando_controller-service) + + This repository contains the controller microservice. ## Testcontainers @@ -32,4 +35,4 @@ docker run \ -e KAFKA_BROKER= \ -e KAFKA_BROKER_PORT= \ kwkmdo-controller -``` \ No newline at end of file +``` From 9d7a05aea98ffb04550968e6f0824b799baccc5d Mon Sep 17 00:00:00 2001 From: Clemi2806 <38780028+Clemi2806@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:10:41 +0100 Subject: [PATCH 8/8] feat: Add more badges to Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 517f6d2..f7da45f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Powerplant Controller Service [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Kilowatt-Commando_controller-service&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Kilowatt-Commando_controller-service) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Kilowatt-Commando_controller-service&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Kilowatt-Commando_controller-service) +[![SonarQube Cloud](https://sonarcloud.io/images/project_badges/sonarcloud-highlight.svg)](https://sonarcloud.io/summary/new_code?id=Kilowatt-Commando_controller-service) This repository contains the controller microservice.