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
79
80
81
82
83
84
85
86
name: Code Coverage
on:
push:
branches:
pull_request:
branches:
permissions:
contents: read
jobs:
coverage-matrix:
name: Coverage on ${{ matrix.os }} / ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
#- os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout code
uses: actions/checkout@v3
# Linux deps + QEMU for ARM64
- name: Install Linux packages
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y llvm lcov qemu-user-static gcc-aarch64-linux-gnu binfmt-support
- name: Enable QEMU binfmt
if: runner.os == 'Linux'
run: sudo update-binfmts --enable qemu-aarch64
- name: Verify QEMU installation
if: runner.os == 'Linux'
run: |
qemu-aarch64-static --version
echo "QEMU for ARM64 is properly configured."
- name: Install cross
if: runner.os == 'Linux'
run: cargo install cross --locked
# Windows LLVM
- name: Install LLVM on Windows
if: runner.os == 'Windows'
run: choco install llvm --no-progress
# Nightly + llvm-cov
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov --locked
# Install the standard library for the chosen target
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
# Run coverage in one logical command (no backslashes)
- name: Run coverage
env:
RUSTFLAGS: "-C instrument-coverage"
CARGO_INCREMENTAL: "0"
shell: bash
run: |
cargo llvm-cov --branch --workspace --html --target ${{ matrix.target }}
- name: Move HTML report
run: mv target/llvm-cov/html target/coverage-${{ matrix.os }}-${{ matrix.target }}
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: html-report-${{ matrix.os }}-${{ matrix.target }}
path: target/coverage-${{ matrix.os }}-${{ matrix.target }}