Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Add sonar check in CI #3848

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Set up java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "adopt"
cache: "maven"
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-backend
restore-keys: ${{ runner.os }}-maven-
- name: Backend Build with Maven
run: ./mvnw -B clean install -Pshaded -DskipTests
result:
Expand Down
48 changes: 47 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,60 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-unit-test
restore-keys: ${{ runner.os }}-maven-
- name: Set up java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "adopt"
cache: "maven"
- name: Unit-Test with Maven
run: ./mvnw clean -B test
sonarcloud-analysis:
name: SonarCloud Code Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
submodules: true
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-unit-test
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'adopt'
- name: Execute SonarCloud Scan
run: |
./mvnw clean verify sonar:sonar \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=apache \
-Dsonar.projectKey=apache_incubator-streampark \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.token=7ef5d3a630b7009a1f4fdca48e776d0605e69d7d \
-Dmaven.test.skip=true \
-Dspotless.skip=true \
-Dsonar.exclusions=target/dependency-reduced-pom.xml

# - name: SonarCloud Scan
# uses: sonarsource/[email protected]
# env:
# SONAR_TOKEN: 7ef5d3a630b7009a1f4fdca48e776d0605e69d7d
## SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
# with:
# args: >
# -Dsonar.organization=apache
# -Dsonar.projectKey=apache_incubator-streampark
# -Dsonar.sourceEncoding=UTF-8
result:
name: Unit-Test - Result
runs-on: ubuntu-latest
Expand Down
40 changes: 40 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,17 @@
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.0.0.4121</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
</plugin>
</plugins>

</build>
Expand Down Expand Up @@ -997,6 +1008,35 @@
<spotless.skip>true</spotless.skip>
</properties>
</profile>

<profile>
<id>coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Loading