Skip to content

Commit 846775e

Browse files
authored
Code cov script (#45)
* adding script * run new script * change permissions * add script * update script * fix errors in script * CI yml file to run script instead * add clean script * more specific file name * nit * fix bug * fix script again * revert again * now works --------- Co-authored-by: Luke Videckis <lukevideckis@gmail.com>
1 parent 8af8260 commit 846775e

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ jobs:
7676

7777
# https://doc.rust-lang.org/rustc/instrument-coverage.html
7878
- name: code coverage
79-
run: |
80-
cargo profdata -- merge -sparse default_*.profraw -o ptc_rust.profdata
81-
cargo cov -- show -Xdemangler=rustfilt --use-color --ignore-filename-regex='/.cargo/registry' --instr-profile=ptc_rust.profdata $(find target/debug/examples/ -type f -executable | sed 's/^/--object /')
82-
cargo cov -- export -Xdemangler=rustfilt --ignore-filename-regex='/.cargo/registry' --instr-profile=ptc_rust.profdata $(find target/debug/examples/ -type f -executable | sed 's/^/--object /') --summary-only | python .github/workflows/check_code_cov.py
79+
run: ./.github/workflows/code_cov.sh
80+
81+
shellcheck_shfmt:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v3
85+
- name: Install dependencies
86+
run: sudo apt install shfmt shellcheck
87+
- name: shellcheck and shfmt
88+
run: ./.github/workflows/shellcheck_shfmt.sh

.github/workflows/clean.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cargo clean
3+
rm -rf default_*.profraw ptc_rust.profdata .verify-helper/

.github/workflows/code_cov.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# RUSTFLAGS="-C instrument-coverage -C link-dead-code" oj-verify run --tle 20 --jobs 4 examples/data_structures/rmq.rs
3+
4+
set -eo pipefail
5+
6+
executables=$(find target/debug/examples/ -type f -executable | sed 's/^/--object /')
7+
cov_flags=(-Xdemangler=rustfilt --ignore-filename-regex='/.cargo/registry' --instr-profile=ptc_rust.profdata "${executables}")
8+
9+
cargo profdata -- merge -sparse default_*.profraw -o ptc_rust.profdata
10+
# shellcheck disable=SC2068 # double quotes cause command to fail, not sure why
11+
cargo cov -- show ${cov_flags[@]} --use-color
12+
# shellcheck disable=SC2068
13+
cargo cov -- export ${cov_flags[@]} --summary-only | python .github/workflows/check_code_cov.py
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
shellcheck --shell=bash --check-sourced --enable=all .github/workflows/*.sh || exit 1
4+
5+
shfmt -ln=bash -s -d -w .github/workflows/*.sh || exit 1

0 commit comments

Comments
 (0)