Skip to content

SonarCloud Analysis #2446

SonarCloud Analysis

SonarCloud Analysis #2446

Workflow file for this run

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Github action job to test core java library features on
# downstream client libraries before they are released.
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 17
uses: actions/setup-java@v1
with:
java-version: 17
- 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