Skip to content

Commit fcc2c3b

Browse files
committed
[CI/CD及代码质量优化]: 主要调整构建配置与CI流程,增强代码静态检查与安全性
- **优化.clang-tidy配置**:扩展静态检查规则集,禁用部分不适用条款,启用临时析构函数分析 - **重构GitHub Actions逻辑**: - 移除install-dependencies中冗余的os_name参数传递 - 新增CodeQL代码安全扫描工作流,包含定时触发与PR检查 - 扩展dependabot监控范围至自定义action目录 - **改进打包流程**: - 添加Python虚拟环境管理脚本activate_venv.sh - 调整macOS打包脚本使用虚拟环境执行Python打包逻辑 - **修复脚本兼容性问题**: - 移除package.py的shebang依赖,改为显式调用python解释器 - 规范shell脚本错误处理与路径操作逻辑
1 parent 5575a17 commit fcc2c3b

9 files changed

Lines changed: 116 additions & 17 deletions

File tree

.clang-tidy

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1-
---
2-
Checks: 'clang-analyzer-*,readability-*,performance-*,modernize-*,bugprone-*,cert-*,portability-*,llvm-*,google-*'
3-
WarningsAsErrors: ''
1+
Checks: >
2+
clang-analyzer-*,
3+
bugprone-*,
4+
performance-*,
5+
cert-*,
6+
misc-*,
7+
modernize-*,
8+
cppcoreguidelines-*,
9+
concurrency-*,
10+
-modernize-use-trailing-return-type,
11+
-cppcoreguidelines-avoid-magic-numbers,
12+
-llvm-header-guard,
13+
-readability-identifier-length,
14+
-readability-magic-numbers,
15+
-modernize-pass-by-value,
16+
-cert-err58-cpp,
17+
-hicpp-exception-baseclass
18+
19+
WarningsAsErrors: >
20+
clang-analyzer-*,
21+
bugprone-*,
22+
performance-*,
23+
cert-*,
24+
misc-*,
25+
concurrency-mt-unsafe,
26+
concurrency-thread-canceltype,
27+
cppcoreguidelines-pro-type-*,
28+
cppcoreguidelines-owning-memory,
29+
cppcoreguidelines-no-malloc,
30+
hicpp-noexcept,
31+
performance-no-int-to-ptr,
32+
performance-trivially-destructible,
33+
bugprone-exception-escape
34+
435
HeaderFilterRegex: '.'
5-
AnalyzeTemporaryDtors: false
6-
FormatStyle: none
7-
User: user
36+
AnalyzeTemporaryDtors: true
37+
FormatStyle: file
38+
User: user

.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/dependabot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
version: 2
77
updates:
88
- package-ecosystem: "github-actions" # See documentation for possible values
9-
directory: "/" # Location of package manifests
9+
directories :
10+
- "/" # Location of package manifests
11+
- "/.github/actions/**"
1012
schedule:
1113
interval: "weekly"

.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+
current_path=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
24+
pip install -r "${current_path}/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)