From ff440e68c941b039d809d3169dac7ae73f637abc Mon Sep 17 00:00:00 2001 From: Patrick Favre-Bulle Date: Wed, 15 Feb 2023 19:03:28 +0100 Subject: [PATCH 1/2] Add sonar analyzing and remove codecov --- .github/workflows/build_deploy.yml | 36 +++++++++++++++++++++++++----- README.md | 7 +++--- pom.xml | 6 +++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml index efbcc8a..3f7e9d2 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/build_deploy.yml @@ -8,6 +8,9 @@ on: - '*' # Trigger on all tags pull_request: { } +env: + SONARQUBE_PROJECT: patrickfav_bytes-java + jobs: build: runs-on: ubuntu-latest @@ -15,16 +18,33 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven + id: cache-primes + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 - name: Set up JDK 8 uses: actions/setup-java@v3 with: java-version: '8' distribution: 'adopt' - cache: 'maven' - name: Build with Maven - run: ./mvnw -B clean package checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true - - name: Upload coverage reports to CodeCov - uses: codecov/codecov-action@v3 + run: ./mvnw -B clean verify checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true + - name: Analyze with SonaQube + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=$SONARQUBE_PROJECT deploy: needs: build @@ -38,12 +58,18 @@ jobs: KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} run: | echo $KEYSTORE_BASE64 | base64 --decode > keystore.jks + - name: Cache Maven + id: cache-primes + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 - name: Set up Maven Central Repository uses: actions/setup-java@v3 with: java-version: '8' distribution: 'adopt' - cache: 'maven' server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml server-username: MAVEN_USERNAME # env variable for username in deploy server-password: MAVEN_PASSWORD # env variable for token in deploy diff --git a/README.md b/README.md index 8171298..c9096b4 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,11 @@ to blindly paste code snippets from [![Maven Central](https://img.shields.io/maven-central/v/at.favre.lib/bytes)](https://mvnrepository.com/artifact/at.favre.lib/bytes) [![Github Actions](https://github.com/patrickfav/bytes-java/actions/workflows/build_deploy.yml/badge.svg)](https://github.com/patrickfav/bytes-java/actions) [![Javadocs](https://www.javadoc.io/badge/at.favre.lib/bytes.svg)](https://www.javadoc.io/doc/at.favre.lib/bytes) -[![codecov](https://codecov.io/gh/patrickfav/bytes-java/branch/master/graph/badge.svg?token=YiSRwBApvz)](https://codecov.io/gh/patrickfav/bytes-java) -[![Maintainability](https://api.codeclimate.com/v1/badges/43b7770f0ee00b85f92a/maintainability)](https://codeclimate.com/github/patrickfav/bytes-java/maintainability) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=patrickfav_bytes-java&metric=coverage)](https://sonarcloud.io/summary/new_code?id=patrickfav_bytes-java) +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=patrickfav_bytes-java&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=patrickfav_bytes-java) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=patrickfav_bytes-java&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=patrickfav_bytes-java) -It's main features include: +Its main features include: * **Creation** from a wide variety of sources: multiple arrays, integers, [streams](https://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html), random, strings, files, uuid, ... * **Transformation** with many built-in: append, [xor](https://en.wikipedia.org/wiki/Exclusive_or), [and](https://en.wikipedia.org/wiki/Logical_conjunction), [hash](https://en.wikipedia.org/wiki/Cryptographic_hash_function), [shifts](https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts), shuffle, reverse, [checksum](https://en.wikipedia.org/wiki/Checksum), ... diff --git a/pom.xml b/pom.xml index 1c665e9..045e102 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,12 @@ false + + patrickfav + https://sonarcloud.io + jacoco + reuseReports + java From 528413b2575d06364fb7cae01bfd81c6ca875a87 Mon Sep 17 00:00:00 2001 From: Patrick Favre-Bulle Date: Wed, 15 Feb 2023 19:14:28 +0100 Subject: [PATCH 2/2] Remove errorprone and proguard optimized version to be able to build with JDK11 Not yet JDK17 compatible --- .github/workflows/build_deploy.yml | 10 +++++----- .mvn/maven.config | 2 +- README.md | 4 ++-- pom.xml | 8 ++------ 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml index 3f7e9d2..607a0ca 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/build_deploy.yml @@ -33,11 +33,11 @@ jobs: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - - name: Set up JDK 8 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'adopt' + java-version: '11' + distribution: 'temurin' - name: Build with Maven run: ./mvnw -B clean verify checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true - name: Analyze with SonaQube @@ -68,8 +68,8 @@ jobs: - name: Set up Maven Central Repository uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'adopt' + java-version: '11' + distribution: 'temurin' server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml server-username: MAVEN_USERNAME # env variable for username in deploy server-password: MAVEN_PASSWORD # env variable for token in deploy diff --git a/.mvn/maven.config b/.mvn/maven.config index b9d8785..f1099e4 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1 +1 @@ --DcommonConfig.compiler.profile=jdk7_w_errorprone +-DcommonConfig.compiler.profile=jdk7 diff --git a/README.md b/README.md index c9096b4..03720ad 100644 --- a/README.md +++ b/README.md @@ -700,8 +700,8 @@ the plugin versions as well as providing the checkstyle config rules. Specifical ## Tech Stack -* Java 7 (+ [errorprone](https://github.com/google/error-prone) static analyzer) -* Maven +* Java 7 Source, JDK 11 required to build (not yet JDK17 compatible) +* Maven 3 # Credits diff --git a/pom.xml b/pom.xml index 045e102..5803bb5 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ at.favre.lib common-parent - 18 + 18.1 bytes @@ -41,7 +41,7 @@ org.apache.felix maven-bundle-plugin - 4.2.0 + 5.1.8 true @@ -71,10 +71,6 @@ org.jacoco jacoco-maven-plugin - - com.github.wvengen - proguard-maven-plugin - org.apache.maven.plugins maven-jarsigner-plugin