Skip to content

Commit add834f

Browse files
committed
[重构构建流程并新增CodeQL代码分析]: 优化CI/CD配置,增强代码质量检查
- 新增可复用的GitHub Action依赖安装组件(.github/actions/install-dependencies) - 统一管理vcpkg安装与缓存逻辑 - 支持多平台(Win/macOS/Linux)差异化依赖安装 - 集成ninja/clang等构建工具配置 - 重构现有构建工作流(build.yml) - 使用新的依赖安装action替代重复步骤 - 简化构建配置文件结构 - 新增CodeQL代码质量分析工作流(codeql.yml) - 自动执行C++代码静态分析 - 配置定期扫描和PR触发机制 - 复用统一的依赖安装流程 - 更新vcpkg基线版本至最新提交(d5cb5b9) - 确保依赖包使用最新稳定版本 - 保持vcpkg生态同步更新
1 parent 2b41d7e commit add834f

File tree

4 files changed

+101
-44
lines changed

4 files changed

+101
-44
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Install Dependencies'
2+
description: 'Install dependencies for the environment'
3+
4+
runs:
5+
using: 'composite'
6+
7+
steps:
8+
- name: Install Custom VCPKG
9+
uses: RealChuan/install-vcpkg@main
10+
with:
11+
repo: 'https://github.com/RealChuan/vcpkg.git'
12+
branch: 'dev'
13+
14+
- name: Update vcpkg manifest baseline
15+
shell: bash
16+
run: |
17+
vcpkg x-update-baseline
18+
19+
- name: Cache vcpkg
20+
uses: actions/cache@v4
21+
with:
22+
path: ${{ github.workspace }}/build/vcpkg_installed
23+
key: ${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-${{ github.sha }}
24+
restore-keys: |
25+
${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-
26+
${{ matrix.os }}-vcpkg-installed-
27+
${{ matrix.os }}-
28+
29+
- name: Install dependencies on windows
30+
if: runner.os == 'Windows'
31+
shell: bash
32+
run: |
33+
choco install ninja
34+
ninja --version
35+
cmake --version
36+
37+
- name: Install dependencies on macos
38+
if: runner.os == 'macOS'
39+
shell: bash
40+
run: |
41+
brew install nasm python-setuptools
42+
ninja --version
43+
cmake --version
44+
clang --version
45+
46+
- name: Install dependencies on linux
47+
if: runner.os == 'Linux'
48+
shell: bash
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install ninja-build clang
52+
ninja --version
53+
cmake --version
54+
gcc --version
55+

.github/workflows/build.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,11 @@ jobs:
3434
- "Ninja"
3535

3636
steps:
37-
- name: Install dependencies on windows
38-
if: startsWith(matrix.os, 'windows')
39-
run: |
40-
choco install ninja
41-
ninja --version
42-
cmake --version
43-
- name: Install dependencies on macos
44-
if: startsWith(matrix.os, 'macos')
45-
shell: bash
46-
run: |
47-
brew install ninja python-setuptools
48-
ninja --version
49-
cmake --version
50-
clang --version
51-
- name: Install dependencies on ubuntu
52-
if: startsWith(matrix.os, 'ubuntu')
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install ninja-build clang
56-
ninja --version
57-
cmake --version
58-
gcc --version
59-
6037
- uses: actions/checkout@v4
6138
with:
6239
fetch-depth: 1
6340

64-
- name: Install custom vcpkg
65-
uses: RealChuan/install-vcpkg@main
66-
with:
67-
repo: 'https://github.com/RealChuan/vcpkg.git'
68-
branch: 'dev'
69-
70-
- name: Update vcpkg manifest baseline
71-
shell: bash
72-
run: |
73-
vcpkg x-update-baseline
74-
75-
- name: Cache vcpkg
76-
uses: actions/cache@v4
77-
with:
78-
path: ${{ github.workspace }}/build/vcpkg_installed
79-
key: ${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-${{ github.sha }}
80-
restore-keys: |
81-
${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-
82-
${{ matrix.os }}-vcpkg-installed-
83-
${{ matrix.os }}-
41+
- uses: ./.github/actions/install-dependencies
8442

8543
- name: Configure and build windows
8644
if: startsWith(matrix.os, 'windows')

.github/workflows/codeql.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '.clang*'
7+
- '.gitignore'
8+
- 'LICENSE'
9+
- 'README*'
10+
pull_request:
11+
paths-ignore:
12+
- '.clang*'
13+
- '.gitignore'
14+
- 'LICENSE'
15+
- 'README*'
16+
17+
schedule:
18+
- cron: '0 0 1 * *'
19+
workflow_dispatch:
20+
21+
22+
jobs:
23+
build:
24+
name: Build
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
32+
- uses: ./.github/actions/install-dependencies
33+
34+
- name: Initialize CodeQL
35+
uses: github/codeql-action/init@v3
36+
with:
37+
languages: cpp
38+
39+
- name: Autobuild
40+
uses: github/codeql-action/autobuild@v3
41+
42+
- name: Perform CodeQL Analysis
43+
uses: github/codeql-action/analyze@v3
44+

vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
]
2828
}
2929
],
30-
"builtin-baseline": "3de032f834a9b28a455e35600b03e9d365ce3b85"
30+
"builtin-baseline": "d5cb5b9392b89fe9ad25786022415999202277d6"
3131
}

0 commit comments

Comments
 (0)