# CI/CD Integration

#### CI/CD Integration

**Continuous Integration**

```yaml
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
          
      - name: Install AMESA
        run: pip install composabl
        
      - name: Validate Simulators
        run: |
          for sim in simulators/*/; do
            composabl sim validate "$sim"
          done
          
      - name: Run Tests
        run: pytest tests/
```

**Continuous Deployment**

```yaml
# .github/workflows/deploy.yml
name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
          
      - name: Install AMESA
        run: pip install composabl
        
      - name: Set Token
        run: echo "${{ secrets.AMESA_TOKEN }}" > ~/.composabl/token
        
      - name: Publish Components
        run: |
          # Publish simulators
          composabl sim publish ./simulators/reactor-sim/
          
          # Publish skills
          composabl skill publish ./skills/temperature-control/
          
          # Publish perceptors
          composabl perceptor publish ./perceptors/derivative-calc/
```

#### Scripting with CLI

```python
#!/usr/bin/env python3
import subprocess
import json
import sys

def run_command(cmd):
    """Run CLI command and return output"""
    result = subprocess.run(
        cmd, 
        shell=True, 
        capture_output=True, 
        text=True
    )
    if result.returncode != 0:
        print(f"Error: {result.stderr}")
        sys.exit(1)
    return result.stdout.strip()

# Get simulator mappings
mappings_json = run_command(
    "composabl sim mappings --address localhost:1337"
)
mappings = json.loads(mappings_json)

# Extract sensor names
sensors = [
    s["name"] 
    for s in mappings["sensor_space"]["mappings"]
]

print(f"Found sensors: {sensors}")

# Create agent dynamically
agent_code = f"""
from composabl import Agent, Sensor

agent = Agent()
agent.add_sensors([
    {', '.join(f'Sensor("{s}", "", lambda obs: obs[{i}])' 
               for i, s in enumerate(sensors))}
])
"""

with open("dynamic_agent.py", "w") as f:
    f.write(agent_code)

# Train agent
run_command("composabl agent train dynamic_agent.py")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.amesa.com/reference/cli-reference/ci-cd-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
