Skip to content

Commit 9a0eae6

Browse files
committed
Added Sonar Integration
1 parent a683809 commit 9a0eae6

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Sonar
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ develop ]
7+
paths-ignore:
8+
- '**.md'
9+
- 'assets/**'
10+
- 'config/**'
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
paths-ignore:
14+
- '**.md'
15+
- 'assets/**'
16+
- 'config/**'
17+
18+
env:
19+
SONARCLOUD_ORG: ${{ github.event.organization.login }}
20+
SONARCLOUD_HOST: https://sonarcloud.io
21+
22+
jobs:
23+
sonar:
24+
name: SonarCloud Scan
25+
runs-on: ubuntu-latest
26+
# Dependabot PRs have no access to secrets (SONAR_TOKEN) -> Ignore them
27+
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'dependabot/') }}
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
32+
33+
- name: Set up JDK 11
34+
uses: actions/setup-java@v3
35+
with:
36+
distribution: 'temurin'
37+
java-version: 11
38+
39+
- name: Cache SonarCloud packages
40+
uses: actions/cache@v3
41+
with:
42+
path: ~/.sonar/cache
43+
key: ${{ runner.os }}-sonar
44+
restore-keys: ${{ runner.os }}-sonar
45+
46+
- name: Cache Maven packages
47+
uses: actions/cache@v3
48+
with:
49+
path: ~/.m2
50+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
51+
restore-keys: ${{ runner.os }}-m2
52+
53+
- name: Build with Maven
54+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONARCLOUD_ORG }}_${{ github.event.repository.name }} -Dsonar.organization=${{ env.SONARCLOUD_ORG }} -Dsonar.host.url=${{ env.SONARCLOUD_HOST }}
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
57+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadin-addon-template)
22
[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/vaadin-addon-template)](https://mvnrepository.com/artifact/com.xdev-software/vaadin-addon-template)
33
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-addon-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/vaadin-addon-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_vaadin-addon-template&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_vaadin-addon-template)
45
![Vaadin 23+](https://img.shields.io/badge/Vaadin%20Platform/Flow-23+-00b4f0.svg)
56

67
# vaadin-addon-template

0 commit comments

Comments
 (0)