Integrate SonarQube code analysis #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-action | |
on: | |
push: | |
branches-ignore: | |
- 'gh-pages' | |
pull_request: | |
branches-ignore: | |
- 'gh-pages' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{matrix.os}} | |
steps: | |
- name: Check repository | |
uses: actions/checkout@v3 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
#Run only on macOS | |
- name: Setup Docker | |
if: ${{ matrix.os == 'macos-latest' && github.event_name == 'pull_request' }} | |
uses: better0fdead/actions-setup-docker@better0fdead/increase-timeout | |
#Build without test on Windows or macOS (when not a PR) | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- name: Cache SonarQube packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Gradle build | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" || ( "$RUNNER_OS" == "macOS" && ${{ github.event_name }} != 'pull_request' ) ]]; then | |
./gradlew build -x test | |
else | |
./gradlew build sonar --info | |
fi | |
shell: bash |