forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson-auto-merge-ci-pipeline.json
More file actions
16 lines (16 loc) · 2.72 KB
/
Copy pathlesson-auto-merge-ci-pipeline.json
File metadata and controls
16 lines (16 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"task_id": "lesson-auto-merge-ci-pipeline",
"title": "Auto-Merge CI Pipeline — DCO, Quality Score, Shadow Branch, Dynamic Deps, Auto-Merge",
"domain": "devops",
"tags": [
"github-actions",
"ci",
"auto-merge",
"shadow-branch",
"quality-score"
],
"problem": "Manual merge is the bottleneck in zero-bounty open-source workflows. Maintainers must review every PR, click merge, post thank-you comments — repetitive work that doesn't scale when AI agents submit PRs at high velocity.",
"solution": "Build a fully automated CI pipeline that handles the entire PR lifecycle from submission to merge:\n\n```\nPR opened → Shadow Branch mirror → DCO check (standalone)\n → Quality Score (noise ratio + title heuristics)\n → Dynamic Dependency Discovery (find -name requirements.txt)\n → Test Suite → Audit Report → Auto-Merge Gate\n → Thank-you comment posted → Issue closed\n```\n\n### 1. Heuristic Quality Score (anti-spam)\n\nReject low-effort agent submissions before running expensive tests:\n\n```yaml\n# pr-checks.yml snippet — Agent Quality Score\n- name: Agent Quality Score\n run: |\n DIFF=$(gh api repos/owner/repo/pulls/$PR/files --paginate --jq '[.[].patch // \"\"] | join(\"\\n\")')\n TOTAL=$(echo \"$DIFF\" | grep -c '^[+-]')\n NOISE=$(echo \"$DIFF\" | grep -cE '^[+-]\\s*$|^[+-]\\s*[}\\]>\\]]')\n SCORE=100\n [ \"$(echo \"$RATIO > 0.5\" | bc)\" -eq 1 ] && SCORE=$((SCORE - 50))\n # Title pattern check\n echo \"$TITLE\" | grep -qi \"automated.*submit\\|auto.*pr\" && SCORE=$((SCORE - 20))\n [ \"$SCORE\" -lt 40 ] && gh pr close \"$PR\" --comment \"Quality Score Failed\"\n```\n\nThreshold: score >= 40 passes. Below that → auto-close with explanation.\n\n### 2. Dynamic Dependency Discovery\n\nInstead of manually tracking which subdirectories need `pip install`, scan recursively:\n\n```yaml\n- name: Install Dependencies\n run: |\n pip install -r requirements.txt 2>/dev/null || true\n find . -path ./venv -prune -o -name \"requirements.txt\" \\\n -print0 | xargs -0 pip install -r 2>/dev/null || true\n pip install pytest pytest-cov\n```\n\nPrevents the \"ModuleNotFoundError on new submodule deps\" class of CI failures.\n\n### 3. Shadow Branch Isolation\n\nExternal contributor PRs get mirrored to `shadow/pr-N` branches automatically:\n\n```yaml\n# shadow-branch.yml\non: pull_request\njobs:\n isolate:\n if: github.event.pull_request.author_association != 'OWNER'\n steps:\n - run: |\n gh api repos/owner/repo/git/refs --method POST \\\n --field ref=\"refs/heads/shadow/pr-$PR_NUM\" \\\n --",
"source": "lessons/auto-merge-ci-pipeline.md",
"test_cmd": "python3 scripts/verify_task.py lesson-auto-merge-ci-pipeline"
}