feat: add archeflow-rollback.sh for post-merge test failure auto-revert

This commit is contained in:
2026-04-04 07:34:43 +02:00
parent 34f101c166
commit 7f99d52a09
3 changed files with 99 additions and 23 deletions

View File

@@ -380,30 +380,19 @@ If all reviewers approved (and completion criteria met, if defined):
./lib/archeflow-git.sh merge "$RUN_ID" --no-ff
```
4. **Post-merge test validation:**
4. **Post-merge test validation** (using the auto-rollback script):
```bash
# Read test_command from config
TEST_CMD=$(grep -E "^test_command:" .archeflow/config.yaml | sed 's/^test_command:\s*//' | tr -d '"' || true)
if [[ -n "$TEST_CMD" ]]; then
echo "Running post-merge tests: $TEST_CMD"
if ! bash -c "$TEST_CMD"; then
echo "Post-merge tests FAILED — reverting merge..."
git revert --no-edit HEAD
# Emit decision event for the revert
./lib/archeflow-event.sh "$RUN_ID" decision act "" \
'{"what":"post_merge_test","chosen":"revert","rationale":"test suite failed after merge"}' "$SEQ_CHECK_TO_ACT"
# If cycles remain, cycle back with integration test failure feedback
if [[ "$CYCLE" -lt "$MAX_CYCLES" ]]; then
echo "Cycling back with integration test failure feedback..."
# Build act-feedback.md with "integration test failure on main" as top finding
# Continue to step 4d (Issues Found)
else
echo "Max cycles reached. Reporting failure to user."
# Continue to step 4e (Max Cycles Reached)
fi
# Run tests and auto-revert if they fail
if ! ./lib/archeflow-rollback.sh "$RUN_ID"; then
# Rollback script already reverted HEAD and emitted decision event
# If cycles remain, cycle back with integration test failure feedback
if [[ "$CYCLE" -lt "$MAX_CYCLES" ]]; then
echo "Cycling back with integration test failure feedback..."
# Build act-feedback.md with "integration test failure on main" as top finding
# Continue to step 4d (Issues Found)
else
echo "Max cycles reached. Reporting failure to user."
# Continue to step 4e (Max Cycles Reached)
fi
fi
```