Skip to content

Commit

Permalink
Merge pull request #7 from eclipse-tractusx/feat/workflows/sonarscan-…
Browse files Browse the repository at this point in the history
…main

Feat/workflows/sonarscan main
  • Loading branch information
nicoprow authored Jan 23, 2023
2 parents fbb6cef + 523cfe6 commit 2107ec4
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/sonarscan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Execute SonarCloud Scan with Test Execution
on:
push:
branches:
- main
workflow_call:

jobs:
analyze:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

#Use Maven package cache
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
#Use Sonar cache
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

#Verify with tests and sonar analysis
- name: Verify
run: ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<springmockk.version>3.1.1</springmockk.version>
<assertj.version>3.23.1</assertj.version>
<spring-boot.version>3.0.0</spring-boot.version>
<sonar.organization>catenax</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>bptm</sonar.projectKey>
<sonar.moduleKey>${project.groupId}:${project.artifactId}</sonar.moduleKey>
<sonar.version>3.9.1.2184</sonar.version>
<jacoco.version>0.8.7</jacoco.version>
</properties>
<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -211,6 +217,36 @@
<projectId>automotive.tractusx</projectId>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar.version}</version>
</plugin>
<!-- Creates test coverage report -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit 2107ec4

Please sign in to comment.