-
Notifications
You must be signed in to change notification settings - Fork 18
65 lines (61 loc) · 2.74 KB
/
Copy pathsonar.yml
File metadata and controls
65 lines (61 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Sonar
# 这个 workflow 现在是**非阻断的质量看板,不是门禁**。
#
# 起因:SONAR_TOKEN 已失效,「Build and analyze」这一步 403 恒失败(最近 8 次全红)。
# 只要它是红的,PR 的 mergeable_state 就恒为 unstable、永远到不了 clean,
# codegen PR 的自动合并会被这条与代码质量无关的红叉挡死。
# 处置:给该 step 加 step 级 continue-on-error —— step 仍然会红、问题不被掩盖,
# 但 job 结论是 success,不再拖住合并。**修好 token 是另一件事,不在本次范围内。**
#
# job 的显示名 `Build` 必须保持不变:它可能已经被配进分支保护的 required check,
# 改名会让那条 required check 永远 pending、把所有 PR 卡死。
# (job key 仍叫 `lint` 是历史遗留,与代码风格检查无关;本仓真正的 lint 见 ci.yml,
# 且那个目前是空壳。)
#
# 已从原来的 `mvn verify` 缩为只跑到 compile:verify 会把测试和打包再跑一遍,
# 而这两件事 ci.yml 已经做了,重复跑既费时又让「哪个结果算数」变得含糊。
# sonar 分析本身只需要有编译产物即可。
# 原来的 -Dgpg.skip 一并去掉:gpg 签名绑在 verify 阶段,跑到 compile 根本到不了那里。
on:
push:
branches:
- master
- release/*
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
jobs:
lint:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: temurin
- name: Cache SonarCloud packages
uses: actions/cache@v6
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v6
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# continue-on-error 加在 step 上而不是 job 上:
# job 级会把整个 job 标成 success 却看不出哪里出了问题,
# step 级则是这一步红、job 绿,红叉仍留在 Actions 页面上等人去修 token。
- name: Build and analyze
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B -DskipTests compile org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ucloud_ucloud-sdk-java