Skip to content

Update to latest Gradle Action, tweak build for configuration cache (… #236

Update to latest Gradle Action, tweak build for configuration cache (…

Update to latest Gradle Action, tweak build for configuration cache (… #236

name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Allows sonar to collect blame information
# From https://docs.sonarqube.org/latest/analysis/github-integration/
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0
# v4.2.1
with:
validate-wrappers: true
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Run tests
run: ./gradlew --configuration-cache check javadoc publish sonar -s -Pversion=${BUILD_LABEL//\//_}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
BUILD_LABEL: ${{ github.head_ref || github.ref_name }}