Skip to content

Add SonarQube analysis #132

Add SonarQube analysis

Add SonarQube analysis #132

Workflow file for this run

name: Gradle Build and Test
on:
pull_request:
push:
workflow_dispatch:
env:
SONAR_ORGANIZATION: "aim42"
SONAR_PROJECT_KEY: "aim42_htmlSanityCheck"
jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
# Always build with JDK 8 initially
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Execute Gradle build
run: ./gradlew clean check integrationTest --scan --stacktrace
- name: 'Publish Test Results'
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: |
**/build/test-results/**/*.xml
- name: JaCoCo Test Coverage Report
uses: PavanMudigonda/[email protected]
with:
coverage_results_path: "htmlSanityCheck-gradle-plugin/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
coverage_report_name: Coverage
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
./gradlew sonar -Psonar.branch.name=${BRANCH_NAME} --info
- name: Upload Artifacts
uses: actions/upload-artifact@master
with:
name: maven-repo
path: build/maven-repo
- name: Trigger Test Matrix Workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: test-java-os-mix.yml