Skip to content

Commit

Permalink
ARC-979: Setup Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed Jan 30, 2024
1 parent 6445477 commit 8aaecff
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 29 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Spotless Linter

on:
push:

jobs:
lint:
runs-on: ubuntu-latest
env:
MAVEN_USERNAME: continuousintegration-oviva
MAVEN_PASSWORD: ${{ secrets.MAVEN_REPO_TOKEN }}
permissions:
contents: read
packages: read
checks: write
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
cache: 'maven'
- name: run spotless
id: spotless
run: mvn -B spotless:check
- name: check spotless
if: always()
uses: oviva-ag/checks-action@v1.2.0
with:
name: Check spotless output
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ steps.spotless.outcome }}
41 changes: 41 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit Tests

on:
push:
branches:
- 'main'
pull_request:
types: [ opened, synchronize, reopened ]
paths-ignore:
- '.github/**'

jobs:
test:
env:
MAVEN_USERNAME: continuousintegration-oviva
MAVEN_PASSWORD: ${{ secrets.MAVEN_REPO_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Run unit tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
19 changes: 19 additions & 0 deletions gesundheitsid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,30 @@
<artifactId>slf4j-jdk14</artifactId>
<scope>test</scope>
</dependency>

<!-- BEGIN wiremock // fix for broken dependency convergence -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-helpers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
<!-- END wiremock -->

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-core</artifactId>
Expand Down
196 changes: 167 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<packaging>pom</packaging>

<properties>
<maven.version>3.8.6</maven.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand All @@ -18,15 +20,28 @@
<maven.compiler.release>${maven.compiler.source}</maven.compiler.release>

<version.keycloak>23.0.3</version.keycloak>
<version.jboss-logging>3.5.1.Final</version.jboss-logging>
<version.jboss-logging>3.5.3.Final</version.jboss-logging>
<version.slf4j>2.0.10</version.slf4j>
<version.nimbus-jose-jwt>9.37.3</version.nimbus-jose-jwt>

<spotless-maven-plugin.version>2.41.1</spotless-maven-plugin.version>
<spotless-maven-plugin.google-java-format.version>1.18.1
</spotless-maven-plugin.google-java-format.version>
<jacoco.version>0.8.11</jacoco.version>


<maven-shade.version>3.2.4</maven-shade.version>

<sonar.organization>oviva-ag</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectName>${project.artifactId}</sonar.projectName>
<sonar.projectKey>oviva-ag_keycloak-gesundheitsid</sonar.projectKey>
<sonar.moduleKey>${project.groupId}_${project.artifactId}</sonar.moduleKey>
<sonar.cpd.exclusions></sonar.cpd.exclusions>
<sonar.coverage.exclusions></sonar.coverage.exclusions>
<sonar.coverage.jacoco.xmlReportPaths>
${project.build.directory}/site/jacoco-ut/jacoco.xml,${project.build.directory}/site/jacoco-it/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<licenses>
Expand Down Expand Up @@ -117,7 +132,7 @@
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc5</version>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
Expand All @@ -134,14 +149,14 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>5.9.0</version>
<version>5.10.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.19.3</version>
<version>1.19.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -150,11 +165,60 @@
<artifactId>rest-assured</artifactId>
<version>5.4.0</version>
</dependency>


<!-- BEGIN wiremock // fix for broken dependency convergence & vulnerabilities -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-helpers</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.9.0</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>com.github.jknack</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- END wiremock -->

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-bom</artifactId>
Expand All @@ -172,39 +236,113 @@
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
<configuration>
<java>
<removeUnusedImports/>
<googleJavaFormat>
<version>${spotless-maven-plugin.google-java-format.version}</version>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
<executions>
<execution>
<id>spotless-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>spotless-apply</id>
<phase>compile</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade.version}</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>${maven.version}</version>
</requireMavenVersion>
<reactorModuleConvergence>
<message>The reactor is not valid</message>
</reactorModuleConvergence>
<dependencyConvergence/>
<banDuplicatePomDependencyVersions/>
<banDependencyManagementScope/>
<banCircularDependencies/>
</rules>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<java>
<removeUnusedImports/>
<googleJavaFormat>
<version>${google-java-format.version}</version>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
<executions>
<execution>
<!-- Runs in compile phase to fail fast in case of formatting issues.-->
<id>spotless-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<!-- Runs in compile phase to fail fast in case of formatting issues.-->
<id>spotless-apply</id>
<phase>compile</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

0 comments on commit 8aaecff

Please sign in to comment.