Skip to content

Commit 237de88

Browse files
committed
Add test-coverage report
1 parent 0234318 commit 237de88

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88
workflow_dispatch:
99

10-
concurrency:
10+
concurrency:
1111
group: ${{ github.head_ref || github.ref }}
1212
cancel-in-progress: true
1313

@@ -21,29 +21,48 @@ jobs:
2121
uses: actions/cache@v4
2222
with:
2323
path: |
24-
~/.cargo/bin/
25-
~/.cargo/registry/index/
26-
~/.cargo/registry/cache/
27-
~/.cargo/git/db/
28-
target/
24+
~/.cargo/bin/
25+
~/.cargo/registry/index/
26+
~/.cargo/registry/cache/
27+
~/.cargo/git/db/
28+
target/
2929
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3030
- run: cargo clippy --all-targets --all-features -- -D warnings
3131
run-tests:
3232
runs-on: ubuntu-latest
3333
steps:
3434
- id: checkout
3535
uses: actions/checkout@v4
36+
- name: Setup test coverage env
37+
run: |
38+
cargo install grcov
39+
rustup component add llvm-tools
3640
- name: Cache
3741
uses: actions/cache@v4
3842
with:
3943
path: |
40-
~/.cargo/bin/
41-
~/.cargo/registry/index/
42-
~/.cargo/registry/cache/
43-
~/.cargo/git/db/
44-
target/
44+
~/.cargo/bin/
45+
~/.cargo/registry/index/
46+
~/.cargo/registry/cache/
47+
~/.cargo/git/db/
48+
target/
4549
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4650
- run: cargo test --locked
51+
env:
52+
LLVM_PROFILE_FILE=: target/debug/coverage/grcov-%p-%m.profraw
53+
RUSTFLAGS: -Cinstrument-coverage
54+
- name: Generate coverage
55+
run: |
56+
grcov target/debug/coverage/grcov-*.profraw \
57+
--branch \
58+
--ignore-not-existing \
59+
--binary-path ./target/debug/ \
60+
--source-dir ./src \
61+
--output-types cobertura,markdown \
62+
--ignore "/*" \
63+
--output-path ./target/debug/coverage/
64+
- name: Set summary
65+
run: cat ./target/debug/coverage/markdown.md >> $GITHUB_STEP_SUMMARY
4766
build-container:
4867
permissions:
4968
packages: write
@@ -61,8 +80,8 @@ jobs:
6180
password: ${{ secrets.GITHUB_TOKEN }}
6281
- id: build-image
6382
run: |
64-
pack build ghcr.io/simonerm/imtrand:next \
65-
--buildpack paketo-community/rust \
66-
--builder paketobuildpacks/builder-jammy-buildpackless-base:latest \
67-
--cache-image ghcr.io/simonerm/imtrand-cache:next \
68-
--publish
83+
pack build ghcr.io/simonerm/imtrand:next \
84+
--buildpack paketo-community/rust \
85+
--builder paketobuildpacks/builder-jammy-buildpackless-base:latest \
86+
--cache-image ghcr.io/simonerm/imtrand-cache:next \
87+
--publish

0 commit comments

Comments
 (0)