add code coverage and sonarcloud analysis

pull/14/head
Jean Picard 3 years ago
parent 4712348583
commit 3811440c38

@ -1,4 +1,4 @@
# This workflow will build a Java project with Maven
# This workflow will build a Java project with Maven, check coverage with JaCoCo and analyze with sonarcloud
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
@ -16,12 +16,32 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '8'
java-version: '11'
distribution: 'adopt'
- name: Run tests
run: mvn --batch-mode test
- name: Build with Maven
run: mvn --batch-mode package --file pom.xml
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
- name: Upload jar artifact
uses: actions/upload-artifact@v2
with:
name: artifacts
path: target/*.jar

@ -4,6 +4,8 @@
[![Build Status](https://img.shields.io/github/workflow/status/MieuxVoter/majority-judgment-library-java/Java%20CI%20with%20Maven)](https://github.com/MieuxVoter/majority-judgment-library-java/actions)
[![Release](https://img.shields.io/github/v/release/MieuxVoter/majority-judgment-library-java?sort=semver)](https://github.com/MieuxVoter/majority-judgment-library-java/releases)
[![Join the Discord chat at https://discord.gg/rAAQG9S](https://img.shields.io/discord/705322981102190593.svg)](https://discord.gg/rAAQG9S)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jeanpic_majority-judgment-library-java&metric=coverage)](https://sonarcloud.io/dashboard?id=jeanpic_majority-judgment-library-java)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jeanpic_majority-judgment-library-java&metric=alert_status)](https://sonarcloud.io/dashboard?id=jeanpic_majority-judgment-library-java)
Test-driven java library to help deliberate using [Majority Judgment](https://mieuxvoter.fr/index.php/decouvrir/?lang=en).

@ -13,8 +13,11 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.projectKey>jeanpic_majority-judgment-library-java</sonar.projectKey>
<sonar.organization>jeanpic</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<dependencies>
@ -56,10 +59,6 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>

Loading…
Cancel
Save