From 3811440c388ebaaed054e4d1cf51a71c1e7b3fb4 Mon Sep 17 00:00:00 2001 From: Jean Picard Date: Mon, 31 May 2021 13:52:45 +0200 Subject: [PATCH] add code coverage and sonarcloud analysis --- .github/workflows/maven.yml | 34 +++++++++++++++++++++++++++------- README.md | 2 ++ pom.xml | 11 +++++------ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c04cb45..908108d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 0f0c9d1..628566d 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/pom.xml b/pom.xml index dc327a3..40f442c 100644 --- a/pom.xml +++ b/pom.xml @@ -13,8 +13,11 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 + jeanpic_majority-judgment-library-java + jeanpic + https://sonarcloud.io @@ -56,10 +59,6 @@ maven-compiler-plugin 3.8.0 - - 1.8 - 1.8 - maven-surefire-plugin