Skip to content

Commit 7b22a73

Browse files
author
EchoBT
committed
ci: add code coverage badge with cargo-llvm-cov
1 parent 2a89445 commit 7b22a73

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ jobs:
4141
test:
4242
name: Test
4343
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
4446
steps:
4547
- name: Checkout code
4648
uses: actions/checkout@v4
4749

4850
- name: Setup Rust toolchain
4951
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
components: llvm-tools-preview
54+
55+
- name: Install cargo-llvm-cov
56+
uses: taiki-e/install-action@cargo-llvm-cov
5057

5158
- name: Cache cargo
5259
uses: actions/cache@v4
@@ -59,8 +66,17 @@ jobs:
5966
restore-keys: |
6067
${{ runner.os }}-cargo-test-
6168
62-
- name: Run tests
63-
run: cargo test --verbose --workspace
69+
- name: Run tests with coverage
70+
run: cargo llvm-cov --workspace --json --output-path coverage.json --summary-only
71+
72+
- name: Convert coverage to json-summary format
73+
run: |
74+
COVERAGE=$(cat coverage.json | jq '.data[0].totals.lines.percent')
75+
echo "{\"total\":{\"lines\":{\"pct\":$COVERAGE}}}" > coverage-summary.json
76+
77+
- name: Update Coverage Badge
78+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
79+
uses: we-cli/coverage-badge-action@main
6480

6581
clippy:
6682
name: Clippy

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**Distributed validator network for decentralized AI evaluation on Bittensor**
66

77
[![CI](https://github.com/PlatformNetwork/platform/actions/workflows/ci.yml/badge.svg)](https://github.com/PlatformNetwork/platform/actions/workflows/ci.yml)
8+
[![Coverage](https://platformnetwork.github.io/platform/badges/coverage.svg)](https://github.com/PlatformNetwork/platform/actions)
89
[![License](https://img.shields.io/github/license/PlatformNetwork/platform)](https://github.com/PlatformNetwork/platform/blob/main/LICENSE)
910
[![GitHub stars](https://img.shields.io/github/stars/PlatformNetwork/platform)](https://github.com/PlatformNetwork/platform/stargazers)
1011
[![Rust](https://img.shields.io/badge/rust-1.90+-orange.svg)](https://www.rust-lang.org/)

0 commit comments

Comments
 (0)