Skip to content

Commit bf4e6f4

Browse files
committed
[CI/CD优化与日志改进]: 优化GitHub Actions配置并增强日志文件错误处理
-**CI依赖安装**: 在Windows、macOS和Linux的vcpkg安装命令中添加`--clean-buildtrees-after-build`和`--clean-packages-after-build`参数,构建后自动清理以节省磁盘空间 -**CI构建流程**: 将条件判断从`startsWith(matrix.os,...)`改为更准确的`runner.os`环境变量检查,提高构建可靠性 -**工具链更新**: 将README工作流中的setup-node动作从v5升级到v6版本 -**日志系统增强**: 在日志文件滚动时添加打开文件失败的错误检查和警告输出,提高系统健壮性
1 parent a44ed03 commit bf4e6f4

4 files changed

Lines changed: 26 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ runs:
5656
run: |
5757
ninja --version
5858
cmake --version
59-
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows || (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
60-
# vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows-static-md || (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
59+
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows \
60+
--clean-buildtrees-after-build --clean-packages-after-build \
61+
|| (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
62+
# vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows-static-md \
63+
# --clean-buildtrees-after-build --clean-packages-after-build \
64+
# || (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
6165
6266
- name: Install dependencies on macos
6367
if: runner.os == 'macOS'
@@ -67,8 +71,12 @@ runs:
6771
ninja --version
6872
cmake --version
6973
clang --version
70-
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-osx || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
71-
vcpkg install ${{ inputs.vcpkg_libs }} --triplet arm64-osx || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
74+
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-osx \
75+
--clean-buildtrees-after-build --clean-packages-after-build \
76+
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
77+
vcpkg install ${{ inputs.vcpkg_libs }} --triplet arm64-osx \
78+
--clean-buildtrees-after-build --clean-packages-after-build \
79+
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
7280
7381
- name: Install dependencies on linux
7482
if: runner.os == 'Linux'
@@ -80,7 +88,9 @@ runs:
8088
ninja --version
8189
cmake --version
8290
gcc --version
83-
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-linux || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
91+
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-linux \
92+
--clean-buildtrees-after-build --clean-packages-after-build \
93+
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
8494
8595
- name: Install Qt
8696
uses: jurplel/install-qt-action@v4

.github/workflows/cmake.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- uses: ./.github/actions/install-dependencies
6262

6363
- name: Configure and build windows
64-
if: startsWith(matrix.os, 'windows')
64+
if: runner.os == 'Windows'
6565
shell: pwsh
6666
run: |
6767
.\packaging\windows\Enter-VsDevShell.ps1
@@ -73,7 +73,7 @@ jobs:
7373
cmake --build "${{ env.BUILD_DIR }}" --config ${{ env.BUILD_TYPE }}
7474
7575
- name: Configure and build ubuntu
76-
if: startsWith(matrix.os, 'ubuntu')
76+
if: runner.os == 'Linux'
7777
shell: bash
7878
run: |
7979
cmake \
@@ -84,7 +84,7 @@ jobs:
8484
cmake --build "${{ env.BUILD_DIR }}" --config ${{ env.BUILD_TYPE }}
8585
8686
- name: Configure and build macos
87-
if: startsWith(matrix.os, 'macos')
87+
if: runner.os == 'macOS'
8888
shell: bash
8989
run: |
9090
cmake \

.github/workflows/readme.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v5
16-
- uses: actions/setup-node@v5
16+
- uses: actions/setup-node@v6
1717
# ISO Langusge Codes: https://cloud.google.com/translate/docs/languages
1818
- name: Adding README - English
1919
uses: dephraiim/translate-readme@main

src/utils/logfile.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ auto LogFile::rollFile(int count) -> bool
114114
d_ptr->file.close();
115115
}
116116
d_ptr->file.setFileName(filename);
117-
d_ptr->file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered);
117+
auto ret = d_ptr->file.open(QIODevice::WriteOnly | QIODevice::Append
118+
| QIODevice::Unbuffered);
119+
if (!ret) {
120+
qWarning() << "Failed to open log file:" << filename
121+
<< "Error:" << d_ptr->file.errorString();
122+
return false;
123+
}
118124
d_ptr->stream.setDevice(&d_ptr->file);
119125
fprintf(stderr, "%s\n", filename.toUtf8().constData());
120126
return true;

0 commit comments

Comments
 (0)