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
@@ -59,41 +49,55 @@ jobs:
5949 args : -- -D warnings -D clippy::panic -D clippy::todo
6050
6151 build_and_test :
52+ name : Build, test, and 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
8673 uses : actions-rs/cargo@v1
8774 with :
8875 command : build
89- - name : Run tests with mock mounts
90- uses : actions-rs/cargo@v1
76+ - name : Run tests with coverage
77+ run : |
78+ cargo llvm-cov test -- --test-threads=1
79+ cargo llvm-cov report --html --output-dir coverage/html
80+ - name : Upload coverage report (HTML artifact)
81+ uses : actions/upload-artifact@v4
9182 with :
92- command : test
93- args : --features test-remount -- --test-threads=1
94- - name : Run mount logic tests
95- uses : actions-rs/cargo@v1
83+ name : coverage-report
84+ path : coverage/html/
85+ retention-days : 14
86+ - name : Upload to GitHub Pages
87+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
88+ uses : actions/upload-pages-artifact@v3
9689 with :
97- command : test
98- # matches 2 remount tests
99- args : test_remount_boot
90+ path : coverage/html/
91+
92+ deploy-pages :
93+ name : Deploy coverage to GitHub Pages
94+ needs : build_and_test
95+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
96+ runs-on : ubuntu-latest
97+ permissions :
98+ pages : write
99+ id-token : write
100+ environment : github-pages
101+ steps :
102+ - name : Deploy to GitHub Pages
103+ uses : actions/deploy-pages@v4
0 commit comments