From be2e4113e7b694bd28bdce2d8aa667918ff6d28a Mon Sep 17 00:00:00 2001 From: daniel-pohl Date: Fri, 31 May 2024 15:53:23 +0200 Subject: [PATCH 1/2] Setup Sonarcloud First step of project --- .github/workflows/sonarcloud-backend.yml | 37 +++++++++++++++++++++++ .github/workflows/sonarcloud-frontend.yml | 20 ++++++++++++ backend/pom.xml | 30 +++++++++++++++--- frontend/sonar-project.properties | 13 ++++++++ 4 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/sonarcloud-backend.yml create mode 100644 .github/workflows/sonarcloud-frontend.yml create mode 100644 frontend/sonar-project.properties diff --git a/.github/workflows/sonarcloud-backend.yml b/.github/workflows/sonarcloud-backend.yml new file mode 100644 index 0000000..8ef8604 --- /dev/null +++ b/.github/workflows/sonarcloud-backend.yml @@ -0,0 +1,37 @@ +name: SonarCloud Backend +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 22 + uses: actions/setup-java@v3 + with: + java-version: 22 + distribution: 'zulu' # Alternative distribution options are available. + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - 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=neuefische_hh-java-24-2-teamproject-2_backend --file backend/pom.xml \ No newline at end of file diff --git a/.github/workflows/sonarcloud-frontend.yml b/.github/workflows/sonarcloud-frontend.yml new file mode 100644 index 0000000..86cc7bf --- /dev/null +++ b/.github/workflows/sonarcloud-frontend.yml @@ -0,0 +1,20 @@ +name: Build Frontend +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml index c2e9bbd..19365b2 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -15,6 +15,9 @@ backend 22 + neuefische + https://sonarcloud.io + neuefische_hh-java-24-2-teamproject-2_backend @@ -46,10 +49,29 @@ org.springframework.boot spring-boot-maven-plugin - - maven-surefire-plugin - 3.2.5 - + + maven-surefire-plugin + 3.2.5 + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + + prepare-agent + + + + report + test + + report + + + + diff --git a/frontend/sonar-project.properties b/frontend/sonar-project.properties new file mode 100644 index 0000000..bf20d84 --- /dev/null +++ b/frontend/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=neuefische_hh-java-24-2-teamproject-2_frontend +sonar.organization=neuefische + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=neuefische_hh-java-24-2-teamproject-2_frontend +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=./frontend/src + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 \ No newline at end of file From 025752ab21c0e5052c8c295f046fb94db3485024 Mon Sep 17 00:00:00 2001 From: daniel-pohl Date: Fri, 31 May 2024 15:53:23 +0200 Subject: [PATCH 2/2] Setup Sonarcloud First step of project --- .github/workflows/sonarcloud-backend.yml | 2 -- .github/workflows/sonarcloud-frontend.yml | 2 -- frontend/sonar-project.properties => sonar-project.properties | 0 3 files changed, 4 deletions(-) rename frontend/sonar-project.properties => sonar-project.properties (100%) diff --git a/.github/workflows/sonarcloud-backend.yml b/.github/workflows/sonarcloud-backend.yml index 8ef8604..6b34b0b 100644 --- a/.github/workflows/sonarcloud-backend.yml +++ b/.github/workflows/sonarcloud-backend.yml @@ -1,8 +1,6 @@ name: SonarCloud Backend on: push: - branches: - - main pull_request: types: [opened, synchronize, reopened] jobs: diff --git a/.github/workflows/sonarcloud-frontend.yml b/.github/workflows/sonarcloud-frontend.yml index 86cc7bf..c4ef4e3 100644 --- a/.github/workflows/sonarcloud-frontend.yml +++ b/.github/workflows/sonarcloud-frontend.yml @@ -1,8 +1,6 @@ name: Build Frontend on: push: - branches: - - main pull_request: types: [opened, synchronize, reopened] jobs: diff --git a/frontend/sonar-project.properties b/sonar-project.properties similarity index 100% rename from frontend/sonar-project.properties rename to sonar-project.properties