Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .github/workflows/fix-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile

# Step 0: Configure git identity and create fix branch
# Step 0a: Clone ag-ui repo for AG-UI schema drift detection
- name: Clone ag-ui repo
run: git clone --depth 1 https://github.com/ag-ui-protocol/ag-ui.git ../ag-ui

# Step 0b: Configure git identity and create fix branch
- name: Configure git
run: |
git config user.name "aimock-drift-bot"
Expand Down Expand Up @@ -83,7 +87,9 @@ jobs:

# Step 3: Invoke Claude Code to fix
- name: Auto-fix drift
id: autofix
if: steps.check.outputs.skip != 'true'
continue-on-error: true
run: npx tsx scripts/fix-drift.ts
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Expand Down Expand Up @@ -118,8 +124,8 @@ jobs:
id: pr
if: success() && steps.check.outputs.skip != 'true'
run: |
npx tsx scripts/fix-drift.ts --create-pr 2>&1 | tee /tmp/pr-output.txt
PR_URL=$(grep -oE 'https://github.com/[^ ]+/pull/[0-9]+' /tmp/pr-output.txt | head -1)
npx tsx scripts/fix-drift.ts --create-pr
PR_URL=$(gh pr list --head "$(git branch --show-current)" --json url --jq '.[0].url')
if [ -z "$PR_URL" ]; then echo "No PR URL found"; exit 1; fi
echo "url=$PR_URL" >> $GITHUB_OUTPUT
env:
Expand All @@ -146,9 +152,11 @@ jobs:
if: success() && steps.pr.outputs.url != ''
run: |
if [ -z "$SLACK_WEBHOOK" ]; then echo "SLACK_WEBHOOK not set, skipping"; exit 0; fi
curl -s -X POST "$SLACK_WEBHOOK" \
MSG="✅ *Drift auto-fix PR created with auto-merge enabled*\nPR: ${{ steps.pr.outputs.url }}\nRun: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
PAYLOAD=$(jq -n --arg text "$MSG" '{text: $text}')
curl -sf -X POST "$SLACK_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\":\"✅ *Drift auto-fixed and merged*\nPR: ${{ steps.pr.outputs.url }}\nRun: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
-d "$PAYLOAD"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Expand All @@ -157,8 +165,10 @@ jobs:
if: failure() && steps.check.outputs.skip != 'true'
run: |
if [ -z "$SLACK_WEBHOOK" ]; then echo "SLACK_WEBHOOK not set, skipping"; exit 0; fi
curl -s -X POST "$SLACK_WEBHOOK" \
MSG="❌ *Drift auto-fix failed* — issue created\nRun: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
PAYLOAD=$(jq -n --arg text "$MSG" '{text: $text}')
curl -sf -X POST "$SLACK_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\":\"❌ *Drift auto-fix failed* — issue created\nRun: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
-d "$PAYLOAD"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
66 changes: 49 additions & 17 deletions .github/workflows/test-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,47 +67,79 @@ jobs:
if-no-files-found: warn
retention-days: 30

- name: Fail if critical drift detected
if: steps.drift.outputs.exit_code == '2'
run: exit 1

notify:
if: always() && github.event_name != 'pull_request'
needs: [drift, agui-schema-drift]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check previous run status
id: prev
if: always()
run: |
PREV=$(gh run list --workflow="Drift Tests" --branch=main --limit=2 --json conclusion --jq '.[1].conclusion // "unknown"')
PREV=$(gh run list --workflow="Drift Tests" --repo="${{ github.repository }}" --branch=main --limit=2 --json conclusion --jq '.[1].conclusion // "unknown"')
echo "conclusion=$PREV" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Notify Slack
if: always()
run: |
if [ -z "$SLACK_WEBHOOK" ]; then echo "SLACK_WEBHOOK not set, skipping"; exit 0; fi

PREV="${{ steps.prev.outputs.conclusion }}"
NOW="${{ job.status }}"
DRIFT="${{ steps.drift.outputs.exit_code }}"
DRIFT_RESULT="${{ needs.drift.result }}"
AGUI_RESULT="${{ needs.agui-schema-drift.result }}"

# Drift detected — always notify
if [ "$DRIFT" = "2" ]; then
HTTP_DRIFT=false
AGUI_DRIFT=false
INFRA_ERROR=false

# Determine what happened in each job
if [ "$DRIFT_RESULT" = "failure" ]; then
HTTP_DRIFT=true
elif [ "$DRIFT_RESULT" != "success" ] && [ "$DRIFT_RESULT" != "skipped" ]; then
INFRA_ERROR=true
fi

if [ "$AGUI_RESULT" = "failure" ]; then
AGUI_DRIFT=true
elif [ "$AGUI_RESULT" != "success" ] && [ "$AGUI_RESULT" != "skipped" ]; then
INFRA_ERROR=true
fi

RUN_URL="<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"

# Both types of drift
if [ "$HTTP_DRIFT" = "true" ] && [ "$AGUI_DRIFT" = "true" ]; then
EMOJI="🚨"
MSG="*Drift detected* in aimock — HTTP API drift + AG-UI schema drift. ${RUN_URL}"
# HTTP API drift only
elif [ "$HTTP_DRIFT" = "true" ]; then
EMOJI="🚨"
MSG="*Drift detected* in aimock — providers changed response formats. <https://github.com/CopilotKit/aimock/actions/runs/${{ github.run_id }}|View run>"
MSG="*HTTP API drift detected* in aimock — providers changed response formats. ${RUN_URL}"
# AG-UI schema drift only
elif [ "$AGUI_DRIFT" = "true" ]; then
EMOJI="🚨"
MSG="*AG-UI schema drift detected* in aimock — canonical ag-ui types changed. ${RUN_URL}"
# Infra failure — always notify
elif [ "$NOW" != "success" ]; then
elif [ "$INFRA_ERROR" = "true" ]; then
EMOJI="❌"
MSG="*Drift tests failed* (infra error). <https://github.com/CopilotKit/aimock/actions/runs/${{ github.run_id }}|View run>"
MSG="*Drift tests failed* (infra error). ${RUN_URL}"
# Recovery: previous was bad, now good — notify once
elif [ "$PREV" = "failure" ]; then
EMOJI="✅"
MSG="Drift tests passing again — all providers match."
MSG="Drift tests passing again — all providers and AG-UI schema match."
# Good → good — stay quiet
else
exit 0
fi

curl -s -X POST "$SLACK_WEBHOOK" \
PAYLOAD=$(jq -n --arg text "${EMOJI} ${MSG}" '{text: $text}')
curl -sf -X POST "$SLACK_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\": \"${EMOJI} ${MSG}\"}"
-d "$PAYLOAD"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Fail if critical drift detected
if: steps.drift.outputs.exit_code == '2'
run: exit 1
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
"default": "./dist/vector-stub.cjs"
}
},
"./agui": {
"import": {
"types": "./dist/agui-stub.d.ts",
"default": "./dist/agui-stub.js"
},
"require": {
"types": "./dist/agui-stub.d.cts",
"default": "./dist/agui-stub.cjs"
}
},
"./vitest": {
"import": {
"types": "./dist/vitest.d.ts",
Expand Down Expand Up @@ -124,6 +134,10 @@
"./dist/vector-stub.d.ts",
"./dist/vector-stub.d.cts"
],
"agui": [
"./dist/agui-stub.d.ts",
"./dist/agui-stub.d.cts"
],
"vitest": [
"./dist/vitest.d.ts",
"./dist/vitest.d.cts"
Expand Down
Loading
Loading