Skip to content
Closed
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
66 changes: 58 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,84 @@ on:
branches: [ main ]

jobs:
lint-and-test:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: make install

- name: Run linting
run: make lint

- name: Run tests with coverage
run: make coverage
test-servicekit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: make install

- name: Test servicekit
run: make test-servicekit

- name: Upload servicekit coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: servicekit
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

test-chapkit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: make install

- name: Test chapkit
run: make test-chapkit

- name: Upload coverage to Codecov
- name: Upload chapkit coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: chapkit
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
101 changes: 40 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help install lint test coverage clean docker-build docker-run docs docs-serve docs-build
.PHONY: help install lint lint-servicekit lint-chapkit test test-servicekit test-chapkit coverage clean

# ==============================================================================
# Venv
Expand All @@ -15,87 +15,66 @@ PYTHON := $(VENV_DIR)/bin/python
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " install Install dependencies"
@echo " lint Run linter and type checker"
@echo " test Run tests"
@echo " coverage Run tests with coverage reporting"
@echo " migrate Generate a new migration (use MSG='description')"
@echo " upgrade Apply pending migrations"
@echo " downgrade Revert last migration"
@echo " docs-serve Serve documentation locally with live reload"
@echo " docs-build Build documentation site"
@echo " docs Alias for docs-serve"
@echo " docker-build Build Docker image for examples"
@echo " docker-run Run example in Docker (use EXAMPLE='config_api')"
@echo " clean Clean up temporary files"
@echo "Monorepo Targets:"
@echo " install Install all dependencies"
@echo " lint Run linter and type checker on all packages"
@echo " lint-servicekit Lint servicekit only"
@echo " lint-chapkit Lint chapkit only"
@echo " test Run all tests"
@echo " test-servicekit Test servicekit only"
@echo " test-chapkit Test chapkit only"
@echo " coverage Run tests with coverage reporting"
@echo " clean Clean up temporary files"

install:
@echo ">>> Installing dependencies"
@$(UV) sync --all-extras
@echo ">>> Installing workspace dependencies"
@$(UV) sync --all-packages

lint:
@echo ">>> Running linter"
@echo ">>> Running linter on all packages"
@$(UV) run ruff format .
@$(UV) run ruff check . --fix
@echo ">>> Running type checker"
@$(UV) run mypy --exclude 'examples/old' src tests examples alembic
@echo ">>> Running type checkers"
@$(UV) run mypy packages/servicekit/src packages/chapkit/src
@$(UV) run pyright

lint-servicekit:
@echo ">>> Linting servicekit"
@$(UV) run ruff format packages/servicekit
@$(UV) run ruff check packages/servicekit --fix
@$(UV) run mypy packages/servicekit/src

lint-chapkit:
@echo ">>> Linting chapkit"
@$(UV) run ruff format packages/chapkit
@$(UV) run ruff check packages/chapkit --fix
@$(UV) run mypy packages/chapkit/src

test:
@echo ">>> Running tests"
@$(UV) run pytest -q
@echo ">>> Running all tests"
@$(UV) run pytest packages/servicekit/tests packages/chapkit/tests -q --ignore=packages/servicekit/tests/test_example_*.py

test-servicekit:
@echo ">>> Testing servicekit"
@$(UV) run pytest packages/servicekit/tests -q --ignore=packages/servicekit/tests/test_example_artifact_api.py --ignore=packages/servicekit/tests/test_example_config_api.py --ignore=packages/servicekit/tests/test_example_config_artifact_api.py --ignore=packages/servicekit/tests/test_example_core_api.py --ignore=packages/servicekit/tests/test_example_core_cli.py --ignore=packages/servicekit/tests/test_example_custom_operations_api.py --ignore=packages/servicekit/tests/test_example_full_featured_api.py --ignore=packages/servicekit/tests/test_example_job_scheduler_api.py --ignore=packages/servicekit/tests/test_example_job_scheduler_sse_api.py --ignore=packages/servicekit/tests/test_example_library_usage_api.py --ignore=packages/servicekit/tests/test_example_monitoring_api.py --ignore=packages/servicekit/tests/test_example_task_execution_api.py

test-chapkit:
@echo ">>> Testing chapkit"
@$(UV) run pytest packages/chapkit/tests -q

coverage:
@echo ">>> Running tests with coverage"
@$(UV) run coverage run -m pytest -q
@$(UV) run coverage run -m pytest packages/servicekit/tests packages/chapkit/tests -q
@$(UV) run coverage report
@$(UV) run coverage xml

migrate:
@echo ">>> Generating migration: $(MSG)"
@$(UV) run alembic revision --autogenerate -m "$(MSG)"
@echo ">>> Formatting migration file"
@$(UV) run ruff format alembic/versions

upgrade:
@echo ">>> Applying pending migrations"
@$(UV) run alembic upgrade head

downgrade:
@echo ">>> Reverting last migration"
@$(UV) run alembic downgrade -1

docs-serve:
@echo ">>> Serving documentation at http://127.0.0.1:8000"
@$(UV) run mkdocs serve

docs-build:
@echo ">>> Building documentation site"
@$(UV) run mkdocs build

docs: docs-serve

docker-build:
@echo ">>> Building Docker image"
@docker build -t chapkit-examples .

docker-run:
@echo ">>> Running Docker container with example: $(EXAMPLE)"
@if [ -z "$(EXAMPLE)" ]; then \
echo "Error: EXAMPLE not specified. Usage: make docker-run EXAMPLE=config_api"; \
exit 1; \
fi
@docker run -it --rm -p 8000:8000 \
-e EXAMPLE_MODULE=examples.$(EXAMPLE):app \
chapkit-examples

clean:
@echo ">>> Cleaning up"
@find . -type f -name "*.pyc" -delete
@find . -type d -name "__pycache__" -delete
@find . -type d -name ".pytest_cache" -delete
@find . -type d -name ".ruff_cache" -delete
@find . -type d -name ".mypy_cache" -delete

# ==============================================================================
# Default
Expand Down
Loading
Loading