Skip to content

Commit b3fd4e7

Browse files
author
Packit Build
committed
feat(code-coverage): add code coverage reprot
use llmv-cov to generate coverage report Signed-off-by: Packit Build <packit@fedoraproject.org>
1 parent 33b27dc commit b3fd4e7

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,26 @@ jobs:
5959
args: -- -D warnings -D clippy::panic -D clippy::todo
6060

6161
build_and_test:
62+
name: Build, test, and coverage
6263
runs-on: ubuntu-latest
63-
container:
64+
container:
6465
image: fedora:latest
6566
options: --user root
67+
env:
68+
CARGO_TERM_COLOR: always
69+
LLVM_COV: /usr/bin/llvm-cov
70+
LLVM_PROFDATA: /usr/bin/llvm-profdata
6671
steps:
6772
- name: Install deps
6873
run: |
69-
dnf install -y make gcc git cargo rust git grub2-efi grub2-efi-modules shim
74+
dnf install -y make gcc git cargo rust git grub2-efi grub2-efi-modules shim llvm
7075
- uses: actions/checkout@v4
7176
with:
7277
persist-credentials: false
7378
- name: Fix git trust
7479
run: git config --global --add safe.directory /__w/greenboot-rs/greenboot-rs
7580
- name: Cache
76-
uses: actions/cache@v3
81+
uses: actions/cache@v4
7782
with:
7883
path: |
7984
~/.cargo/bin/
@@ -82,18 +87,36 @@ jobs:
8287
~/.cargo/git/db/
8388
target/
8489
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
90+
- name: Install cargo-llvm-cov
91+
run: cargo install cargo-llvm-cov
8592
- name: Build
8693
uses: actions-rs/cargo@v1
8794
with:
8895
command: build
89-
- name: Run tests with mock mounts
90-
uses: actions-rs/cargo@v1
96+
- name: Run tests with coverage
97+
run: |
98+
cargo llvm-cov test -- --test-threads=1
99+
cargo llvm-cov report --html --output-dir coverage/html
100+
- name: Upload coverage report (HTML artifact)
101+
uses: actions/upload-artifact@v4
91102
with:
92-
command: test
93-
args: --features test-remount -- --test-threads=1
94-
- name: Run mount logic tests
95-
uses: actions-rs/cargo@v1
103+
name: coverage-report
104+
path: coverage/html/
105+
retention-days: 14
106+
- name: Upload to GitHub Pages
107+
uses: actions/upload-pages-artifact@v3
96108
with:
97-
command: test
98-
# matches 2 remount tests
99-
args: test_remount_boot
109+
path: coverage/html/
110+
111+
deploy-pages:
112+
name: Deploy coverage to GitHub Pages
113+
needs: build_and_test
114+
if: github.ref == 'refs/heads/greenboot-rs' && github.event_name == 'push'
115+
runs-on: ubuntu-latest
116+
permissions:
117+
pages: write
118+
id-token: write
119+
environment: github-pages
120+
steps:
121+
- name: Deploy to GitHub Pages
122+
uses: actions/deploy-pages@v4

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ log = "0.4"
2121
clap = { version = "4.0", features = ["derive"] }
2222
config = "0.15.13"
2323
pretty_env_logger = "0.5.0"
24-
nix = "0.30.1"
24+
nix = "0.31.1"
2525
glob = "0.3.0"
2626
serde = "1.0"
2727
serde_json = "1.0"

0 commit comments

Comments
 (0)