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
75
76
77
78
name: Update Coverage
on:
# Run on pushes to master that change source or test code
push:
branches:
paths:
- 'src/**'
- 'tests/**'
- 'scripts/generate-coverage.py'
- 'Cargo.toml'
- 'Cargo.lock'
# Allow manual trigger
workflow_dispatch:
# Run weekly on Monday at 00:00 UTC
schedule:
- cron: '0 0 * * 1'
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache target directory
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-target-coverage-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Generate coverage
run: |
chmod +x ./scripts/generate-coverage.py
./scripts/generate-coverage.py
- name: Commit and push if changed
run: |
git pull
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add docs/assets/data/coverage.json docs/assets/data/stats.json docs/assets/data/coverage-history.json
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update coverage data [skip ci]"
git push
fi