Skip to content

Add SonarQube coverage to Maven test workflow #14

Add SonarQube coverage to Maven test workflow

Add SonarQube coverage to Maven test workflow #14

Workflow file for this run

name: Maven Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Run tests and generate coverage report
run: ./mvnw verify
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
${{ github.event_name == 'pull_request' && format('-Dsonar.pullrequest.key={0}', github.event.pull_request.number) || '' }}
${{ github.event_name == 'pull_request' && format('-Dsonar.pullrequest.branch={0}', github.head_ref) || '' }}
${{ github.event_name == 'pull_request' && format('-Dsonar.pullrequest.base={0}', github.base_ref) || '' }}
# - name: Generate test report
# if: always()
# run: ./mvnw surefire-report:report
#
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: target/surefire-reports/