Skip to content

Commit fb40d21

Browse files
IronsDuclaude
andcommitted
refactor: CI 使用 CMake 预设替代传统命令
- build-gcc: 使用 release 预设 - coverage: 使用 coverage 预设 - build-clang: 使用 clang-release 预设 - 移除不再需要的 BUILD_TYPE 环境变量 - 更新构建产物路径 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 899f155 commit fb40d21

1 file changed

Lines changed: 13 additions & 47 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
pull_request:
77
branches: [ main, develop ]
88

9-
env:
10-
BUILD_TYPE: Release
11-
129
jobs:
1310
# Ubuntu with GCC
1411
build-gcc:
@@ -64,26 +61,16 @@ jobs:
6461
${{ github.workspace }}/vcpkg/vcpkg version
6562
6663
- name: Configure CMake
67-
run: |
68-
mkdir build
69-
cd build
70-
cmake .. \
71-
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
72-
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
73-
-DBUILD_SHARED_LIBS=ON
64+
run: cmake --preset=release
7465

7566
- name: Build
76-
run: |
77-
cd build
78-
make -j$(nproc)
67+
run: cmake --build --preset=release
7968

8069
- name: Run tests
81-
working-directory: build
82-
run: |
83-
ctest --output-on-failure --verbose
70+
run: ctest --preset=release --verbose
8471

8572
- name: Check library linking
86-
working-directory: build
73+
working-directory: build/release
8774
run: |
8875
ldd profiler_example
8976
ldd libprofiler_lib.so
@@ -132,28 +119,17 @@ jobs:
132119
runVcpkgFormatString: ['install', '--recurse', '--clean-after-build', '--x-install-root', '$[env.VCPKG_INSTALLED_DIR]', '--triplet', 'x64-linux']
133120

134121
- name: Configure CMake with Coverage
135-
run: |
136-
mkdir build
137-
cd build
138-
cmake .. \
139-
-DCMAKE_BUILD_TYPE=Debug \
140-
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
141-
-DBUILD_SHARED_LIBS=ON \
142-
-DENABLE_COVERAGE=ON
122+
run: cmake --preset=coverage
143123

144124
- name: Build
145-
run: |
146-
cd build
147-
make -j$(nproc)
125+
run: cmake --build --preset=coverage
148126

149127
- name: Run tests
150-
working-directory: build
151-
run: |
152-
ctest --output-on-failure
128+
run: ctest --preset=coverage
153129

154130
- name: Generate coverage report
131+
working-directory: build/coverage
155132
run: |
156-
cd build
157133
gcovr --xml-pretty --exclude-unreachable-branches --print-summary \
158134
--output coverage.xml \
159135
--root ${{ github.workspace }} \
@@ -164,7 +140,7 @@ jobs:
164140
uses: codecov/codecov-action@v5
165141
with:
166142
token: ${{ secrets.CODECOV_TOKEN }}
167-
files: build/coverage.xml
143+
files: build/coverage/coverage.xml
168144
flags: unittests
169145
name: cpp-remote-profiler-coverage
170146
fail_ci_if_error: false
@@ -225,26 +201,16 @@ jobs:
225201
${{ github.workspace }}/vcpkg/vcpkg version
226202
227203
- name: Configure CMake with Clang
228-
run: |
229-
mkdir build
230-
cd build
231-
CC=clang CXX=clang++ cmake .. \
232-
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
233-
-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
234-
-DBUILD_SHARED_LIBS=ON
204+
run: cmake --preset=clang-release
235205

236206
- name: Build
237-
run: |
238-
cd build
239-
make -j$(nproc)
207+
run: cmake --build --preset=clang-release
240208

241209
- name: Run tests
242-
working-directory: build
243-
run: |
244-
ctest --output-on-failure --verbose
210+
run: ctest --preset=clang-release --verbose
245211

246212
- name: Check library linking
247-
working-directory: build
213+
working-directory: build/clang-release
248214
run: |
249215
ldd profiler_example
250216
ldd libprofiler_lib.so

0 commit comments

Comments
 (0)