From 661a2997eeb875d8541c59965bb9bd1edefcd27b Mon Sep 17 00:00:00 2001 From: Emiliano Martinez Date: Thu, 13 Nov 2025 13:21:58 -0700 Subject: [PATCH 1/2] feat: Add comprehensive test suite and Phase 1 stabilization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Phase 1: Stabilization Complete ### Testing Infrastructure ✅ - Added pytest test suite with 43 tests (100% passing) - Achieved 85% code coverage - Tests for all 11 MCP tools: - Challenge management (11 tests) - Progress tracking (9 tests) - Spaced repetition reviews (11 tests) - AI analysis (12 tests) ### CI/CD Integration ✅ - Updated GitHub Actions workflow - Automated testing on push/PR - Coverage reporting with codecov - Docker build verification - Tests run before Docker build ### Documentation ✅ - Added CONTRIBUTING.md with: - Development setup guide - Testing guidelines - PR submission process - Coding standards - Project structure ### Improvements - Updated requirements.txt with test dependencies - Enhanced .gitignore for test artifacts - All tests use isolated temporary directories - Proper fixture management with conftest.py ## Test Results ``` 43 passed in 0.43s Coverage: 85% (268 statements, 39 missed) ``` ## Next Steps - Phase 1 remaining: Error handling improvements, logging - Phase 2: Advanced analytics, challenge templates - Phase 3: ML integration, knowledge graphs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/settings.local.json | 4 +- .github/workflows/docker-build.yml | 45 +++- .gitignore | 5 +- CONTRIBUTING.md | 388 +++++++++++++++++++++++++++++ requirements.txt | 6 +- tests/__init__.py | 1 + tests/conftest.py | 76 ++++++ tests/test_analysis.py | 179 +++++++++++++ tests/test_challenges.py | 197 +++++++++++++++ tests/test_progress.py | 156 ++++++++++++ tests/test_reviews.py | 213 ++++++++++++++++ 11 files changed, 1259 insertions(+), 11 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_analysis.py create mode 100644 tests/test_challenges.py create mode 100644 tests/test_progress.py create mode 100644 tests/test_reviews.py diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 27402aa..ec81452 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -3,7 +3,9 @@ "allow": [ "WebFetch(domain:code.claude.com)", "Bash(npx @anthropic-ai/mcp-builder:*)", - "Bash(npx @modelcontextprotocol/inspector:*)" + "Bash(npx @modelcontextprotocol/inspector:*)", + "Bash(python3:*)", + "Bash(git add:*)" ], "deny": [], "ask": [] diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 5815792..1f83e73 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,21 +1,52 @@ -name: Docker Build and Test +name: Test and Build on: push: - branches: [ main ] + branches: [ main, dev ] pull_request: - branches: [ main ] + branches: [ main, dev ] jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests with coverage + run: | + pytest tests/ -v --cov=learning_server --cov-report=term --cov-report=xml + + - name: Upload coverage reports + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + fail_ci_if_error: false + build: runs-on: ubuntu-latest - + needs: test + steps: - uses: actions/checkout@v3 - + - name: Build Docker image run: docker build -t obsidian-learning-extension:test . - + - name: Test Docker image run: | - docker run --rm obsidian-learning-extension:test python -c "import learning_server; print('Server imports successfully')" \ No newline at end of file + docker run --rm obsidian-learning-extension:test python -c "import learning_server; print('Server imports successfully')" + + - name: Test Docker image starts + run: | + timeout 10s docker run --rm obsidian-learning-extension:test python -c "print('Docker container works')" || true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 868f268..f51a125 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,7 @@ test_mcp_tools.py # Testing .pytest_cache/ .coverage -htmlcov/ \ No newline at end of file +coverage.xml +htmlcov/ +*.pyc +__pycache__/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ec117ca --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,388 @@ +# Contributing to Obsidian Learning Extension + +Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to the project. + +## Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [Getting Started](#getting-started) +- [Development Setup](#development-setup) +- [Making Changes](#making-changes) +- [Testing](#testing) +- [Submitting Changes](#submitting-changes) +- [Coding Standards](#coding-standards) +- [Project Structure](#project-structure) + +## Code of Conduct + +- Be respectful and inclusive +- Welcome newcomers and help them learn +- Focus on constructive feedback +- Respect different viewpoints and experiences +- Accept responsibility for mistakes + +## Getting Started + +1. **Fork the repository** + ```bash + # Click the 'Fork' button on GitHub + ``` + +2. **Clone your fork** + ```bash + git clone https://github.com/YOUR_USERNAME/obsidian-learning-extension.git + cd obsidian-learning-extension + ``` + +3. **Add upstream remote** + ```bash + git remote add upstream https://github.com/canoo/obsidian-learning-extension.git + ``` + +## Development Setup + +### Prerequisites + +- Python 3.11 or higher +- Docker and Docker Compose (optional, for containerized development) +- Git + +### Local Development + +1. **Create a virtual environment** + ```bash + python3 -m venv venv + source venv/bin/activate # On Windows: venv\Scripts\activate + ``` + +2. **Install dependencies** + ```bash + pip install -r requirements.txt + ``` + +3. **Run tests** + ```bash + pytest tests/ -v + ``` + +4. **Run server locally** + ```bash + python learning_server.py + ``` + +### Docker Development + +1. **Build the image** + ```bash + docker-compose build + ``` + +2. **Run the container** + ```bash + docker-compose up + ``` + +## Making Changes + +### Branch Strategy + +- `main` - Production-ready code +- `dev` - Development branch +- `feature/*` - New features +- `fix/*` - Bug fixes +- `docs/*` - Documentation updates + +### Workflow + +1. **Create a branch** + ```bash + git checkout -b feature/your-feature-name + ``` + +2. **Make your changes** + - Write code following our [coding standards](#coding-standards) + - Add tests for new functionality + - Update documentation as needed + +3. **Test your changes** + ```bash + pytest tests/ -v --cov=learning_server + ``` + +4. **Commit your changes** + ```bash + git add . + git commit -m "feat: add new feature" + ``` + +### Commit Message Convention + +We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: + +``` +(): + + + +