Skip to content

Commit

Permalink
ci: 优化代码质量扫描配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Jan 30, 2024
1 parent 75fe537 commit 1a8c589
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 10 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,29 @@ jobs:
sonar-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Scan
uses: SonarSource/sonarcloud-github-action@master
- name: Setup Java
uses: actions/setup-java@master
with:
distribution: 'adopt'
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Analyze
run: mvn -B verify -Psonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/SNAPSHOT-v1.3.0-%23ff3f59.svg" alt="Release" />
</a>
<a href="https://sonarcloud.io/summary/new_code?id=Charles7c_continew-starter" target="_blank">
<img src="https://sonarcloud.io/api/project_badges/measure?project=Charles7c_continew-starter&metric=alert_status" alt="Sonar Status" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/Spring Boot-3.1.7-%236CB52D.svg" alt="Spring Boot" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/Java-17-%236CB52D.svg" alt="Java" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/github/stars/Charles7c/continew-starter?style=social" alt="GitHub stars" />
</a>
Expand All @@ -18,12 +27,6 @@
<a href="https://gitee.com/Charles7c/continew-starter" target="_blank">
<img src="https://gitee.com/Charles7c/continew-starter/badge/fork.svg?theme=white" alt="Gitee forks" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/Spring Boot-3.1.7-%236CB52D.svg" alt="Release" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/Java-17-%236CB52D.svg" alt="Release" />
</a>

## 简介

Expand Down
37 changes: 37 additions & 0 deletions continew-starter-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<!-- Maven Plugin Versions -->
<flatten.version>1.5.0</flatten.version>
<spotless.version>2.40.0</spotless.version>
<sonar.version>3.9.1.2184</sonar.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -543,6 +544,12 @@
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
</plugin>
<!-- Sonar 代码质量分析插件 -->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down Expand Up @@ -604,5 +611,35 @@
</repository>
</distributionManagement>
</profile>
<!-- Sonar 代码质量分析 -->
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>charles7c</sonar.organization>
<sonar.projectKey>Charles7c_continew-starter</sonar.projectKey>
<sonar.moduleKey>${project.groupId}:${project.artifactId}</sonar.moduleKey>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 1a8c589

Please sign in to comment.