-
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.36 KB
/
Copy pathcoverage.yml
File metadata and controls
74 lines (63 loc) · 2.36 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
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# coverage.yml — Code coverage reporting via cargo-tarpaulin.
# Generates coverage report and uploads to Codecov.
name: Coverage
on:
pull_request:
branches: ['**']
push:
branches: [main]
permissions:
contents: read
jobs:
coverage:
name: Code coverage
# No `if: hashFiles('Cargo.toml') != ''` guard — `hashFiles()` is invalid in
# a job-level `if:` and startup-fails the whole workflow (see rust-ci.yml).
# This repo always has a Cargo workspace.
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Generate coverage report
run: |
cargo tarpaulin \
-p jtv-core \
--out xml \
--out html \
--output-dir coverage/ \
--skip-clean \
--timeout 120
- name: Upload to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v5
with:
files: coverage/cobertura.xml
fail_ci_if_error: false
- name: Write summary
if: always()
run: |
echo "## Code Coverage Report" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if [ -f coverage/cobertura.xml ]; then
LINE_RATE=$(grep -oP 'line-rate="\K[^"]+' coverage/cobertura.xml | head -1)
PERCENT=$(echo "$LINE_RATE * 100" | bc -l 2>/dev/null | head -c 5 || echo "$LINE_RATE")
echo "Line coverage: **${PERCENT}%**" >> "$GITHUB_STEP_SUMMARY"
else
echo "Coverage report not generated." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload HTML report as artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-report
path: coverage/
retention-days: 30