Skip to content

Commit

Permalink
fix code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed Nov 15, 2024
1 parent 83fad68 commit 710becc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,39 @@ jobs:
tests:
name: cargo test
runs-on: ubuntu-latest
env:
RUSTFLAGS: -C instrument-coverage
RUST_BACKTRACE: 1
LLVM_PROFILE_FILE: default_%m.profraw
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get install -y zsh fish

- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install coverage tools
run: |
rustup component add llvm-tools
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Run tests
env:
RUST_BACKTRACE: 1
run: cargo test --locked -- --nocapture
run: cargo nextest run

- name: Generate coverage report
run: |
toolchain="$(grep '^default_toolchain' ~/.rustup/settings.toml | cut -d'"' -f2)"
PATH="$HOME/.rustup/toolchains/$toolchain/lib/rustlib/${toolchain#*-}/bin:$PATH"
BINARIES="$(cargo nextest list --list-type binaries-only --message-format json | jq -r '.["rust-binaries"] | .[] | "--object \(.["binary-path"])"' | tr '\n' ' ')"
ARGS="-instr-profile fixit.profdata $BINARIES --object $PWD/target/debug/fixit"
llvm-profdata merge -sparse default_*.profraw -o fixit.profdata
llvm-cov report --use-color --ignore-filename-regex='/.cargo/registry' $ARGS
llvm-cov export -format=lcov $ARGS -sources src/{,**/}*.rs > fixit.lcov
- name: Upload coverage report
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

audit:
name: Check security advisory database
Expand All @@ -70,22 +89,3 @@ jobs:
tar -xvzf cargo-audit-x86_64-unknown-linux-musl-*.tgz
cp cargo-audit-x86_64-unknown-linux-musl-*/cargo-audit .
./cargo-audit audit
coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get install -y zsh fish

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Run cargo-tarpaulin
run: |
gh release download --repo xd009642/tarpaulin --pattern 'cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz'
tar -xvzf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz
./cargo-tarpaulin --follow-exec --engine llvm --skip-clean --coveralls ${{ secrets.COVERALLS_TOKEN }}
2 changes: 0 additions & 2 deletions tests/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fn fish() -> (Session, NamedTempFile) {

let mut p = Session::spawn(fish).expect("Failed to spawn fish");

// Initialize Fish
p.send_line("fixit init fish | source").unwrap();

(p, histfile)
Expand All @@ -37,7 +36,6 @@ fn fixed(fish: (Session, NamedTempFile)) {
p.set_expect_timeout(Some(Duration::from_secs(5)));

p.send_line("eco 'Hello, world!'").unwrap();
p.expect("Unknown command").unwrap();
p.send_line("fix").unwrap();
p.send_line("").unwrap();
p.expect("Hello, world!").unwrap();
Expand Down

0 comments on commit 710becc

Please sign in to comment.