agentic-loop 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ralph.sh +4 -0
- package/package.json +1 -1
- package/ralph/ci.sh +130 -0
- package/ralph/setup.sh +51 -0
- package/templates/github/workflows/nightly.yml +105 -0
- package/templates/github/workflows/pr.yml +56 -0
package/bin/ralph.sh
CHANGED
|
@@ -57,6 +57,7 @@ source "$RALPH_LIB/verify.sh"
|
|
|
57
57
|
source "$RALPH_LIB/prd.sh"
|
|
58
58
|
source "$RALPH_LIB/signs.sh"
|
|
59
59
|
source "$RALPH_LIB/test.sh"
|
|
60
|
+
source "$RALPH_LIB/ci.sh"
|
|
60
61
|
|
|
61
62
|
# Run auto-config if config.json was just created
|
|
62
63
|
if [[ "${_ralph_needs_autoconfig:-}" == "true" ]]; then
|
|
@@ -111,6 +112,9 @@ main() {
|
|
|
111
112
|
coverage)
|
|
112
113
|
ralph_test_coverage "$@"
|
|
113
114
|
;;
|
|
115
|
+
ci)
|
|
116
|
+
ralph_ci "$@"
|
|
117
|
+
;;
|
|
114
118
|
sign)
|
|
115
119
|
ralph_sign "$@"
|
|
116
120
|
;;
|
package/package.json
CHANGED
package/ralph/ci.sh
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# ci.sh - Set up GitHub Actions CI/CD workflows
|
|
4
|
+
|
|
5
|
+
# Install GitHub Actions workflows
|
|
6
|
+
ralph_ci() {
|
|
7
|
+
local cmd="${1:-install}"
|
|
8
|
+
|
|
9
|
+
case "$cmd" in
|
|
10
|
+
install)
|
|
11
|
+
install_github_workflows
|
|
12
|
+
;;
|
|
13
|
+
status)
|
|
14
|
+
check_ci_status
|
|
15
|
+
;;
|
|
16
|
+
*)
|
|
17
|
+
echo "Usage: ralph ci [install|status]"
|
|
18
|
+
echo ""
|
|
19
|
+
echo "Commands:"
|
|
20
|
+
echo " install - Install GitHub Actions workflows"
|
|
21
|
+
echo " status - Check CI status"
|
|
22
|
+
;;
|
|
23
|
+
esac
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
install_github_workflows() {
|
|
27
|
+
echo ""
|
|
28
|
+
print_info "=== Setting up GitHub Actions CI/CD ==="
|
|
29
|
+
echo ""
|
|
30
|
+
|
|
31
|
+
# Check if this is a git repo
|
|
32
|
+
if [[ ! -d ".git" ]]; then
|
|
33
|
+
print_error "Not a git repository. Run 'git init' first."
|
|
34
|
+
return 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Create workflows directory
|
|
38
|
+
mkdir -p .github/workflows
|
|
39
|
+
|
|
40
|
+
# Copy workflow templates
|
|
41
|
+
local template_dir="$RALPH_TEMPLATES/github/workflows"
|
|
42
|
+
|
|
43
|
+
if [[ ! -d "$template_dir" ]]; then
|
|
44
|
+
print_error "Workflow templates not found at $template_dir"
|
|
45
|
+
return 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Install PR workflow
|
|
49
|
+
if [[ -f ".github/workflows/pr.yml" ]]; then
|
|
50
|
+
echo " PR workflow already exists, skipping..."
|
|
51
|
+
else
|
|
52
|
+
cp "$template_dir/pr.yml" .github/workflows/pr.yml
|
|
53
|
+
print_success "Created .github/workflows/pr.yml (fast lint checks)"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# Install nightly workflow
|
|
57
|
+
if [[ -f ".github/workflows/nightly.yml" ]]; then
|
|
58
|
+
echo " Nightly workflow already exists, skipping..."
|
|
59
|
+
else
|
|
60
|
+
cp "$template_dir/nightly.yml" .github/workflows/nightly.yml
|
|
61
|
+
print_success "Created .github/workflows/nightly.yml (full test suite)"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
echo ""
|
|
65
|
+
echo "Workflows installed:"
|
|
66
|
+
echo ""
|
|
67
|
+
echo " 📋 PR Check (.github/workflows/pr.yml)"
|
|
68
|
+
echo " Runs on: Pull requests to main/master"
|
|
69
|
+
echo " Checks: Lint, TypeScript, Build"
|
|
70
|
+
echo " Speed: Fast (~1-2 min)"
|
|
71
|
+
echo ""
|
|
72
|
+
echo " 🌙 Nightly Tests (.github/workflows/nightly.yml)"
|
|
73
|
+
echo " Runs on: Daily at 3am UTC + manual trigger"
|
|
74
|
+
echo " Checks: Full test suite + PRD testSteps + Coverage"
|
|
75
|
+
echo " Speed: Comprehensive (~5-10 min)"
|
|
76
|
+
echo ""
|
|
77
|
+
|
|
78
|
+
# Check if we need to customize for monorepo
|
|
79
|
+
local backend_dir frontend_dir
|
|
80
|
+
backend_dir=$(get_config '.directories.backend' "")
|
|
81
|
+
frontend_dir=$(get_config '.directories.frontend' "")
|
|
82
|
+
|
|
83
|
+
if [[ -n "$backend_dir" ]] || [[ -n "$frontend_dir" ]]; then
|
|
84
|
+
print_warning "Monorepo detected. You may need to customize workflow paths."
|
|
85
|
+
echo ""
|
|
86
|
+
echo " Edit .github/workflows/*.yml to add:"
|
|
87
|
+
[[ -n "$backend_dir" ]] && echo " - working-directory: $backend_dir"
|
|
88
|
+
[[ -n "$frontend_dir" ]] && echo " - working-directory: $frontend_dir"
|
|
89
|
+
echo ""
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
# Remind about secrets
|
|
93
|
+
echo "Next steps:"
|
|
94
|
+
echo " 1. Review and customize the workflows if needed"
|
|
95
|
+
echo " 2. Commit and push: git add .github && git commit -m 'ci: Add GitHub Actions workflows'"
|
|
96
|
+
echo " 3. Set up any required secrets in GitHub repo settings"
|
|
97
|
+
echo ""
|
|
98
|
+
|
|
99
|
+
return 0
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
check_ci_status() {
|
|
103
|
+
echo ""
|
|
104
|
+
print_info "=== CI/CD Status ==="
|
|
105
|
+
echo ""
|
|
106
|
+
|
|
107
|
+
# Check for workflow files
|
|
108
|
+
if [[ -f ".github/workflows/pr.yml" ]]; then
|
|
109
|
+
print_success "PR workflow: installed"
|
|
110
|
+
else
|
|
111
|
+
print_warning "PR workflow: not installed"
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
if [[ -f ".github/workflows/nightly.yml" ]]; then
|
|
115
|
+
print_success "Nightly workflow: installed"
|
|
116
|
+
else
|
|
117
|
+
print_warning "Nightly workflow: not installed"
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# Check GitHub CLI
|
|
121
|
+
if command -v gh &>/dev/null; then
|
|
122
|
+
echo ""
|
|
123
|
+
echo "Recent workflow runs:"
|
|
124
|
+
gh run list --limit 5 2>/dev/null || echo " (unable to fetch - check 'gh auth login')"
|
|
125
|
+
else
|
|
126
|
+
echo ""
|
|
127
|
+
echo "Install GitHub CLI (gh) to see workflow status:"
|
|
128
|
+
echo " brew install gh && gh auth login"
|
|
129
|
+
fi
|
|
130
|
+
}
|
package/ralph/setup.sh
CHANGED
|
@@ -26,6 +26,7 @@ ralph_setup() {
|
|
|
26
26
|
setup_claude_md
|
|
27
27
|
setup_mcp
|
|
28
28
|
setup_precommit_hooks
|
|
29
|
+
setup_github_ci "$pkg_root"
|
|
29
30
|
|
|
30
31
|
echo ""
|
|
31
32
|
echo " ========================================"
|
|
@@ -463,3 +464,53 @@ EOF
|
|
|
463
464
|
echo " Then run: pre-commit install"
|
|
464
465
|
fi
|
|
465
466
|
}
|
|
467
|
+
|
|
468
|
+
# Set up GitHub Actions CI/CD
|
|
469
|
+
setup_github_ci() {
|
|
470
|
+
local pkg_root="$1"
|
|
471
|
+
local template_dir="$pkg_root/templates/github/workflows"
|
|
472
|
+
|
|
473
|
+
# Skip if not a git repo
|
|
474
|
+
if [[ ! -d ".git" ]]; then
|
|
475
|
+
return 0
|
|
476
|
+
fi
|
|
477
|
+
|
|
478
|
+
# Skip if templates don't exist
|
|
479
|
+
if [[ ! -d "$template_dir" ]]; then
|
|
480
|
+
return 0
|
|
481
|
+
fi
|
|
482
|
+
|
|
483
|
+
# Skip if already set up
|
|
484
|
+
if [[ -f ".github/workflows/pr.yml" ]] && [[ -f ".github/workflows/nightly.yml" ]]; then
|
|
485
|
+
return 0
|
|
486
|
+
fi
|
|
487
|
+
|
|
488
|
+
echo ""
|
|
489
|
+
echo " GitHub Actions CI/CD can be configured:"
|
|
490
|
+
echo " - PR checks: Fast lint/typecheck on pull requests"
|
|
491
|
+
echo " - Nightly: Full test suite + PRD tests at 3am UTC"
|
|
492
|
+
echo ""
|
|
493
|
+
read -r -p " Set up GitHub Actions? [Y/n] " response
|
|
494
|
+
|
|
495
|
+
if [[ "$response" =~ ^[Nn]$ ]]; then
|
|
496
|
+
echo " Skipped GitHub Actions (run 'ralph ci install' later)"
|
|
497
|
+
return 0
|
|
498
|
+
fi
|
|
499
|
+
|
|
500
|
+
echo "Setting up GitHub Actions CI/CD..."
|
|
501
|
+
|
|
502
|
+
# Create workflows directory
|
|
503
|
+
mkdir -p .github/workflows
|
|
504
|
+
|
|
505
|
+
# Install PR workflow
|
|
506
|
+
if [[ ! -f ".github/workflows/pr.yml" ]]; then
|
|
507
|
+
cp "$template_dir/pr.yml" .github/workflows/pr.yml
|
|
508
|
+
echo " Created .github/workflows/pr.yml (fast PR checks)"
|
|
509
|
+
fi
|
|
510
|
+
|
|
511
|
+
# Install nightly workflow
|
|
512
|
+
if [[ ! -f ".github/workflows/nightly.yml" ]]; then
|
|
513
|
+
cp "$template_dir/nightly.yml" .github/workflows/nightly.yml
|
|
514
|
+
echo " Created .github/workflows/nightly.yml (nightly full tests)"
|
|
515
|
+
fi
|
|
516
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Nightly comprehensive test suite
|
|
2
|
+
# Runs full tests + all PRD testSteps
|
|
3
|
+
|
|
4
|
+
name: Nightly Tests
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
schedule:
|
|
8
|
+
# Run at 3am UTC every day
|
|
9
|
+
- cron: '0 3 * * *'
|
|
10
|
+
workflow_dispatch: # Allow manual trigger
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
# Add postgres if your project needs it
|
|
18
|
+
postgres:
|
|
19
|
+
image: postgres:15
|
|
20
|
+
env:
|
|
21
|
+
POSTGRES_USER: test
|
|
22
|
+
POSTGRES_PASSWORD: test
|
|
23
|
+
POSTGRES_DB: test
|
|
24
|
+
ports:
|
|
25
|
+
- 5432:5432
|
|
26
|
+
options: >-
|
|
27
|
+
--health-cmd pg_isready
|
|
28
|
+
--health-interval 10s
|
|
29
|
+
--health-timeout 5s
|
|
30
|
+
--health-retries 5
|
|
31
|
+
|
|
32
|
+
env:
|
|
33
|
+
DATABASE_URL: postgresql://test:test@localhost:5432/test
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
# Python setup
|
|
39
|
+
- name: Set up Python
|
|
40
|
+
if: hashFiles('pyproject.toml') != '' || hashFiles('requirements.txt') != ''
|
|
41
|
+
uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: '3.11'
|
|
44
|
+
|
|
45
|
+
- name: Install Python dependencies
|
|
46
|
+
if: hashFiles('pyproject.toml') != ''
|
|
47
|
+
run: |
|
|
48
|
+
pip install uv
|
|
49
|
+
uv pip install -e ".[dev]" --system 2>/dev/null || pip install -e ".[dev]" 2>/dev/null || pip install -e . 2>/dev/null || true
|
|
50
|
+
|
|
51
|
+
# Node.js setup
|
|
52
|
+
- name: Set up Node.js
|
|
53
|
+
if: hashFiles('package.json') != ''
|
|
54
|
+
uses: actions/setup-node@v4
|
|
55
|
+
with:
|
|
56
|
+
node-version: '20'
|
|
57
|
+
cache: 'npm'
|
|
58
|
+
|
|
59
|
+
- name: Install Node dependencies
|
|
60
|
+
if: hashFiles('package.json') != ''
|
|
61
|
+
run: npm ci
|
|
62
|
+
|
|
63
|
+
# Run database migrations if needed
|
|
64
|
+
- name: Run migrations
|
|
65
|
+
if: hashFiles('alembic.ini') != ''
|
|
66
|
+
run: alembic upgrade head
|
|
67
|
+
continue-on-error: true
|
|
68
|
+
|
|
69
|
+
# Python tests
|
|
70
|
+
- name: Python tests
|
|
71
|
+
if: hashFiles('pyproject.toml') != '' || hashFiles('pytest.ini') != ''
|
|
72
|
+
run: |
|
|
73
|
+
pytest -v --tb=short 2>/dev/null || python -m pytest -v --tb=short 2>/dev/null || true
|
|
74
|
+
|
|
75
|
+
# Node tests
|
|
76
|
+
- name: Node tests
|
|
77
|
+
if: hashFiles('package.json') != ''
|
|
78
|
+
run: npm test 2>/dev/null || true
|
|
79
|
+
|
|
80
|
+
# PRD testSteps (if ralph is set up)
|
|
81
|
+
- name: Install ralph
|
|
82
|
+
run: npm install -g thrivekit 2>/dev/null || true
|
|
83
|
+
|
|
84
|
+
- name: Run PRD tests
|
|
85
|
+
if: hashFiles('.ralph/prd.json') != ''
|
|
86
|
+
run: ralph test prd 2>/dev/null || true
|
|
87
|
+
continue-on-error: true
|
|
88
|
+
|
|
89
|
+
# Coverage report
|
|
90
|
+
- name: Coverage report
|
|
91
|
+
if: hashFiles('pyproject.toml') != ''
|
|
92
|
+
run: |
|
|
93
|
+
pip install pytest-cov
|
|
94
|
+
pytest --cov --cov-report=term-missing 2>/dev/null || true
|
|
95
|
+
continue-on-error: true
|
|
96
|
+
|
|
97
|
+
notify:
|
|
98
|
+
needs: test
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
if: failure()
|
|
101
|
+
steps:
|
|
102
|
+
- name: Notify on failure
|
|
103
|
+
run: |
|
|
104
|
+
echo "Nightly tests failed! Check the workflow run for details."
|
|
105
|
+
# Add Slack/Discord notification here if desired
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Fast PR checks - lint only, no tests
|
|
2
|
+
# Tests run in nightly workflow to keep PRs fast
|
|
3
|
+
|
|
4
|
+
name: PR Check
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main, master]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
# Python linting
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
if: hashFiles('pyproject.toml') != '' || hashFiles('requirements.txt') != ''
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: '3.11'
|
|
22
|
+
|
|
23
|
+
- name: Install Python dependencies
|
|
24
|
+
if: hashFiles('pyproject.toml') != ''
|
|
25
|
+
run: |
|
|
26
|
+
pip install ruff
|
|
27
|
+
pip install -e . 2>/dev/null || true
|
|
28
|
+
|
|
29
|
+
- name: Ruff lint
|
|
30
|
+
if: hashFiles('pyproject.toml') != '' || hashFiles('ruff.toml') != ''
|
|
31
|
+
run: ruff check .
|
|
32
|
+
|
|
33
|
+
# Node.js linting
|
|
34
|
+
- name: Set up Node.js
|
|
35
|
+
if: hashFiles('package.json') != ''
|
|
36
|
+
uses: actions/setup-node@v4
|
|
37
|
+
with:
|
|
38
|
+
node-version: '20'
|
|
39
|
+
cache: 'npm'
|
|
40
|
+
|
|
41
|
+
- name: Install Node dependencies
|
|
42
|
+
if: hashFiles('package.json') != ''
|
|
43
|
+
run: npm ci
|
|
44
|
+
|
|
45
|
+
- name: ESLint
|
|
46
|
+
if: hashFiles('package.json') != ''
|
|
47
|
+
run: npm run lint 2>/dev/null || npx eslint . 2>/dev/null || true
|
|
48
|
+
|
|
49
|
+
- name: TypeScript check
|
|
50
|
+
if: hashFiles('tsconfig.json') != ''
|
|
51
|
+
run: npx tsc --noEmit
|
|
52
|
+
|
|
53
|
+
# Build check (catches import/bundling errors)
|
|
54
|
+
- name: Build
|
|
55
|
+
if: hashFiles('package.json') != ''
|
|
56
|
+
run: npm run build 2>/dev/null || true
|