Skip to content

Commit

Permalink
Add backend analysis with sonar cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcell Dechant committed May 21, 2024
1 parent 10e6164 commit c0bd254
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/sonar-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Analyze 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@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 22
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'temurin' # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
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 }}
working-directory: ./backend
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=neuefische_java-curriculum-6-java-02-Fullstack-Project-backend
21 changes: 21 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<description>backend</description>
<properties>
<java.version>22</java.version>
<sonar.organization>neuefische</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -46,6 +48,25 @@

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions backend/src/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tells Lombok that this is the root directory and that it shouldn’t search parent directories for more configuration files
config.stopBubbling = true
# tells Lombok to add @lombok.Generated annotation to all generated methods
lombok.addLombokGeneratedAnnotation = true

0 comments on commit c0bd254

Please sign in to comment.