4040 container : fedora:latest
4141 steps :
4242 - uses : actions/checkout@v4
43- - name : Cache
44- uses : actions/cache@v3
45- with :
46- path : |
47- ~/.cargo/bin/
48- ~/.cargo/registry/index/
49- ~/.cargo/registry/cache/
50- ~/.cargo/git/db/
51- target/
52- key : ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
5343 - name : Install deps
5444 run : |
5545 dnf install -y make gcc git clippy cargo rust
@@ -58,42 +48,54 @@ jobs:
5848 command : clippy
5949 args : -- -D warnings -D clippy::panic -D clippy::todo
6050
61- build_and_test :
51+ build_and_test_with_coverage :
52+ name : Build, test with coverage
6253 runs-on : ubuntu-latest
63- container :
54+ container :
6455 image : fedora:latest
6556 options : --user root
57+ env :
58+ CARGO_TERM_COLOR : always
59+ LLVM_COV : /usr/bin/llvm-cov
60+ LLVM_PROFDATA : /usr/bin/llvm-profdata
6661 steps :
6762 - name : Install deps
6863 run : |
69- dnf install -y make gcc git cargo rust git grub2-efi grub2-efi-modules shim
64+ dnf install -y make gcc git cargo rust git grub2-efi grub2-efi-modules shim llvm
7065 - uses : actions/checkout@v4
7166 with :
7267 persist-credentials : false
7368 - name : Fix git trust
7469 run : git config --global --add safe.directory /__w/greenboot-rs/greenboot-rs
75- - name : Cache
76- uses : actions/cache@v3
77- with :
78- path : |
79- ~/.cargo/bin/
80- ~/.cargo/registry/index/
81- ~/.cargo/registry/cache/
82- ~/.cargo/git/db/
83- target/
84- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
70+ - name : Install cargo-llvm-cov
71+ run : cargo install cargo-llvm-cov
8572 - name : Build
86- uses : actions-rs/cargo@v1
87- with :
88- command : build
89- - name : Run tests with mock mounts
90- uses : actions-rs/cargo@v1
73+ run : cargo build
74+ - name : Run tests with coverage
75+ run : |
76+ cargo llvm-cov test -- --test-threads=1
77+ cargo llvm-cov report --html --output-dir tests/coverage
78+ - name : Upload coverage report (HTML artifact)
79+ uses : actions/upload-artifact@v4
9180 with :
92- command : test
93- args : --features test-remount -- --test-threads=1
94- - name : Run mount logic tests
95- uses : actions-rs/cargo@v1
81+ name : coverage-report
82+ path : tests/coverage/
83+ retention-days : 14
84+ - name : Upload coverage report (GitHub Pages)
85+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
86+ uses : actions/upload-pages-artifact@v3
9687 with :
97- command : test
98- # matches 2 remount tests
99- args : test_remount_boot
88+ path : tests/coverage/
89+
90+ deploy-pages :
91+ name : Deploy coverage to GitHub Pages
92+ needs : build_and_test
93+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
94+ runs-on : ubuntu-latest
95+ permissions :
96+ pages : write
97+ id-token : write
98+ environment : github-pages
99+ steps :
100+ - name : Deploy to GitHub Pages
101+ uses : actions/deploy-pages@v4
0 commit comments