Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow that monitors the downstream test result. #15793

Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/indexer-protos-sdk-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ jobs:
repository: 'aptos-labs/aptos-indexer-processor-sdk'
event-type: 'proto-dependency-update'
client-payload: '{"commit_hash": "${{ github.sha }}", "branch_name": "${{ steps.commit_hash.outputs.branch_name }}"}'
- name: Poll for Workflow Run and Wait for Job Completion
run: |
. scripts/indexer_proto_update_status_poll.sh
env:
PAT_TOKEN: ${{ steps.secrets.outputs.token }}
TARGET_BRANCH: ${{ steps.commit_hash.outputs.branch_name }}-update-aptos-protos-update-sdk
# TOOD: enable this once the forge test is stable.
# - name: Run Forge Tests
# uses: ./.github/workflows/workflow-run-forge
Expand Down
42 changes: 42 additions & 0 deletions scripts/indexer_proto_update_status_poll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# PAT_TOKEN and TARGET_BRANCH are passed in as environment variables.

TARGET_REPO="aptos-labs/aptos-indexer-processors"
WORKFLOW_NAME="sdk-dependency-update"
MAX_RETRIES=30
RETRY_INTERVAL=60 # seconds

echo "Monitoring workflow $WORKFLOW_NAME for branch $TARGET_BRANCH in $TARGET_REPO"

for ((i=1; i<=MAX_RETRIES; i++)); do
# Get the latest run of the workflow for the target branch
response=$(curl -s -H "Authorization: token $PAT_TOKEN" \
"https://api.github.com/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_NAME/runs?branch=$TARGET_BRANCH&status=in_progress")

# Check if there is an in-progress run
if echo "$response" | grep -q '"in_progress"'; then
echo "Workflow still in progress... waiting."
sleep $RETRY_INTERVAL
else
# Check the latest completed run for the branch
response=$(curl -s -H "Authorization: token $PAT_TOKEN" \
"https://api.github.com/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_NAME/runs?branch=$TARGET_BRANCH&status=completed")
total_count=$(echo "$response" | jq -r '.total_count')
if [ "$total_count" -gt 0 ]; then
conclusion=$(echo "$response" | jq -r '.workflow_runs[0].conclusion')
else
echo "No workflow runs found for branch $TARGET_BRANCH"
continue
fi
# If the workflow succeeds, exit with a zero status
if [ "$conclusion" == "success" ]; then
echo "Workflow completed successfully!"
exit 0
fi
# Otherwise, we retry.
fi
done

echo "Workflow did not complete within the timeout period."
exit 1
Loading