Skip to content

Commit ff440e6

Browse files
committed
Add sonar analyzing and remove codecov
1 parent 63eecac commit ff440e6

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

.github/workflows/build_deploy.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,43 @@ on:
88
- '*' # Trigger on all tags
99
pull_request: { }
1010

11+
env:
12+
SONARQUBE_PROJECT: patrickfav_bytes-java
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest
1417

1518
steps:
1619
- name: Checkout Code
1720
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
23+
- name: Cache SonarCloud packages
24+
uses: actions/cache@v3
25+
with:
26+
path: ~/.sonar/cache
27+
key: ${{ runner.os }}-sonar
28+
restore-keys: ${{ runner.os }}-sonar
29+
- name: Cache Maven
30+
id: cache-primes
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/.m2
34+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: ${{ runner.os }}-m2
1836
- name: Set up JDK 8
1937
uses: actions/setup-java@v3
2038
with:
2139
java-version: '8'
2240
distribution: 'adopt'
23-
cache: 'maven'
2441
- name: Build with Maven
25-
run: ./mvnw -B clean package checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true
26-
- name: Upload coverage reports to CodeCov
27-
uses: codecov/codecov-action@v3
42+
run: ./mvnw -B clean verify checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true
43+
- name: Analyze with SonaQube
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
46+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
47+
run: mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=$SONARQUBE_PROJECT
2848

2949
deploy:
3050
needs: build
@@ -38,12 +58,18 @@ jobs:
3858
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
3959
run: |
4060
echo $KEYSTORE_BASE64 | base64 --decode > keystore.jks
61+
- name: Cache Maven
62+
id: cache-primes
63+
uses: actions/cache@v3
64+
with:
65+
path: ~/.m2
66+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
67+
restore-keys: ${{ runner.os }}-m2
4168
- name: Set up Maven Central Repository
4269
uses: actions/setup-java@v3
4370
with:
4471
java-version: '8'
4572
distribution: 'adopt'
46-
cache: 'maven'
4773
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
4874
server-username: MAVEN_USERNAME # env variable for username in deploy
4975
server-password: MAVEN_PASSWORD # env variable for token in deploy

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ to blindly paste code snippets from
3030
[![Maven Central](https://img.shields.io/maven-central/v/at.favre.lib/bytes)](https://mvnrepository.com/artifact/at.favre.lib/bytes)
3131
[![Github Actions](https://github.com/patrickfav/bytes-java/actions/workflows/build_deploy.yml/badge.svg)](https://github.com/patrickfav/bytes-java/actions)
3232
[![Javadocs](https://www.javadoc.io/badge/at.favre.lib/bytes.svg)](https://www.javadoc.io/doc/at.favre.lib/bytes)
33-
[![codecov](https://codecov.io/gh/patrickfav/bytes-java/branch/master/graph/badge.svg?token=YiSRwBApvz)](https://codecov.io/gh/patrickfav/bytes-java)
34-
[![Maintainability](https://api.codeclimate.com/v1/badges/43b7770f0ee00b85f92a/maintainability)](https://codeclimate.com/github/patrickfav/bytes-java/maintainability)
33+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=patrickfav_bytes-java&metric=coverage)](https://sonarcloud.io/summary/new_code?id=patrickfav_bytes-java)
34+
[![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)
35+
[![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)
3536

36-
It's main features include:
37+
Its main features include:
3738

3839
* **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, ...
3940
* **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), ...

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424

2525
<properties>
2626
<commonConfig.jarSign.skip>false</commonConfig.jarSign.skip>
27+
<!-- SonarQube Config -->
28+
<sonar.organization>patrickfav</sonar.organization>
29+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
30+
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
31+
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
32+
<sonar.language>java</sonar.language>
2733
</properties>
2834

2935
<build>

0 commit comments

Comments
 (0)