Skip to content

Commit c746ad1

Browse files
committed
refactor(ast): add test coverage workflow
Change-Id: Ie9234a0998f7c424672cd8dffca44fe0d406148d
1 parent a7b5f4d commit c746ad1

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- test-macos
2020
- test-windows
2121
- lint
22+
- coverage
2223
steps:
2324
- run: exit 0
2425

@@ -98,3 +99,36 @@ jobs:
9899
- name: Format check
99100
run: |
100101
cargo fmt -- --check
102+
103+
cov:
104+
runs-on: ubuntu-latest
105+
timeout-minutes: 40
106+
permissions:
107+
contents: read
108+
checks: write
109+
pull-requests: write
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
- uses: dtolnay/rust-toolchain@stable
114+
- uses: taiki-e/install-action@v2
115+
with:
116+
tool: cargo-llvm-cov
117+
118+
- name: Generate coverage (LCOV + HTML)
119+
run: |
120+
cargo llvm-cov --workspace --all-features --doctests \
121+
--lcov --output-path lcov.info
122+
cargo llvm-cov --workspace --all-features --doctests --html
123+
124+
- uses: actions/upload-artifact@v4
125+
with:
126+
name: coverage-html
127+
path: target/llvm-cov/html
128+
129+
- name: Upload to Codecov
130+
uses: codecov/codecov-action@v4
131+
with:
132+
files: lcov.info
133+
fail_ci_if_error: true
134+
verbose: true

.github/workflows/cov.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project: # 可选:总覆盖率门禁(想只卡 patch 也行)
4+
default:
5+
informational: true # 仅展示,不卡死 CI(想卡就设 false 并配 target)
6+
patch:
7+
default:
8+
target: 70% # 新增/修改的 diff 区域覆盖率必须 ≥ 70%
9+
threshold: 0% # 不允许低于目标(留有回旋可设 2% 之类)
10+
informational: false # 失败时让检查变红,阻止合并(配合分支保护)

0 commit comments

Comments
 (0)