Skip to content

Commit 082f5e0

Browse files
committed
Add Codecov coverage workflow and badge
1 parent f132751 commit 082f5e0

File tree

4 files changed

+56
-6
lines changed

4 files changed

+56
-6
lines changed

.github/workflows/coverage.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
coverage:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout source
17+
uses: actions/checkout@v4
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: llvm-tools-preview
23+
24+
- name: Install cargo-llvm-cov
25+
uses: taiki-e/install-action@v2
26+
with:
27+
tool: cargo-llvm-cov
28+
29+
- name: Generate coverage report
30+
run: |
31+
cargo llvm-cov --workspace --locked --lcov --output-path lcov.info
32+
env:
33+
CARGO_INCREMENTAL: "0"
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v4
37+
with:
38+
files: lcov.info
39+
flags: unit
40+
fail_ci_if_error: true
41+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# rsworktree
22

3+
[![Codecov](https://codecov.io/gh/ozan/rust-git-worktree/branch/main/graph/badge.svg)](https://codecov.io/gh/ozan/rust-git-worktree)
4+
35
`rsworktree` is a Rust CLI for managing Git worktrees in a single repo-local directory (`.rsworktree`). It provides a focused, ergonomic workflow for creating, jumping into, listing, and removing worktrees without leaving the terminal.
46

57
## Table of Contents

tests/commands/cd.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,22 @@ fn cd_command_spawns_shell_in_worktree() -> Result<(), Box<dyn Error>> {
7979
.assert()
8080
.success();
8181

82+
let worktree_path = repo_dir
83+
.path()
84+
.join(".rsworktree")
85+
.join("feature/test")
86+
.canonicalize()?;
87+
8288
Command::cargo_bin("rsworktree")?
8389
.current_dir(repo_dir.path())
8490
.env("RSWORKTREE_SHELL", "env")
8591
.args(["cd", "feature/test"])
8692
.assert()
8793
.success()
88-
.stdout(
89-
predicate::str::contains("Spawning shell")
90-
.and(predicate::str::contains("PWD=/"))
91-
.and(predicate::str::contains("feature/test")),
92-
);
94+
.stdout(predicate::str::contains(format!(
95+
"PWD={}",
96+
worktree_path.display()
97+
)));
9398

9499
Ok(())
95100
}

tests/commands/rm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ fn rm_command_spawns_root_shell_when_called_inside_worktree() -> Result<(), Box<
112112
.join(".rsworktree")
113113
.join("feature/move-back");
114114

115+
let repo_root = repo_dir.path();
116+
115117
Command::cargo_bin("rsworktree")?
116118
.current_dir(&worktree_path)
117119
.env("RSWORKTREE_SHELL", "env")
@@ -120,7 +122,7 @@ fn rm_command_spawns_root_shell_when_called_inside_worktree() -> Result<(), Box<
120122
.success()
121123
.stdout(predicate::str::contains(format!(
122124
"PWD={}",
123-
repo_dir.path().display()
125+
repo_root.display()
124126
)));
125127

126128
Ok(())

0 commit comments

Comments
 (0)