Setup SonarCloud

This commit is contained in:
Christian Koop 2021-05-30 06:42:21 +02:00
parent fc838ce66a
commit e0507324cd
4 changed files with 82 additions and 35 deletions

View File

@ -1,35 +0,0 @@
name: Build
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: 'Cache: Maven-Repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: 'mvn -B -Duser.name="GitHub Runner on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" clean package'
- name: 'Upload Build Artifact: EpicAnchors-*.jar'
uses: actions/upload-artifact@v2
with:
name: EpicAnchors-artifacts
path: ./modules/epicanchors-plugin/target/EpicAnchors-*.jar

76
.github/workflows/maven.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: 'Build & Test'
on:
push:
branches: [ master ]
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
# Setup Java
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
# Checkout project files
- uses: actions/checkout@v2
# Caches
- name: 'Cache: Maven'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
# Build project
- name: Build with Maven
run: 'mvn -B -Duser.name="GitHub Runner on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" clean package'
# Upload build artifacts
- name: 'Upload Build Artifact: EpicAnchors-*.jar'
uses: actions/upload-artifact@v2
with:
name: EpicAnchors-artifacts
path: ./modules/epicanchors-plugin/target/EpicAnchors-*.jar
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
# Setup Java
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
# Checkout project files
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Caches
- name: 'Cache: Maven'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: 'Cache: SonarCloud'
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# SonarCloud static analysis
- name: SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

View File

@ -12,6 +12,7 @@
[![Patreon](https://img.shields.io/badge/-Support_on_Patreon-F96854.svg?logo=patreon&style=flat&logoColor=white)](https://www.patreon.com/join/songoda)
<br>
[![Latest version](https://img.shields.io/github/v/tag/SpraxDev/EpicAnchors?include_prereleases&label=Latest&logo=github&labelColor=black)](https://songoda.com/marketplace/product/31)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=songoda_EpicAnchors&metric=alert_status)](https://sonarcloud.io/dashboard?id=songoda_EpicAnchors)
[![GitHub last commit](https://img.shields.io/github/last-commit/SpraxDev/EpicAnchors?label=Last+commit)](https://github.com/SpraxDev/EpicAnchors/commits)
<br>
[![bStats Servers](https://img.shields.io/bstats/servers/4816?label=Servers)](https://bstats.org/plugin/bukkit/EpicAnchors/4816)

View File

@ -40,6 +40,11 @@
<java.release>8</java.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.projectKey>songoda_EpicAnchors</sonar.projectKey>
<sonar.organization>songoda</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.moduleKey>${project.groupId}:${project.artifactId}</sonar.moduleKey>
</properties>
<issueManagement>