diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml
index 6929411a957..4f32ec1126e 100644
--- a/.github/workflows/build-pr.yml
+++ b/.github/workflows/build-pr.yml
@@ -42,13 +42,19 @@ jobs:
java-version: 21
distribution: 'temurin'
cache: 'maven'
-
- name: Kjør enhetstester
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
- mvn -B --no-transfer-progress verify --settings .m2/maven-settings.xml --file pom.xml -DexcludedGroups=integration,verdikjedetest
+ mvn verify -B --no-transfer-progress --settings .m2/maven-settings.xml --file pom.xml -DexcludedGroups=integration,verdikjedetest -Pjacoco -DjacocoTestDirectory=UT
+ - name: Last opp Jacoco UT rapport
+ uses: actions/upload-artifact@v4
+ with:
+ name: jacocoUT
+ path: target/jacoco/UT/jacoco.xml
+ retention-days: 1
+ overwrite: true
integrasjonstester:
name: Integrasjonstester
@@ -60,13 +66,56 @@ jobs:
java-version: 21
distribution: 'temurin'
cache: 'maven'
-
- name: Kjør integrasjonstester
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
- mvn -B --no-transfer-progress verify --settings .m2/maven-settings.xml --file pom.xml -Dgroups=integration -DexcludedGroups=verdikjedetest -Dsurefire.rerunFailingTestsCount=2
+ mvn verify -B --no-transfer-progress --settings .m2/maven-settings.xml --file pom.xml -Dgroups=integration -DexcludedGroups=verdikjedetest -Dsurefire.rerunFailingTestsCount=2 -Pjacoco -DjacocoTestDirectory=IT
+ - name: Last opp Jacoco IT rapport
+ uses: actions/upload-artifact@v4
+ with:
+ name: jacocoIT
+ path: target/jacoco/IT/jacoco.xml
+ retention-days: 1
+ overwrite: true
+
+ sonar:
+ name: Sonar
+ runs-on: ubuntu-latest-8-cores
+ needs: [ enhetstester, integrasjonstester ]
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-java@v4
+ with:
+ java-version: 21
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Last ned Jacoco UT rapport
+ uses: actions/download-artifact@v4
+ with:
+ name: jacocoUT
+ path: jacoco/UT
+ - name: Last ned Jacoco IT rapport
+ uses: actions/download-artifact@v4
+ with:
+ name: jacocoIT
+ path: jacoco/IT
+ - name: Cache Sonar packages
+ uses: actions/cache@v4
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+ - name: Kjør Sonar
+ env:
+ GITHUB_USERNAME: x-access-token
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: |
+ mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths="jacoco/UT/jacoco.xml,jacoco/IT/jacoco.xml"
verdikjedetesterFeatureToggleOff:
name: Verdikjedetester m/ feature toggles slått av
diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml
new file mode 100644
index 00000000000..74cf2426993
--- /dev/null
+++ b/.github/workflows/sonar.yml
@@ -0,0 +1,91 @@
+name: Sonar
+on:
+ push:
+ branches:
+ - 'main'
+
+jobs:
+ enhetstester:
+ name: Enhetstester
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-java@v4
+ with:
+ java-version: 21
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Kjør enhetstester
+ env:
+ GITHUB_USERNAME: x-access-token
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ mvn test -B --no-transfer-progress--settings .m2/maven-settings.xml --file pom.xml -DexcludedGroups=integration,verdikjedetest -Pjacoco -DjacocoTestDirectory=UT
+ - name: Last opp Jacoco UT rapport
+ uses: actions/upload-artifact@v4
+ with:
+ name: jacocoUT
+ path: target/jacoco/UT/jacoco.xml
+ retention-days: 1
+ overwrite: true
+
+ integrasjonstester:
+ name: Integrasjonstester
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-java@v4
+ with:
+ java-version: 21
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Kjør integrasjonstester
+ env:
+ GITHUB_USERNAME: x-access-token
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ mvn verify -B --no-transfer-progress --settings .m2/maven-settings.xml --file pom.xml -Dgroups=integration -DexcludedGroups=verdikjedetest -Dsurefire.rerunFailingTestsCount=2 -Pjacoco -DjacocoTestDirectory=IT
+ - name: Last opp Jacoco IT rapport
+ uses: actions/upload-artifact@v4
+ with:
+ name: jacocoIT
+ path: target/jacoco/IT/jacoco.xml
+ retention-days: 1
+ overwrite: true
+
+ sonar:
+ name: Sonar
+ runs-on: ubuntu-latest-8-cores
+ needs: [ enhetstester, integrasjonstester ]
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-java@v4
+ with:
+ java-version: 21
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Last ned Jacoco UT rapport
+ uses: actions/download-artifact@v4
+ with:
+ name: jacocoUT
+ path: jacoco/UT
+ - name: Last ned Jacoco IT rapport
+ uses: actions/download-artifact@v4
+ with:
+ name: jacocoIT
+ path: jacoco/IT
+ - name: Cache Sonar packages
+ uses: actions/cache@v4
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+ - name: Kjør Sonar
+ env:
+ GITHUB_USERNAME: x-access-token
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: |
+ mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths="jacoco/UT/jacoco.xml,jacoco/IT/jacoco.xml"
diff --git a/pom.xml b/pom.xml
index 978d62ae70e..2819cbe88f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,11 @@
4.2.0
1.12.0
7.7.1
+ navikt
+ https://sonarcloud.io
+ navikt_familie-ba-sak
+ 4.0.0.4121
+ 0.8.12
@@ -597,7 +602,57 @@
+
+ org.sonarsource.scanner.maven
+ sonar-maven-plugin
+ ${sonar-maven-plugin.version}
+
+
+
+ jacoco
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-maven-plugin.version}
+
+
+ prepare-agent
+
+ prepare-agent
+
+
+
+ ${project.build.directory}/jacoco/${jacocoTestDirectory}/jacoco.exec
+
+
+
+
+ report
+
+ report
+
+
+
+ ${project.build.directory}/jacoco/${jacocoTestDirectory}/jacoco.exec
+
+
+ ${project.build.directory}/jacoco/${jacocoTestDirectory}
+
+
+ XML
+
+
+
+
+
+
+
+
+
+