Skip to content

Commit 070ba80

Browse files
committed
feat(ci): 拆分 CI 为 per-OS workflow + 新增 CodeQL/clang-tidy
- 新增 ubuntu.yml / macos.yml / windows.yml:各自独立运行 Debug+ASan / Debug+TSan / Release - 精简 ci.yml 为额外检查:clang-format / clang-tidy / install-test - 新增 codeql-analysis.yml:周一自动安全扫描 - 新增 .gitattributes / .gitignore / FUNDING.yml / ISSUE_TEMPLATE
1 parent 7e8bc30 commit 070ba80

10 files changed

Lines changed: 254 additions & 172 deletions

File tree

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Mark third-party and build artifacts as vendored / excluded from stats
2+
benchmarks/taskflow/* linguist-vendored
3+
build/* linguist-vendored
4+
documentation/img/* linguist-vendored
5+
6+
# C++ source files
7+
*.cpp linguist-language=C++
8+
*.hpp linguist-language=C++
9+
*.h linguist-language=C++

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Repository for the funding models
2+
3+
github: wicyn
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
---
5+
6+
**Describe the bug**
7+
A clear and concise description of what the bug is.
8+
9+
**To Reproduce**
10+
Steps to reproduce the behavior. Please include a minimal, self-contained code example:
11+
12+
```cpp
13+
#include <taskflowlite/taskflowlite.hpp>
14+
15+
int main() {
16+
// minimal code that triggers the bug
17+
}
18+
```
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Environment:**
24+
- OS: [e.g. Windows 11, Ubuntu 24.04, macOS 15]
25+
- Compiler: [e.g. GCC 14.1, Clang 18.1, MSVC 19.40]
26+
- C++ Standard: [e.g. C++23]
27+
- TaskflowLite version/commit: [e.g. main @ a1b2c3d]
28+
29+
**Additional context**
30+
Add any other context about the problem here.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
---
5+
6+
**Please describe your feature request.**
7+
A clear and concise description of what you want to happen, and the problem it solves. Ex. I'm always frustrated when [...]
8+
9+
**Describe the solution you'd like**
10+
A clear and concise description of what you want to happen.
11+
12+
**Describe alternatives you've considered**
13+
A clear and concise description of any alternative solutions or features you've considered.
14+
15+
**Additional context**
16+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 10 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: TaskflowLite CI
1+
name: CI Extras
22

33
on:
44
push:
@@ -14,11 +14,9 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
# ============================================================================
18-
# 代码格式检查(clang-format)
19-
# ============================================================================
17+
# clang-format
2018
clang-format:
21-
name: clang-format check
19+
name: clang-format
2220
runs-on: ubuntu-latest
2321
steps:
2422
- uses: actions/checkout@v4
@@ -27,175 +25,20 @@ jobs:
2725
- name: Run clang-format
2826
run: find taskflowlite -name '*.hpp' -o -name '*.cpp' | xargs clang-format-18 --dry-run --Werror
2927

30-
# ============================================================================
31-
# 编译 + 测试矩阵(OS × BuildType × Sanitizer)
32-
# ============================================================================
33-
build-and-test:
34-
name: ${{ matrix.os }} | ${{ matrix.build_type }} | San=${{ matrix.sanitizer }}
35-
runs-on: ${{ matrix.os }}
36-
needs: clang-format
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
include:
41-
# ── Ubuntu GCC ──
42-
- os: ubuntu-latest
43-
compiler: gcc
44-
build_type: Release
45-
sanitizer: OFF
46-
- os: ubuntu-latest
47-
compiler: gcc
48-
build_type: Debug
49-
sanitizer: ASAN
50-
- os: ubuntu-latest
51-
compiler: gcc
52-
build_type: Debug
53-
sanitizer: TSAN
54-
55-
# ── Ubuntu Clang ──
56-
- os: ubuntu-latest
57-
compiler: clang
58-
build_type: Release
59-
sanitizer: OFF
60-
- os: ubuntu-latest
61-
compiler: clang
62-
build_type: Debug
63-
sanitizer: ASAN
64-
65-
# ── macOS ──
66-
- os: macos-latest
67-
compiler: clang
68-
build_type: Release
69-
sanitizer: OFF
70-
- os: macos-latest
71-
compiler: clang
72-
build_type: Debug
73-
sanitizer: ASAN
74-
- os: macos-latest
75-
compiler: clang
76-
build_type: Debug
77-
sanitizer: TSAN
78-
79-
# ── Windows MSVC ──
80-
- os: windows-latest
81-
compiler: msvc
82-
build_type: Release
83-
sanitizer: OFF
84-
- os: windows-latest
85-
compiler: msvc
86-
build_type: Debug
87-
sanitizer: ASAN
88-
89-
steps:
90-
- name: Checkout
91-
uses: actions/checkout@v4
92-
93-
# ── 编译器配置 ──
94-
- name: Setup GCC
95-
if: matrix.compiler == 'gcc'
96-
run: |
97-
sudo apt-get update -qq
98-
sudo apt-get install -y -qq g++-14
99-
echo "CC=gcc-14" >> $GITHUB_ENV
100-
echo "CXX=g++-14" >> $GITHUB_ENV
101-
102-
- name: Setup Clang
103-
if: matrix.compiler == 'clang'
104-
run: |
105-
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
106-
sudo add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
107-
sudo apt-get update -qq
108-
sudo apt-get install -y -qq clang-18 libc++-18-dev libc++abi-18-dev
109-
echo "CC=clang-18" >> $GITHUB_ENV
110-
echo "CXX=clang++-18" >> $GITHUB_ENV
111-
112-
# ── ccache 加速 ──
113-
- name: Setup ccache
114-
if: matrix.os != 'windows-latest'
115-
uses: hendrikmuhs/ccache-action@v1
116-
with:
117-
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}
118-
119-
- name: Configure ccache (MSVC)
120-
if: matrix.os == 'windows-latest'
121-
uses: actions/cache@v4
122-
with:
123-
path: ~/ccache
124-
key: ccache-${{ matrix.os }}-${{ matrix.build_type }}-${{ github.run_id }}
125-
restore-keys: ccache-${{ matrix.os }}-${{ matrix.build_type }}-
126-
127-
# ── CMake 配置 ──
128-
- name: Configure CMake
129-
run: >
130-
cmake -S . -B build
131-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
132-
-DTASKFLOWLITE_BUILD_TESTS=ON
133-
-DTASKFLOWLITE_BUILD_EXAMPLES=ON
134-
-DTASKFLOWLITE_SANITIZER=${{ matrix.sanitizer }}
135-
${{ matrix.os == 'windows-latest' && '-T ClangCL' || '' }}
136-
137-
# ── 编译 ──
138-
- name: Build
139-
run: cmake --build build --config ${{ matrix.build_type }} --parallel ${{ runner.os == 'macOS' && '3' || '4' }}
140-
141-
# ── Windows ASan DLL 准备 ──
142-
- name: Copy ASan DLLs (Windows)
143-
if: matrix.os == 'windows-latest' && matrix.sanitizer == 'ASAN'
144-
shell: pwsh
145-
working-directory: ${{ github.workspace }}/build
146-
run: |
147-
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
148-
$msvcVer = (Get-ChildItem "$vsPath\VC\Tools\MSVC" | Sort-Object Name -Descending | Select-Object -First 1).Name
149-
$asanDir = "$vsPath\VC\Tools\MSVC\$msvcVer\bin\Hostx64\x64"
150-
Get-ChildItem -Path . -Filter "TaskflowLiteTest.exe" -Recurse | ForEach-Object {
151-
Copy-Item -Path "$asanDir\clang_rt.asan*.dll" -Destination $_.DirectoryName -Force
152-
}
153-
154-
# ── 运行测试 (Unix) ──
155-
- name: Run Tests (Unix)
156-
if: matrix.os != 'windows-latest'
157-
working-directory: ${{ github.workspace }}/build
158-
env:
159-
TSAN_OPTIONS: ${{ matrix.sanitizer == 'TSAN' && format('suppressions={0}/tsan_suppressions.txt second_deadlock_stack=1 history_size=7', github.workspace) || '' }}
160-
ASAN_OPTIONS: ${{ matrix.sanitizer == 'ASAN' && 'halt_on_error=1:abort_on_error=1:print_stacktrace=1:detect_leaks=1' || '' }}
161-
UBSAN_OPTIONS: ${{ matrix.sanitizer == 'ASAN' && 'halt_on_error=1:print_stacktrace=1' || '' }}
162-
CTEST_OUTPUT_ON_FAILURE: '1'
163-
run: |
164-
if [ "${{ matrix.sanitizer }}" = "TSAN" ]; then
165-
printf '%s\n' \
166-
'race:Catch::RunContext' \
167-
'race:Catch::Detail' \
168-
'race:Catch::StringStreams' \
169-
'race:Catch::OutputRedirect' \
170-
'race:Catch::ConsoleReporter' \
171-
'race:__sanitizer::IsAccessibleMemoryRange' \
172-
> ${{ github.workspace }}/tsan_suppressions.txt
173-
fi
174-
ctest -C ${{ matrix.build_type }} --output-on-failure -j2
175-
176-
# ── 运行测试 (Windows) ──
177-
- name: Run Tests (Windows)
178-
if: matrix.os == 'windows-latest'
179-
working-directory: ${{ github.workspace }}/build
180-
run: ctest -C ${{ matrix.build_type }} --output-on-failure -j2
181-
182-
# ============================================================================
183-
# 额外:Clang-Tidy 静态分析
184-
# ============================================================================
28+
# clang-tidy (PR only)
18529
clang-tidy:
186-
name: clang-tidy analysis
30+
name: clang-tidy
18731
runs-on: ubuntu-latest
188-
needs: clang-format
18932
if: github.event_name == 'pull_request'
19033
steps:
19134
- uses: actions/checkout@v4
192-
- name: Install tools
35+
- name: Install clang-tidy
19336
run: |
19437
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
19538
sudo add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
19639
sudo apt-get update -qq
19740
sudo apt-get install -y -qq clang-tidy-18
198-
- name: Configure CMake
41+
- name: Configure
19942
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DTASKFLOWLITE_BUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
20043
- name: Run clang-tidy
20144
run: |
@@ -204,24 +47,20 @@ jobs:
20447
--checks='-*,bugprone-*,performance-*,modernize-use-nullptr,modernize-use-override' \
20548
--warnings-as-errors='bugprone-*'
20649
207-
# ============================================================================
208-
# 发布构建验证(Install + 消费测试)
209-
# ============================================================================
50+
# install + consumer test
21051
install-test:
211-
name: install + consumer test
52+
name: install + consumer
21253
runs-on: ubuntu-latest
213-
needs: clang-format
21454
steps:
21555
- uses: actions/checkout@v4
21656
- name: Configure
21757
run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install
21858
- name: Install
21959
run: cmake --install build
220-
- name: Verify installed files
60+
- name: Verify
22161
run: |
22262
test -f install/include/taskflowlite/taskflowlite.hpp
22363
test -f install/lib/cmake/TaskflowLite/TaskflowLiteConfig.cmake
224-
echo "Install verified OK"
22564
- name: Consumer test
22665
run: |
22766
mkdir -p /tmp/test-consumer
@@ -245,4 +84,3 @@ jobs:
24584
cmake -S /tmp/test-consumer -B /tmp/test-consumer/build \
24685
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install
24786
cmake --build /tmp/test-consumer/build
248-
echo "Consumer build OK"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '30 2 * * 1'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
strategy:
20+
fail-fast: false
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Initialize CodeQL
24+
uses: github/codeql-action/init@v3
25+
with:
26+
languages: cpp
27+
- name: Build
28+
run: |
29+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DTASKFLOWLITE_BUILD_TESTS=ON
30+
cmake --build build --parallel $(nproc)
31+
- name: Perform CodeQL Analysis
32+
uses: github/codeql-action/analyze@v3

.github/workflows/macos.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: macOS
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
# Debug + ASan/UBSan
8+
debug-asan:
9+
runs-on: macos-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Configure
13+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DTASKFLOWLITE_BUILD_TESTS=ON -DTASKFLOWLITE_SANITIZER=ASAN
14+
- name: Build
15+
run: cmake --build build --parallel $(sysctl -n hw.logicalcpu)
16+
- name: Test
17+
working-directory: build
18+
run: ctest --output-on-failure
19+
20+
# Debug + TSan
21+
debug-tsan:
22+
runs-on: macos-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Configure
26+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DTASKFLOWLITE_BUILD_TESTS=ON -DTASKFLOWLITE_SANITIZER=TSAN
27+
- name: Build
28+
run: cmake --build build --parallel $(sysctl -n hw.logicalcpu)
29+
- name: Test
30+
working-directory: build
31+
env:
32+
TSAN_OPTIONS: suppressions=tsan_suppressions.txt second_deadlock_stack=1 history_size=7
33+
run: |
34+
printf 'race:Catch::RunContext\nrace:Catch::Detail\nrace:__sanitizer::IsAccessibleMemoryRange\n' > tsan_suppressions.txt
35+
ctest --output-on-failure
36+
37+
# Release
38+
release:
39+
runs-on: macos-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Configure
43+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DTASKFLOWLITE_BUILD_TESTS=ON
44+
- name: Build
45+
run: cmake --build build --parallel $(sysctl -n hw.logicalcpu)
46+
- name: Test
47+
working-directory: build
48+
run: ctest --output-on-failure

0 commit comments

Comments
 (0)