Skip to content

Commit b361eb0

Browse files
committed
ran precommit
1 parent c1048f7 commit b361eb0

29 files changed

+1215
-728
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.13'
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
26+
- name: Install dependencies
27+
run: uv sync
28+
29+
- name: Run tests
30+
run: uv run pytest tests/ -v --cov --cov-report=term-missing
31+
32+
- name: Check test count
33+
run: |
34+
TEST_COUNT=$(uv run pytest tests/ --collect-only -q | grep -c "test_")
35+
echo "Found $TEST_COUNT tests"
36+
if [ "$TEST_COUNT" -ne 7 ]; then
37+
echo "Expected 7 tests, found $TEST_COUNT"
38+
exit 1
39+
fi

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ cython_debug/
182182
.abstra/
183183

184184
# Visual Studio Code
185-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
185+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186186
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
187+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188188
# you could uncomment the following to ignore the entire vscode folder
189189
# .vscode/
190190

.pre-commit-config.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Pre-commit hooks for code quality (minimal setup for personal project)
2+
# Install: uv run pre-commit install
3+
# Run manually: uv run pre-commit run --all-files
4+
#
5+
# Using pre-commit.ci for automatic PR fixes and weekly updates
6+
# See: https://pre-commit.ci
7+
8+
ci:
9+
autofix_commit_msg: |
10+
[pre-commit.ci] auto fixes from hooks
11+
12+
for more info, see https://pre-commit.ci
13+
autofix_prs: true
14+
autoupdate_schedule: weekly
15+
skip: [pytest] # Skip pytest in CI (runs in GitHub Actions instead)
16+
17+
repos:
18+
# Ruff - Fast Python linter and formatter
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.8.4
21+
hooks:
22+
# Run the linter with auto-fix
23+
- id: ruff
24+
args: [--fix, --exit-non-zero-on-fix]
25+
# Run the formatter
26+
- id: ruff-format
27+
28+
# Basic file checks (auto-fix)
29+
- repo: https://github.com/pre-commit/pre-commit-hooks
30+
rev: v5.0.0
31+
hooks:
32+
- id: trailing-whitespace
33+
- id: end-of-file-fixer
34+
- id: check-yaml
35+
- id: check-added-large-files
36+
args: ['--maxkb=1000']
37+
- id: check-merge-conflict
38+
- id: mixed-line-ending
39+
40+
# Run tests before commit (local only, skipped in pre-commit.ci)
41+
- repo: local
42+
hooks:
43+
- id: pytest
44+
name: pytest
45+
entry: uv run pytest tests/ -v
46+
language: system
47+
pass_filenames: false
48+
always_run: true

CONTRIBUTING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing
2+
3+
This is a personal project, but if you'd like to contribute, here's how to set up the development environment.
4+
5+
## Development Setup
6+
7+
```bash
8+
# Clone the repository
9+
git clone https://github.com/madebygps/second-brain.git
10+
cd second-brain
11+
12+
# Install dependencies with uv
13+
uv sync
14+
15+
# Install pre-commit hooks
16+
uv run pre-commit install
17+
18+
# Configure your environment
19+
cp .env.example .env
20+
# Edit .env with your paths and Azure credentials
21+
```
22+
23+
## Making Changes
24+
25+
1. **Create a branch** for your changes
26+
```bash
27+
git checkout -b feature/your-feature-name
28+
```
29+
30+
2. **Make your changes** - The pre-commit hooks will automatically:
31+
- Lint code with ruff (auto-fixes issues)
32+
- Format code with ruff-format
33+
- Run the 7 essential tests
34+
- Check file endings and whitespace
35+
36+
3. **Run tests manually** if needed:
37+
```bash
38+
uv run pytest tests/ -v
39+
uv run pytest tests/ --cov # with coverage
40+
```
41+
42+
4. **Commit your changes** - Pre-commit hooks will run automatically:
43+
```bash
44+
git add .
45+
git commit -m "Your descriptive commit message"
46+
```
47+
48+
5. **Push and create a PR**:
49+
```bash
50+
git push origin feature/your-feature-name
51+
```
52+
53+
6. **pre-commit.ci will automatically**:
54+
- Run checks on your PR
55+
- Auto-fix any formatting/linting issues
56+
- Push fixes to your PR branch
57+
58+
## Testing Philosophy
59+
60+
This is a **personal project** with minimal tests focused on preventing data loss:
61+
62+
- ✅ Configuration validation (missing paths)
63+
- ✅ File naming (reflection vs. plan entries)
64+
- ✅ Write/read cycles (data persistence)
65+
- ✅ Path separation (diary vs. planner)
66+
67+
We don't test:
68+
- ❌ LLM responses (too variable)
69+
- ❌ CLI output formatting (not critical)
70+
- ❌ Template generation (easily tested manually)
71+
- ❌ Search functionality (depends on external Azure service)
72+
73+
## Code Style
74+
75+
- **Formatting**: Handled automatically by `ruff-format` (100 char line length)
76+
- **Type hints**: Use Python 3.13+ type hints on all functions
77+
- **Naming**: Clear, descriptive names (no abbreviations unless obvious)
78+
- **Comments**: Docstrings on all public functions
79+
80+
## CI/CD
81+
82+
**GitHub Actions** runs on push/PR:
83+
- Runs all 7 tests with coverage
84+
- Validates test count (ensures tests aren't accidentally deleted)
85+
- Checks Python 3.13 compatibility
86+
87+
**[pre-commit.ci](https://pre-commit.ci)** (free for open source):
88+
- Auto-fixes PRs (formatting, imports, whitespace)
89+
- Weekly dependency updates via automated PRs
90+
- Faster than GitHub Actions for simple checks
91+
- Comment `pre-commit.ci run` to re-trigger
92+
- Skip with `[skip pre-commit.ci]` in commit message
93+
94+
## Package Management
95+
96+
**ALWAYS use `uv`, never `pip`**:
97+
98+
```bash
99+
# Add a dependency
100+
uv add package-name
101+
102+
# Add a dev dependency
103+
uv add --dev package-name
104+
105+
# Update dependencies
106+
uv sync
107+
108+
# Remove a dependency
109+
uv remove package-name
110+
```
111+
112+
## Questions?
113+
114+
Open an issue or reach out to [@madebygps](https://github.com/madebygps).

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Second Brain
22

3+
[![Tests](https://github.com/madebygps/second-brain/actions/workflows/test.yml/badge.svg)](https://github.com/madebygps/second-brain/actions/workflows/test.yml)
4+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/madebygps/second-brain/main.svg)](https://results.pre-commit.ci/latest/github/madebygps/second-brain/main)
5+
36
AI-powered personal knowledge system with daily planning, reflective journaling, semantic backlinks, and intelligent book notes search.
47

58
## Features
@@ -30,6 +33,9 @@ AI-powered personal knowledge system with daily planning, reflective journaling,
3033
# Install dependencies
3134
uv sync
3235

36+
# Set up pre-commit hooks (optional but recommended)
37+
uv run pre-commit install
38+
3339
# Configure
3440
cp .env.example .env
3541
# Edit .env with your paths and Azure credentials
@@ -166,7 +172,9 @@ After writing, run `brain diary link today` to add semantic backlinks:
166172
- Analysis reports and patterns
167173
- **Azure AI Search** - Required for book notes search functionality only
168174

169-
## Testing
175+
## Development
176+
177+
### Testing
170178

171179
Minimal test suite focused on preventing data loss:
172180

@@ -181,6 +189,41 @@ uv run pytest --cov # Run with coverage
181189
- Write/read cycles (prevent data loss)
182190
- Path separation (diary vs. planner)
183191

192+
### Code Quality
193+
194+
Pre-commit hooks automatically run before each commit:
195+
196+
```bash
197+
# Install hooks (one-time setup)
198+
uv run pre-commit install
199+
200+
# Run manually on all files
201+
uv run pre-commit run --all-files
202+
```
203+
204+
**Hooks include:**
205+
- `ruff` - Fast Python linter with auto-fix
206+
- `ruff-format` - Auto-format Python code
207+
- `pytest` - Run test suite (prevents data loss bugs)
208+
- File checks (trailing whitespace, file endings, large files)
209+
210+
**[pre-commit.ci](https://pre-commit.ci) integration:**
211+
- ✅ Automatically fixes PRs (formatting, imports, etc.)
212+
- ✅ Weekly dependency updates
213+
- ✅ Zero configuration needed
214+
215+
### CI/CD
216+
217+
**GitHub Actions** runs on push/PR:
218+
- ✅ Tests with coverage reporting
219+
- ✅ Test count validation (ensures 7 tests)
220+
- ✅ Python 3.13 compatibility check
221+
222+
**[pre-commit.ci](https://pre-commit.ci)** runs on PRs:
223+
- ✅ Auto-fixes formatting and linting issues
224+
- ✅ Weekly dependency updates (automated PRs)
225+
- ✅ Faster than GitHub Actions for simple checks
226+
184227
## License
185228

186229
MIT

0 commit comments

Comments
 (0)