diff --git a/.github/workflows/indexer-processor-testing.yaml b/.github/workflows/indexer-processor-testing.yaml index 6e7049c233baa..85b79dedce21a 100644 --- a/.github/workflows/indexer-processor-testing.yaml +++ b/.github/workflows/indexer-processor-testing.yaml @@ -91,6 +91,10 @@ jobs: - name: Handle New Files and Differences run: | + echo "Checking outputs from diff_check step..." + echo "New file found: ${{ steps.diff_check.outputs.new_file_found }}" + echo "Diff found: ${{ steps.diff_check.outputs.diff_found }}" + if [ "${{ steps.diff_check.outputs.new_file_found }}" == "true" ]; then echo "New JSON files detected:" echo "${{ steps.diff_check.outputs.new_files }}" # Print all new files with paths @@ -121,7 +125,7 @@ jobs: # Conditionally Dispatch Event to Processor Repo if Differences Found - name: Dispatch Event to Processor Repo - if: steps.diff_check.outputs.diff_found == 'true' + if: steps.diff_check.outputs.diff_found == 'true' && steps.diff_check.outputs.new_file_found == 'false' uses: peter-evans/repository-dispatch@v3.0.0 with: TOKEN: '${{ steps.secrets.outputs.token }}' @@ -131,7 +135,10 @@ jobs: # Poll Processor Repo for Workflow Run Status and Memorize Run ID to check the job status - name: Poll for Workflow Run and Wait for Job Completion - if: steps.diff_check.outputs.diff_found == 'true' + if: steps.diff_check.outputs.diff_found == 'true' && steps.diff_check.outputs.new_file_found == 'false' id: poll_status run: | - . scripts/indexer_processor_tests_status_poll.sh \ No newline at end of file + . scripts/indexer_processor_tests_status_poll.sh + env: + GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} # Pass the correct GitHub token + GITHUB_SHA: ${{ github.sha }} \ No newline at end of file diff --git a/scripts/indexer_processor_tests_status_poll.sh b/scripts/indexer_processor_tests_status_poll.sh index 7aa190fd86504..be617fe108e1a 100644 --- a/scripts/indexer_processor_tests_status_poll.sh +++ b/scripts/indexer_processor_tests_status_poll.sh @@ -23,8 +23,19 @@ else response=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \ "https://api.github.com/repos/aptos-labs/aptos-indexer-processors/actions/runs?event=repository_dispatch&branch=main") + # Check if the workflow_runs array exists + workflow_runs=$(echo "$response" | jq -r '.workflow_runs') + if [ "$workflow_runs" == "null" ] || [ -z "$workflow_runs" ]; then + echo "No workflow runs found. Response from GitHub API:" + echo "$response" # Output the raw response for debugging + echo "Retrying in $sleep_interval seconds..." + attempts=$((attempts + 1)) + sleep $sleep_interval + continue + fi + # Filter the workflow run by the unique run-name commit hash - run_id=$(echo "$response" | jq -r ".workflow_runs[] | select(.name | test(\"$UUID\")) | .id") + run_id=$(echo "$workflow_runs" | jq -r ".[] | select(.name | test(\"$UUID\")) | .id") if [ -n "$run_id" ]; then echo "Found workflow run with ID: $run_id" @@ -57,8 +68,16 @@ while [ "$job_completed" == false ] && [ $job_attempts -lt $max_job_attempts ]; echo "Polling for job status. Attempt $((job_attempts+1)) of $max_job_attempts..." jobs_response=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "$jobs_url") + # Check if the jobs array exists + jobs=$(echo "$jobs_response" | jq -r '.jobs') + if [ "$jobs" == "null" ] || [ -z "$jobs" ]; then + echo "No jobs found in the workflow run. Response from GitHub API:" + echo "$jobs_response" # Output the raw response for debugging + exit 1 + fi + # Loop through the jobs and check their status - for job in $(echo "$jobs_response" | jq -r '.jobs[] | @base64'); do + for job in $(echo "$jobs" | jq -r '.[] | @base64'); do _jq() { echo "${job}" | base64 --decode | jq -r "${1}" } diff --git a/scripts/indexer_test_txns_compare_and_diff.sh b/scripts/indexer_test_txns_compare_and_diff.sh index 01cec9b946714..e747a1b853ad9 100644 --- a/scripts/indexer_test_txns_compare_and_diff.sh +++ b/scripts/indexer_test_txns_compare_and_diff.sh @@ -31,7 +31,6 @@ compare_and_diff() { diff_output=$(diff -u /dev/null "$generated_file" || true) if [ -n "$diff_output" ]; then echo "New file with diff found in $generated_file" - diff_found=true echo "Diff output for new file:" echo "$diff_output" fi @@ -103,7 +102,13 @@ else echo "No modified files detected." fi -# Set output flags (if integrated in a larger workflow, e.g., GitHub Actions) +# Debugging logs before setting outputs +echo "diff_found=$diff_found" +echo "new_file_found=$new_file_found" +echo "new_files=$new_files" +echo "modified_files=$modified_files" + +# Set output flags echo "diff_found=$diff_found" >> $GITHUB_OUTPUT echo "new_file_found=$new_file_found" >> $GITHUB_OUTPUT echo "new_files=$new_files" >> $GITHUB_OUTPUT # Store new files as output