Skip to content

SonarCloud Analysis #1049

SonarCloud Analysis

SonarCloud Analysis #1049

Workflow file for this run

name: SonarCloud Analysis
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
schedule:
- cron: '30 9 * * *' # 09:30 UTC every day
jobs:
build:
if: github.repository == 'GoogleCloudPlatform/cloud-opensource-java' # 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@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- uses: actions/cache@v2
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.date }}
- name: Mvn install w/ coverage
run: |
./mvnw -B -e -ntp --activate-profiles codecoverage clean install \
-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false \
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
- name: Analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./mvnw \
-B -ntp \
--activate-profiles codecoverage \
-Dsonar.projectKey=GoogleCloudPlatform_cloud-opensource-java \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=googlecloudplatform \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar