Skip to content

Commit

Permalink
Update check-pr.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
kdivya153 committed Oct 29, 2024
1 parent 92c5402 commit bddb69b
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,45 @@ jobs:
repository: rdkcentral/firebolt-apis
event-type: trigger-workflow
client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}'
- name: Get JS Workflow Run ID
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
WORKFLOW_NAME="MFOS standalone sanity report - CORE,MANAGE,DISCOVERY"
# Get workflow ID
js_workflow_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \
--arg WORKFLOW_NAME "$WORKFLOW_NAME" '.workflows[] | select(.name == $WORKFLOW_NAME).id')
# Capture the specific run ID for the workflow just triggered
js_run_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$js_workflow_id/runs?per_page=1" | \
jq -r '.workflow_runs[0].id')
echo "JS_RUN_ID=$js_run_id" >> $GITHUB_ENV
- name: Get CPP Workflow Run ID
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
WORKFLOW_NAME="CXX build"
# Fetch workflow ID
cpp_workflow_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \
--arg WORKFLOW_NAME "$WORKFLOW_NAME" '.workflows[] | select(.name == $WORKFLOW_NAME).id')
# Fetch the specific run ID for the workflow triggered by this workflow
cpp_run_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$cpp_workflow_id/runs?per_page=1" | \
jq -r '.workflow_runs[0].id')
echo "CPP_RUN_ID=$cpp_run_id" >> $GITHUB_ENV
wait-for-sdk-generation:
needs: release
runs-on: ubuntu-latest
Expand All @@ -47,34 +86,17 @@ jobs:
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
WORKFLOW_NAME="MFOS standalone sanity report - CORE,MANAGE,DISCOVERY"
RUN_ID="${{ env.JS_RUN_ID }}"
MAX_POLLS=30 # Max polls before timeout
POLL_INTERVAL=50 # In seconds
# Fetch the workflow ID once
response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \
--arg WORKFLOW_NAME "$WORKFLOW_NAME" \
'.workflows[] | select(.name == $WORKFLOW_NAME)')
workflow_id=$(echo $response | jq -r '.id')
if [ "$workflow_id" == "null" ]; then
echo "Workflow not found."
sleep 10
continue
fi
# Start polling for the workflow run
# Poll the specific run ID for status
for ((i=0; i<MAX_POLLS; i++)); do
# Use the same response to get the latest run
run_response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$workflow_id/runs?per_page=1")
status=$(echo $run_response | jq -r '.workflow_runs[0].status')
conclusion=$(echo $run_response | jq -r '.workflow_runs[0].conclusion')
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
# Store conclusion if available
echo "JS_SDK_CONCLUSION=$conclusion" >> $GITHUB_ENV
status=$(echo $run_response | jq -r '.status')
conclusion=$(echo $run_response | jq -r '.conclusion')
if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then
echo "JavaScript SDK generated successfully for the OpenRPC changes."
Expand All @@ -88,68 +110,46 @@ jobs:
fi
done
# Final check after loop
if [ "$i" -eq "$MAX_POLLS" ]; then
echo "Timeout reached while waiting for JavaScript SDK generation."
exit 1
else
echo "Polling completed successfully."
fi
- name: Poll Firebolt-api for CPP SDK generation
id: poll-cpp-sdk
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
PR_NUMBER="${{ github.event.pull_request.number }}"
WORKFLOW_NAME="CXX build"
RUN_ID="${{ env.CPP_RUN_ID }}"
MAX_POLLS=30 # Max polls before timeout
POLL_INTERVAL=50 # In seconds
PR_NUMBER="${{ github.event.pull_request.number }}"
# Fetch the workflow ID once
response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \
--arg WORKFLOW_NAME "$WORKFLOW_NAME" \
'.workflows[] | select(.name == $WORKFLOW_NAME)')
workflow_id=$(echo $response | jq -r '.id')
if [ "$workflow_id" == "null" ]; then
echo "Workflow not found."
sleep 10
continue
fi
# Start polling for the workflow run
# Poll the specific run ID for status
for ((i=0; i<MAX_POLLS; i++)); do
# Use the same response to get the latest run
run_response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$workflow_id/runs?per_page=1")
status=$(echo $run_response | jq -r '.workflow_runs[0].status')
conclusion=$(echo $run_response | jq -r '.workflow_runs[0].conclusion')
# Store conclusion if available
echo "CPP_SDK_CONCLUSION=$conclusion" >> $GITHUB_ENV
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
status=$(echo $run_response | jq -r '.status')
conclusion=$(echo $run_response | jq -r '.conclusion')
if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then
echo "C++ SDK generated successfully for the OpenRPC changes."
echo "JavaScript SDK generated successfully for the OpenRPC changes."
break
elif [ "$status" == "completed" ] && [ "$conclusion" == "failure" ]; then
echo "Failed to generate C++ SDK for the OpenRPC changes."
echo "Failed to generate JavaScript SDK for the OpenRPC changes."
else
echo "Still in progress. Checking again in ${POLL_INTERVAL} seconds..."
sleep $POLL_INTERVAL
fi
done
# Final check after loop
if [ "$i" -eq "$MAX_POLLS" ]; then
echo "Timeout reached while waiting for C++ SDK generation."
echo "Timeout reached while waiting for JavaScript SDK generation."
exit 1
else
echo "Polling completed successfully."
fi
- name: Post comments on PR
if: env.JS_SDK_CONCLUSION != 'unknown' || env.CPP_SDK_CONCLUSION != 'unknown' # Only run if at least one SDK ran
run: |
Expand Down

0 comments on commit bddb69b

Please sign in to comment.