Skip to content

SonarCloud Analysis #2387

SonarCloud Analysis

SonarCloud Analysis #2387

Workflow file for this run

name: SonarCloud Analysis
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
schedule:
- cron: '00 6 * * *' # 06:00 UTC every day
jobs:
sonar:
if: github.repository == 'GoogleContainerTools/jib' # Only run on upstream branch
name: Build with Sonar
runs-on: ubuntu-20.04
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d' --utc)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar-${{ steps.date.outputs.date }}
- uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Test w/ coverage
continue-on-error: true
run: |
./gradlew clean build jacocoTestReport --stacktrace
- name: Build and analyze
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./gradlew sonarqube --stacktrace