From 9dff2b17ce7f443781c78b2f73f63b0ca61f3ded Mon Sep 17 00:00:00 2001 From: Git Admin Date: Mon, 1 Dec 2025 18:21:51 +0000 Subject: [PATCH] Test enhanced CI/CD workflow --- PHASE3_ENHANCED_WORKFLOW.md | 221 ++++++++++++++++++++++++++++++++++++ README.md | 1 + openhands-sdk-wrapper-sh.sh | 2 +- test.txt | 1 - test2.txt | 1 - test3.txt | 1 - 6 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 PHASE3_ENHANCED_WORKFLOW.md create mode 100644 README.md delete mode 100644 test.txt delete mode 100644 test2.txt delete mode 100644 test3.txt diff --git a/PHASE3_ENHANCED_WORKFLOW.md b/PHASE3_ENHANCED_WORKFLOW.md new file mode 100644 index 0000000..da7019e --- /dev/null +++ b/PHASE3_ENHANCED_WORKFLOW.md @@ -0,0 +1,221 @@ +# Phase 3: Enhanced CI/CD Workflow + +**Status:** โœ… Imported to n8n +**Webhook URL:** `https://n8n.oky.sh/webhook/openhands-enhanced` +**Last Updated:** 2025-12-01 + +--- + +## ๐ŸŽฏ **Enhanced Features** + +### 1. **Retry Logic** +- Maximum 3 retry attempts +- 15-second wait between retries +- Tracks retry count in workflow static data + +### 2. **Status Checking** +- Waits 10 seconds for OpenHands initialization +- Simulates build status checking +- Returns SUCCESS/FAILED status + +### 3. **Response Formatting** +- JSON response with emoji indicators +- Includes retry count +- Shows build status, repo, branch, commit + +### 4. **Error Handling** +- Graceful degradation +- Clear error messages +- Fallback responses + +--- + +## ๐Ÿ”„ **Workflow Flow** + +``` +[1] Gitea Webhook + โ†“ +[2] Extract Repo Info (JavaScript) + โ†“ +[3] Start OpenHands Build (SSH) + โ†“ +[4] Wait 10s (Initialization) + โ†“ +[5] Check Build Status (Simulated) + โ†“ +[6] Should Retry? (IF Node) + โ”œโ”€ NO โ†’ [7] Format Response + โ””โ”€ YES โ†’ [8] Wait 15s โ†’ [9] Under Max Retries? + โ”œโ”€ YES โ†’ [10] Increment Retry โ†’ [11] Retry Build + โ””โ”€ NO โ†’ [7] Format Response (MAX EXCEEDED) + โ†“ +[7] Format Response (with emoji & details) + โ†“ +[8] Send JSON Response +``` + +--- + +## ๐Ÿ“Š **Response Format** + +### Success Response +```json +{ + "status": "SUCCESS", + "emoji": "โœ…", + "repo": "gitadmin/mvp-factory-openhands", + "branch": "main", + "commit": "abc123", + "message": "Build completed successfully", + "timestamp": "2025-12-01T18:15:00.000Z", + "retry_count": 0 +} +``` + +### Failure Response +```json +{ + "status": "FAILED", + "emoji": "โŒ", + "repo": "gitadmin/mvp-factory-openhands", + "branch": "main", + "commit": "abc123", + "message": "Build failed - errors detected", + "timestamp": "2025-12-01T18:15:00.000Z", + "retry_count": 1 +} +``` + +--- + +## ๐Ÿ”ง **Key Improvements Over Phase 2** + +### Phase 2 (Basic) +- Webhook โ†’ Extract โ†’ SSH โ†’ Response +- Simple execution +- No retry logic +- No status checking +- Basic response + +### Phase 3 (Enhanced) +- โœ… Webhook โ†’ Extract โ†’ SSH โ†’ Wait โ†’ Check โ†’ Retry Loop โ†’ Response +- โœ… Retry logic (3 attempts) +- โœ… Status checking +- โœ… Detailed response with status +- โœ… Error handling +- โœ… Better UX with emojis + +--- + +## ๐Ÿงช **Testing** + +### Activate Workflow +1. Go to: https://n8n.oky.sh +2. Find: "Gitea โ†’ OpenHands Enhanced CI/CD" +3. **Toggle to activate** (green) + +### Test Manually +```bash +curl -X POST https://n8n.oky.sh/webhook/openhands-enhanced \ + -H "Content-Type: application/json" \ + -d '{ + "repository": { + "name": "test-repo", + "full_name": "gitadmin/test-repo", + "clone_url": "https://git.oky.sh/gitadmin/test-repo.git" + }, + "ref": "refs/heads/main", + "after": "xyz789", + "commits": [{"message": "Test enhanced workflow"}], + "pusher": {"username": "gitadmin"} + }' +``` + +### Expected Response +```json +{ + "status": "SUCCESS", + "emoji": "โœ…", + "message": "Build completed successfully", + ... +} +``` + +--- + +## ๐Ÿš€ **Gitea Webhook Configuration** + +### Update Gitea Webhook +1. Go to Gitea repository +2. Settings โ†’ Webhooks โ†’ Edit existing webhook +3. Update URL to: `https://n8n.oky.sh/webhook/openhands-enhanced` +4. Save + +### Alternative: Create New Webhook +1. Add Webhook โ†’ Gitea +2. URL: `https://n8n.oky.sh/webhook/openhands-enhanced` +3. Push Events: โœ… +4. Active: โœ… + +--- + +## ๐Ÿ“ˆ **Production Readiness** + +### โœ… Working +- Webhook receiving +- Payload extraction +- SSH execution +- Retry logic +- Status reporting +- Response formatting + +### ๐Ÿ”„ Future Enhancements +- Actual OpenHands status checking (instead of simulation) +- Post status to Gitea API (commit statuses) +- Email/Slack notifications +- Build artifacts storage +- Test result reporting + +--- + +## ๐Ÿ”‘ **Configuration** + +### Workflow Settings +- **Name:** "Gitea โ†’ OpenHands Enhanced CI/CD" +- **Path:** `openhands-enhanced` +- **Active:** โœ… +- **Version:** 1 + +### SSH Credentials +- **ID:** v2BMXeCFGpXaoIyb +- **Name:** SSH Private Key account +- **Key:** /home/bam/.ssh/n8n_key + +### Retry Settings +- **Max Retries:** 3 +- **Wait Between Retries:** 15 seconds +- **Initial Wait:** 10 seconds + +--- + +## ๐Ÿ“ **Notes** + +- This workflow is **simulated** - build status checking is mocked +- In production, replace "Check Build Status" with actual OpenHands API polling +- Retry logic uses n8n static data to persist counter across nodes +- The workflow will eventually complete (either SUCCESS or MAX RETRIES EXCEEDED) + +--- + +## ๐ŸŽ“ **Key Learnings** + +1. **n8n Static Data** - Use `$workflow.staticData` for persistent state +2. **Retry Patterns** - Combine Wait + IF nodes for retry loops +3. **Response Formatting** - JavaScript nodes can format JSON responses +4. **Conditional Logic** - IF nodes with multiple branches for complex flows +5. **SSH Integration** - Works reliably for executing commands remotely + +--- + +**Status:** Ready for testing โœ… +**Next:** Configure Gitea webhook and test end-to-end diff --git a/README.md b/README.md new file mode 100644 index 0000000..5b5ff4a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Test enhanced workflow diff --git a/openhands-sdk-wrapper-sh.sh b/openhands-sdk-wrapper-sh.sh index c060516..42993b3 100755 --- a/openhands-sdk-wrapper-sh.sh +++ b/openhands-sdk-wrapper-sh.sh @@ -4,7 +4,7 @@ SDK_PATH="/tmp/software-agent-sdk" VENV_PATH="$SDK_PATH/.venv/bin" -ENV_FILE="/home/bam/claude/mvp-factory/openhands.env" +ENV_FILE="/home/bam/openhands/.env" WRAPPER_PATH="/home/bam/openhands-sdk-wrapper-fixed.py" # Check if task argument provided diff --git a/test.txt b/test.txt deleted file mode 100644 index 922586a..0000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -Test webhook diff --git a/test2.txt b/test2.txt deleted file mode 100644 index 922586a..0000000 --- a/test2.txt +++ /dev/null @@ -1 +0,0 @@ -Test webhook diff --git a/test3.txt b/test3.txt deleted file mode 100644 index 922586a..0000000 --- a/test3.txt +++ /dev/null @@ -1 +0,0 @@ -Test webhook