From 3d2eb972056fd0c6f11cfc0d01c6c66ea04e90f8 Mon Sep 17 00:00:00 2001 From: TapTap Date: Thu, 30 Jul 2026 18:24:29 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20add=20automated=20agent=20workflows=20?= =?UTF-8?q?=E2=80=94=20review,=20fix,=20maintenance,=20batch-merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/agent-batch-merge.yml | 38 ++++++++++++++++++++++ .gitea/workflows/agent-fix.yml | 43 +++++++++++++++++++++++++ .gitea/workflows/agent-maintenance.yml | 26 +++++++++++++++ .gitea/workflows/agent-review.yml | 44 ++++++++++++++++++++++++++ .gitea/workflows/ci.yaml | 2 +- 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/agent-batch-merge.yml create mode 100644 .gitea/workflows/agent-fix.yml create mode 100644 .gitea/workflows/agent-maintenance.yml create mode 100644 .gitea/workflows/agent-review.yml diff --git a/.gitea/workflows/agent-batch-merge.yml b/.gitea/workflows/agent-batch-merge.yml new file mode 100644 index 0000000..5ac60cf --- /dev/null +++ b/.gitea/workflows/agent-batch-merge.yml @@ -0,0 +1,38 @@ +name: Agent Batch Merge +on: + workflow_dispatch: + inputs: + branches: + description: "Comma-separated branches to merge (e.g., fix/a,fix/b)" + required: true + +jobs: + batch-merge: + runs-on: ubuntu-latest + container: gitea.tap-tap.win/taptap/fastsync-ci:v9 + steps: + - uses: actions/checkout@v4 + with: + ref: dev + fetch-depth: 0 + + - name: Merge all branches + run: | + IFS=',' read -ra BRANCHES <<< "${{ github.event.inputs.branches }}" + for branch in "${BRANCHES[@]}"; do + branch=$(echo "$branch" | xargs) + git fetch origin "$branch" + git merge "origin/$branch" --no-edit || true + done + + - name: Build and test + run: | + cmake -B build -S . && cmake --build build -j$(nproc) + ./build/tests + python3 -m pytest tests/ -v --tb=short + + - name: Commit and push + run: | + git add -A + git commit -m "batch-merge: ${{ github.event.inputs.branches }}" || true + git push origin dev diff --git a/.gitea/workflows/agent-fix.yml b/.gitea/workflows/agent-fix.yml new file mode 100644 index 0000000..15b9130 --- /dev/null +++ b/.gitea/workflows/agent-fix.yml @@ -0,0 +1,43 @@ +name: Agent Issue Fix +on: + issue_comment: + types: [created] + +jobs: + fix: + if: contains(github.event.comment.body, '/opencode fix') + runs-on: ubuntu-latest + container: gitea.tap-tap.win/taptap/fastsync-ci:v9 + steps: + - uses: actions/checkout@v4 + with: + ref: dev + fetch-depth: 0 + + - name: Install opencode + run: npm install -g opencode-ai + + - name: Create fix branch and implement + run: | + ISSUE_NUM="${{ github.event.issue.number }}" + BRANCH="auto-fix/issue-${ISSUE_NUM}" + git checkout -b "$BRANCH" origin/dev + opencode run \ + "Fix this issue: ${{ github.event.issue.body }}" + git add -A + git commit -m "auto-fix: address issue #${ISSUE_NUM}" || true + git push origin "$BRANCH" + + - name: Create PR + run: | + ISSUE_NUM="${{ github.event.issue.number }}" + TITLE="${{ github.event.issue.title }}" + curl -s -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"title\": \"Fix: ${TITLE:0:80}\", + \"body\": \"Automated fix for issue #${ISSUE_NUM}\n\nCloses #${ISSUE_NUM}\", + \"head\": \"auto-fix/issue-${ISSUE_NUM}\", + \"base\": \"dev\" + }" \ + "https://gitea.tap-tap.win/api/v1/repos/${{ github.repository }}/pulls" diff --git a/.gitea/workflows/agent-maintenance.yml b/.gitea/workflows/agent-maintenance.yml new file mode 100644 index 0000000..2fa3fc2 --- /dev/null +++ b/.gitea/workflows/agent-maintenance.yml @@ -0,0 +1,26 @@ +name: Agent Scheduled Maintenance +on: + schedule: + - cron: "0 6 * * 1" + +jobs: + audit: + runs-on: ubuntu-latest + container: gitea.tap-tap.win/taptap/fastsync-ci:v9 + steps: + - uses: actions/checkout@v4 + with: + ref: dev + + - name: Install opencode + run: npm install -g opencode-ai + + - name: Security audit + run: | + opencode run --agent security-auditor \ + "Audit the codebase for vulnerabilities. Create issues for any findings via the Gitea API at https://gitea.tap-tap.win/api/v1/repos/${{ github.repository }}/issues using token ${{ secrets.GITEA_TOKEN }}" + + - name: Code quality scan + run: | + opencode run --agent code-quality-guardian \ + "Scan for code quality issues. Create issues for any findings via the Gitea API at https://gitea.tap-tap.win/api/v1/repos/${{ github.repository }}/issues using token ${{ secrets.GITEA_TOKEN }}" diff --git a/.gitea/workflows/agent-review.yml b/.gitea/workflows/agent-review.yml new file mode 100644 index 0000000..3be7107 --- /dev/null +++ b/.gitea/workflows/agent-review.yml @@ -0,0 +1,44 @@ +name: Agent PR Review +on: + pull_request: + types: [opened, synchronize, ready_for_review] + +jobs: + review: + runs-on: ubuntu-latest + container: gitea.tap-tap.win/taptap/fastsync-ci:v9 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install opencode + run: npm install -g opencode-ai + + - name: Run security audit review + run: | + opencode run --agent security-auditor \ + "Review this PR for security vulnerabilities" \ + > /tmp/security-review.md 2>&1 || true + + - name: Run code quality review + run: | + opencode run --agent code-quality-guardian \ + "Review this PR for code quality issues" \ + > /tmp/quality-review.md 2>&1 || true + + - name: Post combined review + run: | + { + echo "## Agent Review Report" + echo "" + echo "### Security Audit" + cat /tmp/security-review.md 2>/dev/null || echo "No security issues found." + echo "" + echo "### Code Quality" + cat /tmp/quality-review.md 2>/dev/null || echo "No quality issues found." + } > /tmp/full-review.md + curl -s -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "$(jq -Rs '{body: .}' < /tmp/full-review.md)" \ + "https://gitea.tap-tap.win/api/v1/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 82cd6af..05e4d05 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [main] + branches: [dev, main] pull_request: jobs: