Skip to content
Merged

Dev #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Dependabot configuration for automated dependency updates
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates

version: 2
updates:
# Python dependencies (pip)
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 5
commit-message:
prefix: "deps"
labels:
- "dependencies"
- "python"
# Group minor/patch updates to reduce PR noise
groups:
python-minor:
patterns:
- "*"
update-types:
- "minor"
- "patch"

# GitHub Actions
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 3
commit-message:
prefix: "ci"
labels:
- "dependencies"
- "github-actions"
groups:
actions:
patterns:
- "*"
51 changes: 48 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
branches: [releases]

env:
# Shared pip cache key prefix
PIP_CACHE_KEY: pip-v1

jobs:
lint:
name: Lint
Expand All @@ -18,6 +22,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-paths: pyproject.toml

- name: Install linting tools
run: pip install black flake8
Expand All @@ -43,6 +49,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-paths: pyproject.toml

- name: Install dependencies
run: |
Expand All @@ -52,7 +60,7 @@ jobs:
pip install -e .

- name: Run microfinity tests
run: pytest tests/ --ignore=tests/test_meshcutter -v
run: pytest microfinity/tests/ tests/ -v

test-meshcutter-unit:
name: Test meshcutter unit (Python ${{ matrix.python-version }})
Expand All @@ -69,6 +77,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-paths: pyproject.toml

- name: Install dependencies
run: |
Expand All @@ -79,7 +89,7 @@ jobs:
pip install -e .

- name: Run meshcutter unit tests
run: pytest tests/test_meshcutter -m "not integration" -v
run: pytest meshcutter/tests/ -m "not integration" -v

test-meshcutter-integration:
name: Test meshcutter integration
Expand All @@ -92,6 +102,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-paths: pyproject.toml

- name: Install dependencies
run: |
Expand All @@ -101,8 +113,39 @@ jobs:
pip install pytest
pip install -e .

- name: Create artifact directory
run: mkdir -p test-artifacts

- name: Run meshcutter integration tests
run: pytest tests/test_meshcutter -m "integration" -v
id: integration-tests
run: |
pytest meshcutter/tests/ -m "integration" -v \
--tb=short \
--basetemp=test-artifacts/tmp
continue-on-error: true

- name: Collect test artifacts on failure
if: steps.integration-tests.outcome == 'failure'
run: |
# Collect any STL files generated during tests
find test-artifacts -name "*.stl" -o -name "*.3mf" 2>/dev/null | head -20 || true
# Also check /tmp for any test outputs
find /tmp -maxdepth 2 -name "*.stl" -newer /tmp -mmin -5 2>/dev/null | head -10 || true

- name: Upload test artifacts
if: steps.integration-tests.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: failed-test-artifacts
path: |
test-artifacts/
/tmp/*.stl
if-no-files-found: ignore
retention-days: 7

- name: Fail if tests failed
if: steps.integration-tests.outcome == 'failure'
run: exit 1

build:
name: Build Package
Expand All @@ -114,6 +157,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-paths: pyproject.toml

- name: Install build tools
run: pip install build twine
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ htmlcov/

# OS
.DS_Store
.claude/
Desktop.ini
._*
Thumbs.db
Expand Down
127 changes: 87 additions & 40 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,65 @@ This file provides context for Claude when working on this project.
1. **microfinity/** - CadQuery-based generator for boxes, baseplates, and spacers
2. **meshcutter/** - Mesh-based tool to convert 1U Gridfinity boxes to micro-divided feet

## Package Structure

### microfinity/
```
microfinity/
├── __init__.py # Package exports and version
├── py.typed # PEP 561 marker
├── cli/ # CLI commands
│ ├── main.py # Unified CLI entry point
│ └── debug.py # Debug subcommands
├── spec/ # Gridfinity specifications
│ ├── loader.py # YAML spec loading
│ └── constants.py # Derived constants
├── cq/ # CadQuery utilities (shared)
│ ├── compat.py # ZLEN_FIX version detection
│ ├── extrude.py # extrude_profile()
│ ├── helpers.py # Geometry helpers
│ └── export.py # STEP/STL/SVG export
├── parts/ # Gridfinity objects
│ ├── base.py # GridfinityObject base class
│ ├── box.py # GridfinityBox
│ ├── baseplate.py # GridfinityBaseplate
│ ├── baseplate_layout.py
│ └── drawer.py # GridfinityDrawerSpacer
├── calibration/ # Calibration prints
│ └── test_prints.py
└── tests/ # Package tests
```

### meshcutter/
```
meshcutter/
├── __init__.py # Package exports
├── py.typed # PEP 561 marker
├── constants.py # Re-exports + meshcutter-specific
├── cli/ # CLI commands
│ └── meshcut.py
├── pipeline/ # Main conversion pipelines
│ └── replace_base.py
├── cutter/ # Cutter geometry generation
│ ├── base.py # generate_cutter()
│ ├── cq.py # CadQuery cutter generation
│ ├── foot.py # Micro-foot generation
│ └── grid.py # Grid/offset calculations
├── detection/ # Mesh analysis
│ ├── footprint.py # Bottom frame detection
│ └── validation.py # Geometry validation
├── mesh/ # Mesh operations
│ ├── convert.py # Trimesh/Manifold conversions
│ ├── boolean.py # Boolean operations
│ ├── geometry.py # 2D geometry helpers
│ ├── grid.py # Grid mask generation
│ └── profile.py # Profile constants
├── io/ # File I/O
│ ├── loader.py
│ └── exporter.py
└── tests/ # Package tests
```

## Key Architecture Decisions

### Meshcutter: Replace-Base Approach
Expand All @@ -21,11 +80,10 @@ The meshcutter uses a **replace-base pipeline** (not boolean subtraction) to con

This produces geometry **identical** to natively-generated micro boxes (<1mm³ difference).

**Important**: The legacy boolean subtraction approach has been deprecated and removed.

### Gridfinity Constants

All Gridfinity constants should come from `meshcutter/core/constants.py`, which re-exports from `microfinity.core.constants`.
All Gridfinity constants should come from `microfinity.spec.constants`, which loads from YAML specs.
Meshcutter re-exports these via `meshcutter.constants`.

Key values:
- `GRU = 42.0` - 1U pitch (mm)
Expand All @@ -34,52 +92,41 @@ Key values:
- `GR_BASE_CLR = 0.25` - Clearance above foot
- `Z_SPLIT_HEIGHT = 5.0` - Where we cut between top and base

## Important Files
### Shared CadQuery Utilities

### Core Modules
- `meshcutter/core/replace_base.py` - Main replace-base pipeline
- `meshcutter/core/constants.py` - Centralized constants
- `meshcutter/core/mesh_utils.py` - Mesh conversion utilities
- `meshcutter/core/cq_utils.py` - CadQuery utilities
- `meshcutter/core/grid_utils.py` - Grid/offset calculations
All CadQuery utilities live in `microfinity.cq/`:
- `ZLEN_FIX` detection - single source of truth
- `extrude_profile()` - shared by both packages
- Export utilities (STEP/STL/SVG)

### CLI
- `meshcutter/cli/meshcut.py` - Command-line interface
Meshcutter imports from `microfinity.cq` instead of duplicating.

## Testing

### Tests
- `tests/test_meshcutter/test_golden.py` - Golden comparison tests
- `tests/test_meshcutter/golden_utils.py` - Test utilities
### Running Tests
```bash
# All tests
pytest -v

## Refactoring Tracking
# Microfinity tests only
pytest microfinity/tests/ -v

**IMPORTANT**: When completing refactoring tasks, update `REFACTOR_TODO.md` to mark items as complete.
# Meshcutter tests only
pytest meshcutter/tests/ -v

The refactoring TODO file tracks:
- DRY elimination (utility modules)
- Module updates
- Test creation
- CI setup
# Shared/integration tests
pytest tests/ -v

## Testing
# Skip slow golden tests
pytest -v -m "not golden"
```

### Golden Tests
Golden tests compare meshcutter output against microfinity-generated references:
- Reference meshes are generated on-demand (not stored)
- Acceptance threshold: <1mm³ total geometric difference
- Test configurations: 1x1x1, 2x3x2, 1x1x3, 3x3x1

### Running Tests
```bash
# All meshcutter tests
pytest tests/test_meshcutter/ -v

# Just golden tests
pytest tests/test_meshcutter/test_golden.py -v

# Quick unit tests (skip slow golden tests)
pytest tests/test_meshcutter/ -v -m "not golden"
```

## Code Style

- **Line length**: 120 characters (configured in pyproject.toml)
Expand All @@ -90,16 +137,16 @@ pytest tests/test_meshcutter/ -v -m "not golden"
## Common Tasks

### Adding a New Micro-Division Size
1. Update `meshcutter/core/grid_utils.py` if offset calculations change
2. Add test configuration to `tests/test_meshcutter/test_golden.py`
1. Update `meshcutter/cutter/grid.py` if offset calculations change
2. Add test configuration to `meshcutter/tests/test_golden.py`
3. Update `docs/TODO_FUTURE_DIVISIONS.md`

### Updating Constants
1. Check if constant exists in `microfinity.core.constants`
2. If yes, re-export in `meshcutter/core/constants.py`
1. Check if constant exists in `microfinity.spec.constants`
2. If yes, re-export in `meshcutter/constants.py`
3. If no, add to meshcutter-specific section

### Debugging Mesh Issues
1. Use `mesh_utils.get_mesh_diagnostics()` for mesh info
1. Use `meshcutter.mesh.convert.get_mesh_diagnostics()` for mesh info
2. Export intermediate meshes with `mesh.export('/tmp/debug.stl')`
3. View in external tool (MeshLab, Blender)
Loading
Loading