.github/workflows/maven.yml
name: Java CI
on:
push:
branches:
- master
- release/*
pull_request:
branches:
- master
- release/*
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
java_version: ['8', '11', '17']
os: ['ubuntu-latest']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@v3.0.0
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v2.1.7
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build
run: ./mvnw --no-transfer-progress -V -B -ff -s .github/settings.xml -e -DtrimStackTrace=false -Dmaven.test.failure.ignore=true -Dsurefire.rerunFailingTestsCount=1 verify
- name: Publish Test Results
# If the CI run is not initiated from the primary repository, it is highly likely that this is a PR from a user who doesn't have commit rights.
# Hence, skip this step to avoid permission failures.
if: github.event.pull_request.head.repo.full_name == 'dropwizard/dropwizard'
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Test Report (${{ matrix.os }} - Java ${{ matrix.java_version }})
report_paths: '**/*-reports/TEST-*.xml'
- name: Upload Test Reports
# If the CI run is not initiated from the primary repository, it is highly likely that this is a PR from a user who doesn't have commit rights.
# Hence, skip this step to avoid permission failures.
if: github.event.pull_request.head.repo.full_name == 'dropwizard/dropwizard'
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.os }}-java${{ matrix.java_version }}
path: '**/*-reports'
- name: Analyze with SonarCloud
if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw --no-transfer-progress -V -B -ff -s .github/settings.xml -Dsonar.projectKey=dropwizard_dropwizard -Dsonar.organization=dropwizard -Dsonar.host.url=https://sonarcloud.io org.sonarsource.scanner.maven:sonar-maven-plugin:sonar