Skip to content

Commit e97b303

Browse files
committed
[CI/CD 优化与静态分析增强]: 改进持续集成流程并增加代码质量检查
- **移除冗余参数**: 删除 `install-dependencies` action 中不再使用的 `os_name` 输入参数 - **统一工作流配置**: 同步更新 `cmake.yml` 和 `qmake.yml` 工作流不再传递 `os_name` - **新增安全扫描**: 引入 CodeQL 工作流实现 C++ 代码静态分析,配置定期扫描与路径过滤规则 - **优化打包环境**: - 新增 `activate_venv.sh` 脚本自动管理 Python 虚拟环境 - 重构 macOS 打包脚本,通过虚拟环境执行 `package.py` 确保依赖隔离 - 移除 `package.py` 的 shebang 声明以规范调用方式
1 parent 7db4599 commit e97b303

File tree

7 files changed

+76
-10
lines changed

7 files changed

+76
-10
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: 'Install Dependencies'
22
description: 'Install qt environment and compile dependencies'
33
inputs:
4-
os_name:
5-
description: 'os name'
6-
required: true
7-
type: string
84
qt_modules:
95
description: 'qt modules'
106
required: false

.github/workflows/cmake.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242
fetch-depth: 1
4343

4444
- uses: ./.github/actions/install-dependencies
45-
with:
46-
os_name: ${{ matrix.os }}
4745

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

.github/workflows/codeql.yml

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

.github/workflows/qmake.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
fetch-depth: 1
4141

4242
- uses: ./.github/actions/install-dependencies
43-
with:
44-
os_name: ${{ matrix.os }}
4543

4644
- uses: RealChuan/install-jom@main
4745

packaging/activate_venv.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -ex
2+
3+
VENV_NAME="venv" # 定义虚拟环境目录名
4+
5+
# 检查虚拟环境是否存在
6+
if [ ! -d "$VENV_NAME" ]; then
7+
echo "创建虚拟环境 '$VENV_NAME'..."
8+
python3 -m venv "$VENV_NAME" || {
9+
echo "创建失败"
10+
exit 1
11+
}
12+
else
13+
echo "检测到虚拟环境 '$VENV_NAME' 已存在"
14+
fi
15+
16+
# 自动激活虚拟环境(需通过 source 执行脚本)
17+
echo "激活虚拟环境..."
18+
source "$VENV_NAME/bin/activate"
19+
20+
# 提示用户后续操作
21+
echo "虚拟环境已激活,当前 Python 路径: $(which python)"
22+
23+
cd "$(dirname "$0")"
24+
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

packaging/macos/package.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
# -*- coding: utf-8 -*-
32

43
import os

packaging/macos/package.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,7 @@ cp -f -v ${project_root}/packaging/macos/dmg.json ${release_dir}/dmg.json
9292
appdmg ${release_dir}/dmg.json ${out_dmg_path}
9393
notarize_app "${out_dmg_path}"
9494

95+
source ${project_root}/packaging/activate_venv.sh
9596
cd "$(dirname "$0")"
96-
./package.py
97+
python ./package.py
98+
deactivate

0 commit comments

Comments
 (0)