Skip to content

Commit 2253f93

Browse files
committed
Move to uv and add github actions
1 parent 2b89336 commit 2253f93

13 files changed

Lines changed: 1860 additions & 239 deletions

File tree

.github/workflows/api-ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: API CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'packages/api/**'
7+
- 'packages/core/**'
8+
- 'pyproject.toml'
9+
- 'uv.lock'
10+
- '.github/workflows/api-ci.yml'
11+
pull_request:
12+
paths:
13+
- 'packages/api/**'
14+
- 'packages/core/**'
15+
- 'pyproject.toml'
16+
- 'uv.lock'
17+
- '.github/workflows/api-ci.yml'
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v4
28+
29+
- name: Set up Python
30+
run: uv python install 3.11
31+
32+
- name: Install dependencies
33+
run: uv sync
34+
35+
- name: Lint
36+
run: |
37+
uv run black --check packages/api/
38+
uv run ruff check packages/api/
39+
uv run mypy packages/api/src/api
40+
41+
- name: Test
42+
run: uv run --package shelly-manager-api pytest packages/api/tests/ -v --cov=api
43+
44+
- name: Build Docker image
45+
run: docker build -f packages/api/Dockerfile -t shelly-manager-api:latest .
46+
47+
- name: Test Docker image
48+
run: |
49+
docker run --rm -d -p 8000:8000 --name test-api shelly-manager-api:latest
50+
sleep 10
51+
curl -f http://localhost:8000/health || echo "Health check endpoint may not exist yet"
52+
docker stop test-api

.github/workflows/cli-ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CLI CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'packages/cli/**'
7+
- 'packages/core/**'
8+
- 'pyproject.toml'
9+
- 'uv.lock'
10+
- '.github/workflows/cli-ci.yml'
11+
pull_request:
12+
paths:
13+
- 'packages/cli/**'
14+
- 'packages/core/**'
15+
- 'pyproject.toml'
16+
- 'uv.lock'
17+
- '.github/workflows/cli-ci.yml'
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v4
28+
29+
- name: Set up Python
30+
run: uv python install 3.11
31+
32+
- name: Install dependencies
33+
run: uv sync
34+
35+
- name: Lint
36+
run: |
37+
uv run black --check packages/cli/
38+
uv run ruff check packages/cli/
39+
uv run mypy packages/cli/src/cli
40+
41+
- name: Test
42+
run: uv run --package shelly-manager-cli pytest packages/cli/tests/ -v --cov=cli
43+
44+
- name: Build Docker image
45+
run: docker build -f packages/cli/Dockerfile -t shelly-manager-cli:latest .
46+
47+
- name: Test Docker image
48+
run: |
49+
docker run --rm shelly-manager-cli:latest --help

.github/workflows/core-ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Core CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'packages/core/**'
7+
- 'pyproject.toml'
8+
- 'uv.lock'
9+
- '.github/workflows/core-ci.yml'
10+
pull_request:
11+
paths:
12+
- 'packages/core/**'
13+
- 'pyproject.toml'
14+
- 'uv.lock'
15+
- '.github/workflows/core-ci.yml'
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- name: Set up Python
28+
run: uv python install 3.11
29+
30+
- name: Install dependencies
31+
run: uv sync
32+
33+
- name: Lint
34+
run: |
35+
uv run black --check packages/core/
36+
uv run ruff check packages/core/
37+
uv run mypy packages/core/src/core
38+
39+
- name: Test
40+
run: uv run --package shelly-manager-core pytest packages/core/tests/ -v --cov=core
41+
42+
- name: Build package
43+
run: uv build --package shelly-manager-core
44+
45+
- name: Upload core wheel
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: core-wheel
49+
path: dist/*.whl
50+
retention-days: 1

.github/workflows/web-ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Web CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'packages/web/**'
7+
- '.github/workflows/web-ci.yml'
8+
pull_request:
9+
paths:
10+
- 'packages/web/**'
11+
- '.github/workflows/web-ci.yml'
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: 'npm'
25+
cache-dependency-path: packages/web/package-lock.json
26+
27+
- name: Install dependencies
28+
working-directory: packages/web
29+
run: npm ci
30+
31+
- name: Lint
32+
working-directory: packages/web
33+
run: |
34+
npm run lint
35+
npm run format:check
36+
37+
- name: Type check
38+
working-directory: packages/web
39+
run: npx tsc --noEmit
40+
41+
- name: Build
42+
working-directory: packages/web
43+
run: npm run build
44+
45+
- name: Build Docker image
46+
run: docker build -f packages/web/Dockerfile -t shelly-manager-web:latest packages/web/
47+
48+
- name: Test Docker image
49+
run: |
50+
docker run --rm -d -p 80:80 --name test-web shelly-manager-web:latest
51+
sleep 5
52+
curl -f http://localhost/ || echo "Web server started successfully"
53+
docker stop test-web

DEVELOPMENT.md

Lines changed: 53 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,96 @@
22

33
## Quick Start
44

5-
1. **Install dependencies:**
6-
```bash
7-
# Install core package first (required by CLI and API)
8-
cd packages/core
9-
pip install -e .
10-
11-
# Install CLI package
12-
cd ../cli
13-
pip install -e .
5+
1. **Install uv:**
146

15-
# Install API package (optional)
16-
cd ../api
17-
pip install -e .
7+
```bash
8+
curl -LsSf https://astral.sh/uv/install.sh | sh
9+
# or
10+
pip install uv
1811
```
1912

20-
2. **Test the core package:**
13+
2. **Install dependencies:**
14+
2115
```bash
22-
cd packages/core
23-
python -c "from core.domain.entities.shelly_device import ShellyDevice; print('Core package working!')"
16+
# Install all workspace packages with dev dependencies
17+
uv sync --extra dev
2418
```
2519

26-
3. **Test CLI and API:**
20+
3. **Test packages:**
21+
2722
```bash
28-
# CLI
29-
cd packages/cli && python -m cli --help
23+
# Test everything
24+
make test
3025

31-
# API
32-
cd packages/api && python -m api
26+
# Test specific packages
27+
make test-core
28+
make test-api
29+
make test-cli
3330
```
3431

3532
## Development Installation
3633

37-
### Local Package Dependencies
38-
Since the core package is not published to PyPI, install packages in this order:
34+
### Workspace Setup
35+
36+
The project uses uv workspace dependencies for consistent version management:
3937

4038
```bash
41-
# 1. Install core package first (required by CLI and API)
42-
cd packages/core
43-
pip install -e .
39+
# Install everything
40+
uv sync --extra dev
4441

45-
# 2. Install CLI package
46-
cd ../cli
47-
pip install -e .
42+
# Install without dev dependencies
43+
uv sync --no-dev
4844

49-
# 3. Install API package (optional)
50-
cd ../api
51-
pip install -e .
45+
# Install specific package
46+
uv sync --package shelly-manager-core
5247
```
5348

54-
### Virtual Environment Setup (Recommended)
49+
### Running Applications
50+
5551
```bash
56-
# For CLI development
57-
cd packages/cli
58-
python -m venv venv
59-
source venv/bin/activate
60-
pip install -e ../core
61-
pip install -e ".[dev]"
62-
63-
# For API development
64-
cd packages/api
65-
python -m venv venv
66-
source venv/bin/activate
67-
pip install -e ../core
68-
pip install -e ".[dev]"
52+
# CLI
53+
uv run shelly-manager --help
54+
55+
# API server
56+
uv run --package shelly-manager-api python -m api.main
6957
```
7058

7159
## Development Workflow
7260

7361
### Code formatting and linting
74-
```bash
75-
# Format code with black
76-
black .
7762

78-
# Check with ruff
79-
ruff check .
63+
```bash
64+
# Format code
65+
make format
8066

81-
# Type checking
82-
mypy .
67+
# Check linting
68+
make lint
8369
```
8470

8571
### Testing
72+
8673
```bash
8774
# Run all tests
88-
pytest
75+
make test
8976

9077
# Run with coverage
91-
pytest --cov=core --cov=app
78+
make test-coverage
9279

93-
# Run specific test types
94-
pytest tests/unit/
95-
pytest tests/integration/
80+
# Run specific package tests
81+
uv run --package shelly-manager-core pytest packages/core/tests/
9682
```
9783

9884
### Running the Application
85+
9986
```bash
100-
# Core functionality (verified working)
101-
cd packages/core
102-
python -c "from core.settings import settings; print(f'✅ Settings: {settings.api.host}:{settings.api.port}')"
103-
104-
# CLI usage (may require additional setup)
105-
cd packages/cli
106-
python -m cli scan 192.168.1.0/24
107-
python -m cli status 192.168.1.100
108-
python -m cli update 192.168.1.100
109-
110-
# API server (may require additional setup)
111-
cd packages/api
112-
python -m api.run_server
87+
# Core functionality
88+
uv run --package shelly-manager-core python -c "from core.domain.entities.shelly_device import ShellyDevice; print('✅ Core package working!')"
89+
90+
# CLI usage
91+
uv run shelly-manager scan --help
92+
uv run shelly-manager device status --help
93+
94+
# API server
95+
uv run --package shelly-manager-api python -m api.main
11396
# Then visit http://localhost:8000/docs
11497
```
115-
116-
> **Note**: CLI and API packages may need additional dependency resolution.
117-
> All core business logic and domain functionality is working correctly.

0 commit comments

Comments
 (0)