From 0c9eb90f5aba20f77a7c6e1af0d6bb5807e31c23 Mon Sep 17 00:00:00 2001
From: grimsi <9295182+grimsi@users.noreply.github.com>
Date: Fri, 21 Oct 2022 17:30:57 +0200
Subject: [PATCH] Switch CI pipeline to SonarCloud
---
.github/workflows/build.yml | 27 ++++++++++++++++-----------
pom.xml | 5 +++++
sonar-project.properties | 2 --
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fd19a95..bccdfcc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,14 +16,23 @@ jobs:
steps:
- name: Git checkout
uses: actions/checkout@v3
-
+ with:
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
+
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '18'
distribution: 'temurin'
cache: 'maven'
-
+
+ - name: Cache SonarCloud packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+
- name: Extract Maven project version
id: project
run: echo "GAMEYFIN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
@@ -31,15 +40,11 @@ jobs:
- name: Show extracted Maven project version
run: echo "${{ steps.project.outputs.GAMEYFIN_VERSION }}"
- - name: Maven build
- run: mvn --batch-mode --update-snapshots package
-
- - name: SonarQube scan
- uses: kitabisa/sonarqube-action@v1.2.0
- with:
- host: https://sonarqube.grimsi.de
- login: ${{ secrets.SONARQUBE_TOKEN }}
- projectKey: grimsi_gameyfin_AYPM67pzsxiaNzCh9BZd
+ - name: Build and analyze
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=grimsi_gameyfin
- name: Upload build artifact
uses: actions/upload-artifact@v3
diff --git a/pom.xml b/pom.xml
index 4911d82..64af3b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,11 @@
backend
+
+ grimsi-github
+ https://sonarcloud.io
+
+
org.springframework.boot
spring-boot-starter-parent
diff --git a/sonar-project.properties b/sonar-project.properties
index cb0b4b5..efe7579 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,4 +1,2 @@
-sonar.projectKey=grimsi_gameyfin_AYPM67pzsxiaNzCh9BZd
-
# Point SONAR to the compiled Java classes
sonar.java.binaries=./backend/target