Skip to content

SonarCloud Analysis #1818

SonarCloud Analysis

SonarCloud Analysis #1818

Workflow file for this run

name: SonarCloud Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
schedule:
- cron: '30 9 * * *' # 09:30 UTC every day
jobs:
build:
if: github.repository == 'GoogleCloudPlatform/cloud-spanner-r2dbc' # Only run on upstream branch
name: Build with Sonar
runs-on: ubuntu-20.04
steps:
- 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
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Mvn test w/ coverage # Need this when the directory/pom structure changes
run: |
./mvnw \
--batch-mode \
--show-version \
--threads 1.5C \
--activate-profiles default,codecov \
clean \
test
- name: Analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./mvnw \
--batch-mode \
--define sonar.projectKey=GoogleCloudPlatform_cloud-spanner-r2dbc \
--define sonar.host.url=https://sonarcloud.io \
--define sonar.organization=googlecloudplatform \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar