From 3811440c388ebaaed054e4d1cf51a71c1e7b3fb4 Mon Sep 17 00:00:00 2001 From: Jean Picard Date: Mon, 31 May 2021 13:52:45 +0200 Subject: [PATCH 1/4] 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 From be37e7ff3d311c4bad7ac3b38c2467480297a88e Mon Sep 17 00:00:00 2001 From: Jean Picard <33869062+jeanpic@users.noreply.github.com> Date: Wed, 2 Jun 2021 13:05:46 +0200 Subject: [PATCH 2/4] change sonar related properties Co-authored-by: Dominique Merle --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40f442c..6f49a14 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ UTF-8 1.8 1.8 - jeanpic_majority-judgment-library-java + MieuxVoter_majority-judgment-library-java jeanpic https://sonarcloud.io From 301461a53cd3cf2c71775a59303405d7bb04283f Mon Sep 17 00:00:00 2001 From: Jean Picard <33869062+jeanpic@users.noreply.github.com> Date: Wed, 2 Jun 2021 13:06:29 +0200 Subject: [PATCH 3/4] change sonar organization Co-authored-by: Dominique Merle --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6f49a14..88ef949 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 1.8 1.8 MieuxVoter_majority-judgment-library-java - jeanpic + mieuxvoter https://sonarcloud.io From bacc4a96fa3dfa9e9b0b6a85be7fadf1c1213cf7 Mon Sep 17 00:00:00 2001 From: Jean Picard <33869062+jeanpic@users.noreply.github.com> Date: Wed, 2 Jun 2021 17:24:36 +0200 Subject: [PATCH 4/4] update sonarcloud project name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 628566d..f7ade0e 100644 --- a/README.md +++ b/README.md @@ -4,8 +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) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=MieuxVoter_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=MieuxVoter_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).