ci: 优化代码质量扫描配置

This commit is contained in:
Charles7c 2024-01-30 23:20:07 +08:00
parent e4180fb976
commit c03c082d2e
3 changed files with 71 additions and 15 deletions

View File

@ -19,7 +19,7 @@ jobs:
uses: actions/setup-java@master uses: actions/setup-java@master
with: with:
distribution: 'adopt' distribution: 'adopt'
java-version: '17' java-version: 17
cache: 'maven' cache: 'maven'
# 3、打包 # 3、打包
- name: Build - name: Build
@ -59,7 +59,7 @@ jobs:
with: with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis fetch-depth: 0 # a full history is required for pull request analysis
- name: Scan - name: Analyze
uses: JetBrains/qodana-action@v2023.3 uses: JetBrains/qodana-action@v2023.3
env: env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
@ -67,10 +67,29 @@ jobs:
sonar-scan: sonar-scan:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@master
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Scan - name: Setup Java
uses: SonarSource/sonarcloud-github-action@master 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: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View File

@ -6,6 +6,18 @@
<a href="https://github.com/Charles7c/continew-admin" target="_blank"> <a href="https://github.com/Charles7c/continew-admin" target="_blank">
<img src="https://img.shields.io/badge/SNAPSHOT-v2.4.0-%23ff3f59.svg" alt="Release" /> <img src="https://img.shields.io/badge/SNAPSHOT-v2.4.0-%23ff3f59.svg" alt="Release" />
</a> </a>
<a href="https://sonarcloud.io/summary/new_code?id=Charles7c_continew-admin" target="_blank">
<img src="https://sonarcloud.io/api/project_badges/measure?project=Charles7c_continew-admin&metric=alert_status" alt="Sonar Status" />
</a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/ContiNew Starter-1.2.1-%236CB52D.svg" alt="ContiNew Starter" />
</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-admin" target="_blank"> <a href="https://github.com/Charles7c/continew-admin" target="_blank">
<img src="https://img.shields.io/github/stars/Charles7c/continew-admin?style=social" alt="GitHub stars" /> <img src="https://img.shields.io/github/stars/Charles7c/continew-admin?style=social" alt="GitHub stars" />
</a> </a>
@ -18,15 +30,6 @@
<a href="https://gitee.com/Charles7c/continew-admin" target="_blank"> <a href="https://gitee.com/Charles7c/continew-admin" target="_blank">
<img src="https://gitee.com/Charles7c/continew-admin/badge/fork.svg?theme=white" alt="Gitee forks" /> <img src="https://gitee.com/Charles7c/continew-admin/badge/fork.svg?theme=white" alt="Gitee forks" />
</a> </a>
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
<img src="https://img.shields.io/badge/ContiNew Starter-1.2.1-%236CB52D.svg" alt="Release" />
</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>
📚 [在线文档](https://doc.charles7c.top) | 🚀 [演示地址](https://cnadmin.charles7c.top)(账号/密码admin/admin123 📚 [在线文档](https://doc.charles7c.top) | 🚀 [演示地址](https://cnadmin.charles7c.top)(账号/密码admin/admin123

34
pom.xml
View File

@ -34,6 +34,7 @@
<!-- 项目版本号 --> <!-- 项目版本号 -->
<revision>2.4.0-SNAPSHOT</revision> <revision>2.4.0-SNAPSHOT</revision>
<tlog.version>1.5.1</tlog.version> <tlog.version>1.5.1</tlog.version>
<sonar.version>3.9.1.2184</sonar.version>
</properties> </properties>
<!-- 全局依赖版本管理 --> <!-- 全局依赖版本管理 -->
@ -169,6 +170,39 @@
</plugins> </plugins>
</build> </build>
<profiles>
<!-- Sonar 代码质量分析 -->
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>charles7c</sonar.organization>
<sonar.projectKey>Charles7c_continew-admin</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>
<!-- 远程仓库配置:华为云、阿里云 Maven 镜像源仓库 --> <!-- 远程仓库配置:华为云、阿里云 Maven 镜像源仓库 -->
<repositories> <repositories>
<repository> <repository>