Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
8.21 kB

Milestone 7: CI/CD Integration

Status: In Progress Started: 2025-12-21

Overview

Milestone 7 implements decentralized CI/CD pipelines, enabling automated build, test, and deployment workflows. This completes the developer workflow experience by allowing repositories to define and execute continuous integration pipelines that run across the Guts network.

Goals

  1. Workflow Configuration: YAML-based pipeline definitions (.guts/workflows/*.yml)
  2. Job Execution: Isolated job execution with step-by-step processing
  3. Status Checks: Integration with branch protection and PR workflows
  4. Artifact Management: Store and retrieve build artifacts
  5. Real-time Logs: Stream build logs to connected clients
  6. Distributed Execution: Jobs can be executed by any node in the network

New Crate: guts-ci

Technology Choices

Component Technology Rationale
Config Format YAML (serde_yaml) Standard CI/CD config format
Isolation Tokio subprocess Process isolation for commands
Storage Content-addressed Artifacts stored by hash
Streaming Channel + WebSocket Real-time log streaming

Workflow Configuration

Configuration files are stored in .guts/workflows/*.yml:

Core Types

Workflow

Job Definition

Workflow Run

Job Run

Artifacts

Status Checks

Data Flow

Phase 1: Core Types & Storage

  1. Create guts-ci crate structure
  2. Define core types (Workflow, Job, Step, Run)
  3. Implement YAML workflow parsing
  4. Create workflow storage
  5. Add validation for workflow configurations

Phase 2: Workflow Runs

  1. Implement WorkflowRun tracking
  2. Create trigger matching logic
  3. Implement job dependency resolution
  4. Add run status management
  5. Create run storage and retrieval

Phase 3: Job Execution

  1. Implement step executor
  2. Add environment variable handling
  3. Create log capture and streaming
  4. Implement timeout handling
  5. Add artifact upload/download

Phase 4: Status Checks Integration

  1. Create StatusCheck type
  2. Integrate with guts-auth branch protection
  3. Auto-create checks on workflow trigger
  4. Update checks on job completion
  5. Block PR merge on failed required checks

Phase 5: API Endpoints

  1. GET/POST /api/repos/{owner}/{name}/workflows
  2. GET /api/repos/{owner}/{name}/workflows/{workflow_id}
  3. GET/POST /api/repos/{owner}/{name}/runs
  4. GET /api/repos/{owner}/{name}/runs/{run_id}
  5. POST /api/repos/{owner}/{name}/runs/{run_id}/cancel
  6. GET /api/repos/{owner}/{name}/runs/{run_id}/jobs
  7. GET /api/repos/{owner}/{name}/runs/{run_id}/jobs/{job_id}/logs
  8. GET/POST /api/repos/{owner}/{name}/artifacts
  9. GET /api/repos/{owner}/{name}/commits/{sha}/status
  10. POST /api/repos/{owner}/{name}/commits/{sha}/statuses

Phase 6: Web UI

  1. Workflow list page (/{owner}/{repo}/actions)
  2. Workflow detail page (/{owner}/{repo}/actions/{workflow})
  3. Run detail page (/{owner}/{repo}/actions/runs/{run_id})
  4. Job log viewer with ANSI color support
  5. Status badges for README
  6. Real-time log streaming via WebSocket

Phase 7: CLI Commands

  1. guts workflow list - List workflows
  2. guts workflow run - Trigger workflow manually
  3. guts run list - List workflow runs
  4. guts run logs - View run logs
  5. guts run cancel - Cancel a running workflow

API Reference

Workflow Endpoints

Method Path Description
GET /api/repos/{owner}/{name}/workflows List workflows
POST /api/repos/{owner}/{name}/workflows Create/update workflow
GET /api/repos/{owner}/{name}/workflows/{id} Get workflow details
DELETE /api/repos/{owner}/{name}/workflows/{id} Delete workflow

Run Endpoints

Method Path Description
GET /api/repos/{owner}/{name}/runs List runs
POST /api/repos/{owner}/{name}/runs Trigger manual run
GET /api/repos/{owner}/{name}/runs/{id} Get run details
POST /api/repos/{owner}/{name}/runs/{id}/cancel Cancel run
POST /api/repos/{owner}/{name}/runs/{id}/rerun Re-run workflow

Job Endpoints

Method Path Description
GET /api/repos/{owner}/{name}/runs/{id}/jobs List jobs in run
GET /api/repos/{owner}/{name}/runs/{id}/jobs/{job} Get job details
GET /api/repos/{owner}/{name}/runs/{id}/jobs/{job}/logs Get job logs

Artifact Endpoints

Method Path Description
GET /api/repos/{owner}/{name}/runs/{id}/artifacts List artifacts
POST /api/repos/{owner}/{name}/runs/{id}/artifacts Upload artifact
GET /api/repos/{owner}/{name}/runs/{id}/artifacts/{name} Download artifact
DELETE /api/repos/{owner}/{name}/runs/{id}/artifacts/{name} Delete artifact

Status Check Endpoints

Method Path Description
GET /api/repos/{owner}/{name}/commits/{sha}/status Get combined status
GET /api/repos/{owner}/{name}/commits/{sha}/statuses List all statuses
POST /api/repos/{owner}/{name}/commits/{sha}/statuses Create status check

WebSocket Events

New event types for CI/CD:

Event Description
workflow_run.requested Workflow run created
workflow_run.in_progress Workflow run started
workflow_run.completed Workflow run finished
workflow_job.queued Job queued
workflow_job.in_progress Job started
workflow_job.completed Job finished
check_run.created Status check created
check_run.completed Status check completed

Built-in Actions

The following actions are available by default:

Action Description
checkout Checkout repository at current commit
cache Cache dependencies between runs
upload-artifact Upload build artifacts
download-artifact Download artifacts from other jobs

Success Criteria

  • Workflows parse correctly from YAML
  • Jobs execute in correct dependency order
  • Status checks integrate with branch protection
  • Logs stream in real-time via WebSocket
  • Artifacts can be uploaded and downloaded
  • Web UI shows workflow runs and logs
  • CLI can trigger and monitor workflows
  • Failed required checks block PR merge

Security Considerations

  1. Sandboxing: Jobs run in isolated environments
  2. Secrets Management: Encrypted secret storage (future)
  3. Timeout Limits: Prevent runaway jobs
  4. Resource Limits: Cap CPU/memory per job
  5. Network Isolation: Restrict network access in jobs
  6. Audit Logging: Log all CI/CD operations

Performance Considerations

  1. Parallel Jobs: Jobs without dependencies run in parallel
  2. Caching: Cache build dependencies
  3. Incremental Builds: Only rebuild changed components
  4. Log Compression: Compress stored logs
  5. Artifact Deduplication: Content-addressed storage

Future Enhancements

These features are out of scope for Milestone 7 but planned:

  1. Secrets Management: Encrypted secrets for workflows
  2. Self-hosted Runners: Custom execution environments
  3. Matrix Builds: Parallel builds across configurations
  4. Reusable Workflows: Import workflows from other repos
  5. Workflow Templates: Pre-built workflow templates
  6. Cost Attribution: Track compute usage per repository

Dependencies

  • guts-auth: Branch protection, permissions
  • guts-collaboration: PR status integration
  • guts-realtime: WebSocket event streaming
  • guts-storage: Artifact storage
  • serde_yaml: YAML parsing
  • tokio: Async execution

References