Skip to content

Commit c607e14

Browse files
committed
Add testing setup with coverage configuration and GitHub Actions workflow
1 parent b304f8f commit c607e14

File tree

9 files changed

+740
-1
lines changed

9 files changed

+740
-1
lines changed

.coveragerc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[run]
2+
branch = True
3+
source = gitvault
4+
omit =
5+
*/tests/*
6+
*/.venv/*
7+
*/venv/*
8+
*/__init__.py
9+
*/.cache/*
10+
11+
[report]
12+
show_missing = True
13+
fail_under = 80

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Run Tests and Coverage
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.10", "3.11", "3.12", "3.13"]
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements.txt
27+
pip install coverage pytest
28+
29+
- name: Run tests with coverage
30+
run: bash scripts/test.sh
31+
32+
- name: Upload HTML coverage report
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: htmlcov-${{ matrix.python-version }}
36+
path: htmlcov/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,6 @@ memory-bank/
182182
# GitVault
183183
.gitvault_private/
184184
.gitvaultinclude
185+
186+
# VS Code
187+
.vscode/

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# GitVault
2+
3+
A simple way to keep your private files safe while sharing your code with the world.
4+
5+
---
6+
7+
## Overview
8+
9+
GitVault helps you **manage sensitive files and folders** that you don’t want in your public Git repo. It lets you back up and version those private files in a separate, secure repo — so you get the best of both worlds.
10+
11+
---
12+
13+
## What it does
14+
15+
- Use a `.gitvaultinclude` file to list private stuff you want to track (which should also be in `.gitignore`)
16+
- `gitvault init` sets up GitVault in your project, creating the private repo and config files
17+
- `gitvault status` shows what’s changed in your private files since your last save
18+
- `gitvault save` commits and pushes those private changes to your private repo
19+
- `gitvault discard` lets you throw away private changes you don’t want to keep
20+
- Keeps secrets out of your public repo, no surprises
21+
- Manual control — **you decide when to save, discard, or check**
22+
23+
---
24+
25+
## How to use it
26+
27+
1. **Initialize GitVault**
28+
29+
Run this once in your repo to set things up:
30+
31+
```bash
32+
gitvault init
33+
```
34+
35+
2. **List your private files**
36+
37+
Create a `.gitvaultinclude` file with paths to your private files or folders (make sure they’re also in `.gitignore`):
38+
39+
```
40+
secrets.env
41+
private_notes/
42+
config/dev.yaml
43+
```
44+
45+
3. **See what’s changed**
46+
47+
```bash
48+
gitvault status
49+
```
50+
51+
4. **Save your private changes**
52+
53+
```bash
54+
gitvault save
55+
```
56+
57+
5. **Discard private changes you don’t want**
58+
59+
```bash
60+
gitvault discard
61+
```
62+
63+
That’s it — your sensitive stuff is safely versioned, but never exposed.
64+
65+
---
66+
67+
## Installation
68+
69+
_Coming soon on PyPI!_
70+
For now, just clone this repo and install the dependencies:
71+
72+
```bash
73+
pip install -r requirements.txt
74+
```
75+
76+
---
77+
78+
## Contributing
79+
80+
Ideas, bugs, or want to help out?
81+
Pull requests are welcome! Or just open an issue and let’s chat.
82+
83+
---
84+
85+
## License
86+
87+
MIT License

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
click==8.1.8
2-
gitpython==3.1.44
2+
gitpython==3.1.44
3+
pytest==8.3.5

scripts/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
coverage run -m pytest
5+
coverage report -m
6+
coverage html

tests/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import pytest
2+
from unittest import mock
3+
4+
@pytest.fixture
5+
def temp_dir(tmp_path):
6+
"""Provides a temporary directory unique to the test invocation."""
7+
return tmp_path
8+
9+
@pytest.fixture
10+
def mock_git_repo():
11+
"""Mocks GitPython's Repo object."""
12+
with mock.patch("git.Repo") as mock_repo_cls:
13+
mock_repo = mock.Mock()
14+
mock_repo_cls.return_value = mock_repo
15+
yield mock_repo
16+
17+
@pytest.fixture(autouse=True)
18+
def shared_setup_teardown():
19+
"""Shared setup/teardown logic for all tests, including patching gh repo create."""
20+
import subprocess as sp
21+
from unittest import mock
22+
23+
real_run = sp.run
24+
25+
def fake_run(*args, **kwargs):
26+
# Support subprocess.run(args, **kwargs) where args can be list or str
27+
cmd = args[0] if args else kwargs.get("args")
28+
if isinstance(cmd, list) and len(cmd) >= 3:
29+
if cmd[0] == "gh" and cmd[1] == "repo" and cmd[2] == "create":
30+
# Simulate successful repo creation without creating a real repo
31+
return sp.CompletedProcess(cmd, 0, stdout="Simulated repo created\n", stderr="")
32+
# Otherwise, call the real subprocess.run
33+
return real_run(*args, **kwargs)
34+
35+
with mock.patch("subprocess.run", side_effect=fake_run):
36+
yield

0 commit comments

Comments
 (0)