Spaces:
Running
Running
| version: '3' | |
| vars: | |
| REGISTRY: '{{.REGISTRY | default "ghcr.io"}}' | |
| IMAGE_NAME: '{{.IMAGE_NAME | default "hf-builder"}}' | |
| tasks: | |
| default: | |
| desc: Show available tasks | |
| cmds: | |
| - task --list | |
| # Development | |
| dev: | |
| desc: Run builder locally for development | |
| env: | |
| FLASK_DEBUG: "1" | |
| LOG_FORMAT: text | |
| cmds: | |
| - python app.py | |
| dev:watch: | |
| desc: Run with auto-reload on file changes | |
| deps: [check:deps] | |
| cmds: | |
| - watchmedo auto-restart --patterns="*.py" --recursive -- python app.py | |
| # Testing | |
| test: | |
| desc: Run all tests | |
| cmds: | |
| - pytest tests/ -v | |
| test:unit: | |
| desc: Run unit tests only | |
| cmds: | |
| - pytest tests/unit/ -v | |
| test:integration: | |
| desc: Run integration tests (requires Docker) | |
| cmds: | |
| - pytest tests/integration/ -v | |
| lint: | |
| desc: Run linting | |
| cmds: | |
| - ruff check . | |
| - ruff format --check . | |
| lint:fix: | |
| desc: Fix linting issues | |
| cmds: | |
| - ruff check --fix . | |
| - ruff format . | |
| # Docker | |
| docker:build: | |
| desc: Build Docker image locally | |
| cmds: | |
| - docker build -t {{.IMAGE_NAME}}:local . | |
| docker:run: | |
| desc: Run Docker image locally | |
| deps: [docker:build] | |
| env: | |
| REGISTRY_URL: '{{.REGISTRY}}' | |
| cmds: | |
| - | | |
| docker run --rm -it \ | |
| -p 7860:7860 \ | |
| -e REGISTRY_URL=$REGISTRY_URL \ | |
| -e REGISTRY_USER=$REGISTRY_USER \ | |
| -e REGISTRY_PASSWORD=$REGISTRY_PASSWORD \ | |
| {{.IMAGE_NAME}}:local | |
| # Deployment | |
| deploy:hf: | |
| desc: Deploy to HuggingFace Space | |
| vars: | |
| SPACE: '{{.SPACE | default "drengskapur/hf-builder"}}' | |
| cmds: | |
| - echo "Deploying to {{.SPACE}}..." | |
| - git push hf main | |
| # Hivemind Integration | |
| hivemind:register: | |
| desc: Register this builder with hivemind controller | |
| vars: | |
| CONTROLLER_URL: '{{.CONTROLLER_URL | default "http://localhost:7860"}}' | |
| BUILDER_ID: '{{.BUILDER_ID | default "builder-1"}}' | |
| cmds: | |
| - | | |
| curl -X POST {{.CONTROLLER_URL}}/api/register \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"worker_id": "{{.BUILDER_ID}}", "name": "Builder {{.BUILDER_ID}}", "capabilities": ["build"]}' | |
| hivemind:heartbeat: | |
| desc: Send heartbeat to hivemind controller | |
| vars: | |
| CONTROLLER_URL: '{{.CONTROLLER_URL | default "http://localhost:7860"}}' | |
| BUILDER_ID: '{{.BUILDER_ID | default "builder-1"}}' | |
| cmds: | |
| - | | |
| curl -X POST {{.CONTROLLER_URL}}/api/heartbeat \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"worker_id": "{{.BUILDER_ID}}", "status": "idle"}' | |
| # Health checks | |
| health: | |
| desc: Check builder health | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| cmds: | |
| - curl -s {{.URL}}/health | jq . | |
| status: | |
| desc: Get builder status | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| cmds: | |
| - curl -s {{.URL}}/api/status | jq . | |
| metrics: | |
| desc: Get Prometheus metrics | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| cmds: | |
| - curl -s {{.URL}}/api/metrics | |
| history: | |
| desc: Get build history | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| cmds: | |
| - curl -s {{.URL}}/api/history | jq . | |
| logs: | |
| desc: Get recent logs | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| cmds: | |
| - curl -s {{.URL}}/api/logs | jq -r '.logs[]' | |
| # Build triggers | |
| build: | |
| desc: Trigger a build via API | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| requires: | |
| vars: [REPO_URL, IMAGE] | |
| cmds: | |
| - | | |
| curl -X POST {{.URL}}/api/build \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "repo_url": "{{.REPO_URL}}", | |
| "image_name": "{{.IMAGE}}", | |
| "branch": "{{.BRANCH | default "main"}}", | |
| "tags": ["{{.TAG | default "latest"}}"] | |
| }' | |
| build:cancel: | |
| desc: Cancel a running build | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| requires: | |
| vars: [BUILD_ID] | |
| cmds: | |
| - curl -X POST {{.URL}}/api/build/{{.BUILD_ID}}/cancel | |
| # Webhook testing | |
| webhook:test: | |
| desc: Send a test webhook | |
| vars: | |
| URL: '{{.URL | default "http://localhost:7860"}}' | |
| requires: | |
| vars: [REPO_URL, IMAGE] | |
| cmds: | |
| - | | |
| curl -X POST {{.URL}}/webhook/test \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "repo_url": "{{.REPO_URL}}", | |
| "image_name": "{{.IMAGE}}", | |
| "branch": "{{.BRANCH | default "main"}}" | |
| }' | |
| # Dependency management | |
| deps: | |
| desc: Install dependencies | |
| cmds: | |
| - pip install -r requirements.txt | |
| deps:dev: | |
| desc: Install dev dependencies | |
| cmds: | |
| - pip install -r requirements.txt pytest ruff watchdog | |
| check:deps: | |
| desc: Check if dependencies are installed | |
| cmds: | |
| - python -c "import flask; import git; import requests" | |
| silent: true | |
| # Cleanup | |
| clean: | |
| desc: Clean up temporary files | |
| cmds: | |
| - rm -rf __pycache__ .pytest_cache .ruff_cache | |
| - find . -name "*.pyc" -delete | |