-
Notifications
You must be signed in to change notification settings - Fork 54
74 lines (66 loc) · 3.01 KB
/
coverage.yml
File metadata and controls
74 lines (66 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Test Coverage
# Run on every push to the main branches and on every pull-request targeting them.
# Also triggers manually from the Actions UI (workflow_dispatch).
on:
push:
branches: [main, master, "chore/**", "ci/**", "feature/**"]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
coverage:
name: "Cargo Test Coverage (≥ 95 %)"
runs-on: ubuntu-latest
steps:
# -----------------------------------------------------------------------
# 1. Source
# -----------------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
# -----------------------------------------------------------------------
# 2. Rust toolchain — stable is sufficient for Soroban unit tests
# -----------------------------------------------------------------------
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
# -----------------------------------------------------------------------
# 3. Cache — speeds up subsequent runs considerably
# -----------------------------------------------------------------------
- name: Cache Cargo registry and build artefacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/
# Key rotates when Cargo.lock changes; falls back to any prior entry.
key: ${{ runner.os }}-cargo-tarpaulin-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-tarpaulin-
${{ runner.os }}-cargo-
# -----------------------------------------------------------------------
# 4. Install cargo-tarpaulin via the taiki-e installer — faster than
# `cargo install` because it downloads a pre-built binary.
# -----------------------------------------------------------------------
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
# -----------------------------------------------------------------------
# 5. Run coverage
# Configuration lives in tarpaulin.toml (workspace root).
# A non-zero exit here means coverage fell below the 95 % threshold —
# this deliberately fails the workflow.
# -----------------------------------------------------------------------
- name: Run test coverage
run: cargo tarpaulin --config tarpaulin.toml
# -----------------------------------------------------------------------
# 6. Upload HTML + XML report as a downloadable workflow artefact.
# Always runs so the report is available even when coverage fails.
# -----------------------------------------------------------------------
- name: Upload coverage report artefact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 30