145 lines
5.7 KiB
YAML
145 lines
5.7 KiB
YAML
# UNUSED: autopilot integration is disabled. The `/autopilot-e2e` slash
|
|
# command has been unregistered in `slash-command-dispatch.yml`, the
|
|
# `repository_dispatch` trigger has been removed here, and the job is
|
|
# guarded with `if: false` so even a manual `workflow_dispatch` is a no-op.
|
|
# Kept on disk for historical reference.
|
|
name: Trigger Autopilot E2E from slash command
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
trigger-autopilot-e2e:
|
|
name: trigger-autopilot-e2e
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
if: false # autopilot integration disabled; see header comment
|
|
permissions:
|
|
pull-requests: write # Required to update PR comments, labels, or branches.
|
|
issues: write # Required to comment on and react to PR issue comments.
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
steps:
|
|
- name: Add initial reaction
|
|
env:
|
|
COMMENT_ID: ${{ github.event.client_payload.github.payload.comment.id }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
|
run: |
|
|
gh api --method POST "repos/$REPOSITORY/issues/comments/$COMMENT_ID/reactions" \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-f content=eyes
|
|
|
|
- name: Generate GitHub App token
|
|
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
|
|
id: app-token
|
|
with:
|
|
app-id: ${{ secrets.AUTOPILOT_DISPATCH_APP_ID }}
|
|
private-key: ${{ secrets.AUTOPILOT_DISPATCH_PRIVATE_KEY }}
|
|
owner: tensorzero
|
|
repositories: autopilot
|
|
|
|
- name: Dispatch to autopilot
|
|
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
|
|
with:
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
repository: tensorzero/autopilot
|
|
event-type: tensorzero-main-updated
|
|
client-payload: |
|
|
{
|
|
"tensorzero_commit": "${{ github.event.client_payload.pull_request.head.sha }}",
|
|
"triggered_by": "${{ github.actor }}",
|
|
"source_run_id": "${{ github.run_id }}",
|
|
"source_run_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
}
|
|
|
|
- name: Wait for autopilot workflow and report status
|
|
id: wait-for-autopilot
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
SOURCE_RUN_ID: ${{ github.run_id }}
|
|
run: |
|
|
EXPECTED_NAME="Cross-Repo E2E (tensorzero/$SOURCE_RUN_ID)"
|
|
echo "Looking for workflow run with name: $EXPECTED_NAME"
|
|
|
|
sleep 10
|
|
|
|
# Find the workflow run by display_title (correlates to our specific dispatch)
|
|
for i in {1..120}; do
|
|
RUN_ID=$(gh api repos/tensorzero/autopilot/actions/runs \
|
|
-q ".workflow_runs[] | select(.display_title==\"$EXPECTED_NAME\") | .id")
|
|
|
|
if [ -n "$RUN_ID" ]; then
|
|
break
|
|
fi
|
|
sleep 5
|
|
done
|
|
|
|
if [ -z "$RUN_ID" ]; then
|
|
echo "Failed to find autopilot workflow run with name: $EXPECTED_NAME"
|
|
echo "run_url=https://github.com/tensorzero/autopilot/actions" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
fi
|
|
|
|
RUN_URL="https://github.com/tensorzero/autopilot/actions/runs/$RUN_ID"
|
|
echo "run_url=$RUN_URL" >> $GITHUB_OUTPUT
|
|
echo "Autopilot workflow: $RUN_URL"
|
|
|
|
# Poll until complete
|
|
while true; do
|
|
RESULT=$(gh api "repos/tensorzero/autopilot/actions/runs/$RUN_ID" -q '{status: .status, conclusion: .conclusion}')
|
|
STATUS=$(echo "$RESULT" | jq -r '.status')
|
|
CONCLUSION=$(echo "$RESULT" | jq -r '.conclusion')
|
|
|
|
if [ "$STATUS" = "completed" ]; then
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "Autopilot E2E tests passed"
|
|
exit 0
|
|
else
|
|
echo "Autopilot E2E tests failed with conclusion: $CONCLUSION"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
sleep 30
|
|
done
|
|
|
|
- name: Comment with workflow link
|
|
if: always()
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
ISSUE_NUMBER: ${{ github.event.client_payload.pull_request.number }}
|
|
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
|
RUN_URL: ${{ steps.wait-for-autopilot.outputs.run_url }}
|
|
run: |
|
|
gh issue comment "$ISSUE_NUMBER" --repo "$REPOSITORY" --body "馃殌 Autopilot E2E tests triggered!
|
|
|
|
View the run: $RUN_URL"
|
|
|
|
- name: Add success reaction
|
|
if: success()
|
|
env:
|
|
COMMENT_ID: ${{ github.event.client_payload.github.payload.comment.id }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
|
run: |
|
|
gh api --method POST "repos/$REPOSITORY/issues/comments/$COMMENT_ID/reactions" \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-f content=hooray
|
|
|
|
- name: Add failure reaction
|
|
if: failure()
|
|
env:
|
|
COMMENT_ID: ${{ github.event.client_payload.github.payload.comment.id }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
|
run: |
|
|
gh api --method POST "repos/$REPOSITORY/issues/comments/$COMMENT_ID/reactions" \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-f content='-1'
|