Skip to content

Sonar + kover

Sonar + kover #28

Workflow file for this run

name: Build-PR
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
permissions:
contents: read
actions: read
checks: write
jobs:
avslutt-andre-workflows-samme-branch:
name: Avslutt andre workflows på samme branch
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
ktlint:
name: Ktlint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Kjør ktlint
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn antrun:run@ktlint
tester:
name: Tester
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 verify -B --no-transfer-progress --settings .m2/maven-settings.xml --file pom.xml
- name: Last opp Jacoco enhetstester rapport
uses: actions/upload-artifact@v4
with:
name: kover
path: target/site/kover/report.xml
retention-days: 1
overwrite: true
sonar:
if: github.actor != 'dependabot[bot]'
name: Sonar
runs-on: ubuntu-latest
needs: [ tester ]
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 kover rapport
uses: actions/download-artifact@v4
with:
name: kover
path: kover/kover
- 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="kover/kover/report.xml"