vibe-and-thrive 1.6.3 → 1.6.5
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/package.json +1 -1
- package/ralph/loop.sh +9 -8
- package/ralph/utils.sh +23 -38
package/package.json
CHANGED
package/ralph/loop.sh
CHANGED
|
@@ -162,7 +162,14 @@ run_loop() {
|
|
|
162
162
|
|
|
163
163
|
rm -f "$prompt_file"
|
|
164
164
|
|
|
165
|
-
# 5. Run verification
|
|
165
|
+
# 5. Run migrations BEFORE verification (tests need DB schema)
|
|
166
|
+
if ! run_migrations_if_needed "$pre_story_sha"; then
|
|
167
|
+
log_progress "$story" "FAILED" "Migration failed"
|
|
168
|
+
print_error "Migration failed for $story, will retry..."
|
|
169
|
+
continue
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
# 6. Run verification pipeline
|
|
166
173
|
echo ""
|
|
167
174
|
if run_verification "$story"; then
|
|
168
175
|
# Mark story as complete
|
|
@@ -175,13 +182,7 @@ run_loop() {
|
|
|
175
182
|
rm -f "$RALPH_DIR/last_test_failure.log"
|
|
176
183
|
rm -f "$RALPH_DIR/last_playwright_failure.log"
|
|
177
184
|
rm -f "$RALPH_DIR/last_browser_failure.json"
|
|
178
|
-
|
|
179
|
-
# Run migrations if new migration files were created
|
|
180
|
-
if ! run_migrations_if_needed "$pre_story_sha"; then
|
|
181
|
-
log_progress "$story" "FAILED" "Migration failed"
|
|
182
|
-
print_error "Migration failed for $story, will retry..."
|
|
183
|
-
continue
|
|
184
|
-
fi
|
|
185
|
+
rm -f "$RALPH_DIR/last_precommit_failure.log"
|
|
185
186
|
|
|
186
187
|
# Auto-commit if git is available
|
|
187
188
|
if command -v git &>/dev/null && [[ -d ".git" ]]; then
|
package/ralph/utils.sh
CHANGED
|
@@ -404,9 +404,10 @@ validate_prd() {
|
|
|
404
404
|
return 0
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
#
|
|
407
|
+
# Ensure database migrations are applied before verification
|
|
408
|
+
# Migration commands are idempotent - they no-op if nothing pending
|
|
408
409
|
run_migrations_if_needed() {
|
|
409
|
-
local pre_sha="$1"
|
|
410
|
+
local pre_sha="$1" # unused now, kept for API compatibility
|
|
410
411
|
local config="$RALPH_DIR/config.json"
|
|
411
412
|
|
|
412
413
|
if [[ ! -f "$config" ]]; then return 0; fi
|
|
@@ -415,44 +416,28 @@ run_migrations_if_needed() {
|
|
|
415
416
|
migrate_cmd=$(jq -r '.migrations.command // empty' "$config" 2>/dev/null)
|
|
416
417
|
if [[ -z "$migrate_cmd" ]]; then return 0; fi
|
|
417
418
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
print_warning "migrations.pattern not configured, skipping migration check"
|
|
422
|
-
return 0
|
|
423
|
-
fi
|
|
424
|
-
|
|
425
|
-
# Check for new migration files since story started
|
|
426
|
-
local new_migrations=""
|
|
427
|
-
|
|
428
|
-
if [[ -n "$pre_sha" ]]; then
|
|
429
|
-
# Compare against pre-story commit
|
|
430
|
-
new_migrations=$(git diff --name-only "$pre_sha" 2>/dev/null | grep -E "$pattern" || true)
|
|
431
|
-
fi
|
|
432
|
-
|
|
433
|
-
# Also check uncommitted changes (staged and unstaged)
|
|
434
|
-
local uncommitted
|
|
435
|
-
uncommitted=$(git diff --name-only HEAD 2>/dev/null | grep -E "$pattern" || true)
|
|
436
|
-
uncommitted+=$(git diff --name-only --cached 2>/dev/null | grep -E "$pattern" || true)
|
|
437
|
-
|
|
438
|
-
if [[ -n "$uncommitted" ]]; then
|
|
439
|
-
new_migrations="$new_migrations $uncommitted"
|
|
440
|
-
fi
|
|
441
|
-
|
|
442
|
-
# Trim whitespace and check if any migrations found
|
|
443
|
-
new_migrations=$(echo "$new_migrations" | xargs)
|
|
419
|
+
# Always run migrations - commands are idempotent (no-op if nothing pending)
|
|
420
|
+
# This ensures DB schema is always in sync before tests run
|
|
421
|
+
echo -n " Ensuring migrations applied... "
|
|
444
422
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
echo " Files: $new_migrations"
|
|
423
|
+
local log_file
|
|
424
|
+
log_file=$(mktemp)
|
|
448
425
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
426
|
+
if safe_exec "$migrate_cmd" "$log_file"; then
|
|
427
|
+
# Check if any migrations were actually applied
|
|
428
|
+
if grep -qiE "applying|migrating|running|upgrade" "$log_file" 2>/dev/null; then
|
|
429
|
+
print_success "applied"
|
|
430
|
+
else
|
|
431
|
+
echo "up to date"
|
|
452
432
|
fi
|
|
453
|
-
|
|
454
|
-
|
|
433
|
+
rm -f "$log_file"
|
|
434
|
+
return 0
|
|
435
|
+
else
|
|
436
|
+
print_error "failed"
|
|
437
|
+
echo ""
|
|
438
|
+
echo " Migration error:"
|
|
439
|
+
tail -20 "$log_file" | sed 's/^/ /'
|
|
440
|
+
rm -f "$log_file"
|
|
441
|
+
return 1
|
|
455
442
|
fi
|
|
456
|
-
|
|
457
|
-
return 0
|
|
458
443
|
}
|