Repository navigation
89 lines (78 loc) · 2.83 KB
/
Copy pathcodeQL.yml
File metadata and controls
89 lines (78 loc) · 2.83 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: CodeQL 扫描
on:
push:
pull_request:
schedule:
- cron: "0 3 * * 1"
jobs:
analyze:
name: CodeQL 分析
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- language: csharp
build-mode: manual
- language: actions
build-mode: none
permissions:
actions: read
contents: read
security-events: write
steps:
- name: 检出仓库
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.ref }}
# SecRandom.Core 的 ProjectReference 指向这条路径,但这一档是**可选依赖**:仓库不可达、tag 不存在或检出失败
# 都不能让流水线变红,所以这一步允许失败,由下面的探测把不可用的目录删掉,主程序照常编译
- name: 检出 NewAlgorithm
id: newalgorithm
if: ${{ matrix.language == 'csharp' }}
continue-on-error: true
uses: actions/checkout@v4
with:
repository: WinFunan/VeriRandom.NewAlgorithm
ref: v0.1.0
path: vendors/NewAlgorithm
persist-credentials: false
- name: 安装 .NET SDK
if: ${{ matrix.language == 'csharp' }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
# 可选依赖:编译不过就删掉,让主工程照常扫描,而不是让整条 CodeQL 作业变红
- name: 校验 NewAlgorithm
if: ${{ matrix.language == 'csharp' }}
shell: pwsh
run: |
$project = 'vendors/NewAlgorithm/SecRandom.NewAlgorithm/SecRandom.NewAlgorithm.csproj'
if (-not (Test-Path $project)) {
Write-Host '::warning::NewAlgorithm is not available; building without the extra algorithm tier.'
exit 0
}
dotnet build $project -c Release --nologo
if ($LASTEXITCODE -ne 0) {
Write-Host '::warning::NewAlgorithm does not build; removing it so the main build stays green.'
Remove-Item 'vendors/NewAlgorithm' -Recurse -Force
}
exit 0
- name: 还原工作负载
if: ${{ matrix.language == 'csharp' }}
run: dotnet workload restore
- name: 还原解决方案
if: ${{ matrix.language == 'csharp' }}
run: dotnet restore ./SecRandom.Desktop/SecRandom.Desktop.csproj
- name: 初始化 CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- name: 构建
if: ${{ matrix.language == 'csharp' }}
run: dotnet build ./SecRandom.Desktop/SecRandom.Desktop.csproj -c Release -p:BuildInParallel=false
- name: 执行 CodeQL 分析
uses: github/codeql-action/analyze@v4