diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 0b98dad2..c7ca13e0 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -38,43 +38,98 @@ jobs: event-type: trigger-workflow client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}' - wait-for-sdk-generation: - needs: release - runs-on: ubuntu-latest - steps: + - 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" + MAX_RETRIES=20 + SLEEP_TIME=15 # seconds + + for ((i=0; i> $GITHUB_ENV + break + else + echo "Waiting for JavaScript workflow to start..." + sleep $SLEEP_TIME + fi + done + + # Poll until the C++ SDK workflow run is available + - name: Get CPP Workflow Run ID + run: | + TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}" + REPO_OWNER="rdkcentral" + REPO_NAME="firebolt-apis" + WORKFLOW_NAME="CXX build" + MAX_RETRIES=20 + SLEEP_TIME=15 # seconds + + for ((i=0; i> $GITHUB_ENV + break + else + echo "Waiting for C++ workflow to start..." + sleep $SLEEP_TIME + fi + done + + + - name: Debugging JS Workflow ID and Run ID + run: | + echo "JavaScript Workflow ID: ${{ env.JS_RUN_ID }}" + echo "C++ Workflow ID: ${{ env.CPP_RUN_ID }}" + + - name: Print Environment Variables + run: printenv + - name: Poll Firebolt-api for JavaScript SDK generation id: poll-javascript-sdk run: | 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> $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." @@ -88,67 +143,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> $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: | @@ -182,4 +216,5 @@ jobs: "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" else echo "No SDKs were generated, no comment will be posted." - fi \ No newline at end of file + fi +