Skip to content

Add checkstyle flag to allow ignoring generated sources (#10) #17

Add checkstyle flag to allow ignoring generated sources (#10)

Add checkstyle flag to allow ignoring generated sources (#10) #17

name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Define BUILD_LABEL
env:
INPUT: ${{ github.head_ref || github.ref_name }}
run: |
echo "BUILD_LABEL=${INPUT//\//_}" >> $GITHUB_ENV
# - name: Echo env
# run: env | sort
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4
# 1.1.0
# From https://docs.sonarqube.org/latest/analysis/github-integration/
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Set build version
# Cannot use ${BUILD_LABEL} with gradle-build-action, so stuff version
# into gradle.properties
run: sed -i 's/^version.*/version = '${BUILD_LABEL}'/;' ./gradle.properties
- name: Run tests
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2
# 2.11.1
with:
# Only write to the cache for builds on the 'main' branch (default - but here for documentation)
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: check javadoc publish -s
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}