From 2471febb334d1840800e747746656cbe19eb6899 Mon Sep 17 00:00:00 2001 From: yuunlimm Date: Sun, 6 Oct 2024 13:27:27 -0700 Subject: [PATCH] differentiate between new file vs diff --- .../workflows/indexer-processor-testing.yaml | 84 ++++++---- .../5523474017_test_addding_new_version.json | 146 ++++++++++++++++++ 2 files changed, 202 insertions(+), 28 deletions(-) create mode 100644 ecosystem/indexer-grpc/indexer-test-transactions/json_transactions/imported_testnet_txns/5523474017_test_addding_new_version.json diff --git a/.github/workflows/indexer-processor-testing.yaml b/.github/workflows/indexer-processor-testing.yaml index a51271dd0a6ec8..be98944e363eed 100644 --- a/.github/workflows/indexer-processor-testing.yaml +++ b/.github/workflows/indexer-processor-testing.yaml @@ -19,7 +19,9 @@ jobs: steps: - name: Checkout the repository uses: actions/checkout@v4 - + with: + ref: ${{ github.event.pull_request.head.ref }} # Checkout the PR's head ref + - name: Set up Rust uses: aptos-labs/aptos-core/.github/actions/rust-setup@main with: @@ -91,40 +93,66 @@ jobs: echo "Showing Modified New JSON Files:" cat ecosystem/indexer-grpc/indexer-test-transactions/new_json_transactions/scripted_transactions/modified_simple_user_script3.json - # Compare New and Existing JSON Files After Modifying and Set Output if Differences Found - - name: Compare JSON Files + - name: Compare JSON Files Across Multiple Folders id: diff_check run: | - cd ecosystem/indexer-grpc/indexer-test-transactions - - # Initialize the diff flag as false + # Initialize the flags diff_found=false - - # Loop over all modified new JSON files and compare them with existing ones in scripted_transactions - for file in json_transactions/scripted_transactions/*.json; do - base_file=$(basename "$file" .json) - modified_file="new_json_transactions/scripted_transactions/modified_${base_file}.json" - original_file="json_transactions/scripted_transactions/modified_${base_file}.json" - if [ -f "$original_file" ]; then - echo "Comparing $modified_file with $original_file..." - - # Run diff and capture the output. Use || true to prevent it from stopping the script - diff_output=$(diff -u "$original_file" "$modified_file" || true) - - if [ -n "$diff_output" ]; then - echo "Differences found in $base_file" - diff_found=true - echo "$diff_output" # Output the actual differences + new_file_found=false + new_files="" + + # Loop over all subdirectories inside json_transactions + for folder in json_transactions/*/; do + for file in $folder/*.json; do + base_file=$(basename "$file" .json) + modified_file="new_json_transactions/$folder/modified_${base_file}.json" + original_file="$folder/modified_${base_file}.json" + + if [ -f "$original_file" ]; then + echo "Comparing $modified_file with $original_file..." + + # Run diff and capture the output + diff_output=$(diff -u "$original_file" "$modified_file" || true) + + if [ -n "$diff_output" ]; then + echo "Differences found in $base_file" + diff_found=true + echo "$diff_output" + else + echo "No differences in $base_file" + fi else - echo "No differences in $base_file" + echo "New file detected: $base_file" + new_file_found=true + new_files="$new_files\n$base_file" # Append new file to list of new files fi - else - echo "No existing file found for $base_file, skipping comparison." - fi + done done - - # Set the output variable based on whether diffs were found + + # Print all new files if found + if [ "$new_file_found" = "true" ]; then + echo "New files detected:" + echo -e "$new_files" + fi + + # 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 + + - name: Handle New Files and Differences + run: | + if [ "${{ steps.diff_check.outputs.new_file_found }}" == "true" ]; then + echo "::error::New JSON files detected:" + echo "${{ steps.diff_check.outputs.new_files }}" # Print all new files + exit 0 # Fail the workflow to enforce manual review + elif [ "${{ steps.diff_check.outputs.diff_found }}" == "true" ]; then + echo "Differences detected. Proceeding with dispatch event." + else + echo "No differences or new files detected." + exit 0 # Proceed successfully only if no new files or differences are found + fi + - id: auth uses: "google-github-actions/auth@v2" diff --git a/ecosystem/indexer-grpc/indexer-test-transactions/json_transactions/imported_testnet_txns/5523474017_test_addding_new_version.json b/ecosystem/indexer-grpc/indexer-test-transactions/json_transactions/imported_testnet_txns/5523474017_test_addding_new_version.json new file mode 100644 index 00000000000000..e5fd6fff68d5e3 --- /dev/null +++ b/ecosystem/indexer-grpc/indexer-test-transactions/json_transactions/imported_testnet_txns/5523474017_test_addding_new_version.json @@ -0,0 +1,146 @@ +{ + "timestamp": { + "seconds": "1722211338", + "nanos": 779450000 + }, + "version": "5523474017", + "info": { + "hash": "1kkham6kNNbAueBgDc+RMZmKTlbL4zywIf+7AWJ0v2A=", + "stateChangeHash": "fABXcX3RraHn5d1GfFJpWrCbwOh9ug7hTeImLvlOA6A=", + "eventRootHash": "08MIxEwK2hfk2FK/5KoPDjIG35oRKmWZEXK8rhLh8ko=", + "success": true, + "vmStatus": "Executed successfully", + "accumulatorRootHash": "UtxhE+1C8udt8mKLmBpBV9ekoy++eHbhFFCXPtniVgM=", + "changes": [ + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x1", + "stateKeyHash": "Xd9ATGDpbpSFvq/Ku5Vgn+2OOOlBpyXK5Nzsgpb7Mtc=", + "type": { + "address": "0x1", + "module": "block", + "name": "BlockResource" + }, + "typeStr": "0x1::block::BlockResource", + "data": "{\"epoch_interval\":\"3600000000\",\"height\":\"322305241\",\"new_block_events\":{\"counter\":\"322305242\",\"guid\":{\"id\":{\"addr\":\"0x1\",\"creation_num\":\"3\"}}},\"update_epoch_interval_events\":{\"counter\":\"7\",\"guid\":{\"id\":{\"addr\":\"0x1\",\"creation_num\":\"4\"}}}}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x1", + "stateKeyHash": "gEjJVCIYFLBFM6nwqZRsOo1HKsYt9azLn0fAl+JW6LY=", + "type": { + "address": "0x1", + "module": "stake", + "name": "ValidatorPerformance" + }, + "typeStr": "0x1::stake::ValidatorPerformance", + "data": "{\"validators\":[{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"1\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"},{\"failed_proposals\":\"0\",\"successful_proposals\":\"0\"}]}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x1", + "stateKeyHash": "exYVvwEtPJQiPz92KH7i973zHTZAcRKLJWrv8IQbYm0=", + "type": { + "address": "0x1", + "module": "timestamp", + "name": "CurrentTimeMicroseconds" + }, + "typeStr": "0x1::timestamp::CurrentTimeMicroseconds", + "data": "{\"microseconds\":\"1722211338779450\"}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x1", + "stateKeyHash": "VCzDS7Uv5qY3MK24IaHd++RWfBWU5M9ZGvrYct7Ry/4=", + "type": { + "address": "0x1", + "module": "randomness", + "name": "PerBlockRandomness" + }, + "typeStr": "0x1::randomness::PerBlockRandomness", + "data": "{\"epoch\":\"16644\",\"round\":\"1\",\"seed\":{\"vec\":[\"0x2d34077a3ec39f050d59efe4694fbdabefc21e44915101bd52b5b1326a814d39\"]}}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x1", + "stateKeyHash": "rLamyj9FTcXOT+7oZEgHwwg1WcI7RCxO2qR8/D4viSk=", + "type": { + "address": "0x1", + "module": "state_storage", + "name": "StateStorageUsage" + }, + "typeStr": "0x1::state_storage::StateStorageUsage", + "data": "{\"epoch\":\"16644\",\"usage\":{\"bytes\":\"70524795966\",\"items\":\"175824675\"}}" + } + } + ] + }, + "epoch": "16644", + "blockHeight": "322305241", + "type": "TRANSACTION_TYPE_BLOCK_METADATA", + "sizeInfo": { + "transactionBytes": 145, + "eventSizeInfo": [ + { + "typeTagBytes": 54, + "totalBytes": 203 + } + ], + "writeOpSizeInfo": [ + { + "keyBytes": 88, + "valueBytes": 112 + }, + { + "keyBytes": 95, + "valueBytes": 305 + }, + { + "keyBytes": 102, + "valueBytes": 8 + }, + { + "keyBytes": 98, + "valueBytes": 50 + }, + { + "keyBytes": 100, + "valueBytes": 24 + } + ] + }, + "blockMetadata": { + "id": "0xb3370bbca2cbe623cc892be55f5b870c860e4735bad0c8ad7d10190deace26ba", + "round": "1", + "events": [ + { + "key": { + "creationNumber": "3", + "accountAddress": "0x1" + }, + "sequenceNumber": "322305241", + "type": { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "block", + "name": "NewBlockEvent" + } + }, + "typeStr": "0x1::block::NewBlockEvent", + "data": "{\"epoch\":\"16644\",\"failed_proposer_indices\":[],\"hash\":\"0xb3370bbca2cbe623cc892be55f5b870c860e4735bad0c8ad7d10190deace26ba\",\"height\":\"322305241\",\"previous_block_votes_bitvec\":\"0x000000\",\"proposer\":\"0x479ca442491cfd636f84fa8e56fa420c8038587e459e886d16a0b9d3993b16ba\",\"round\":\"1\",\"time_microseconds\":\"1722211338779450\"}" + } + ], + "previousBlockVotesBitvec": "AAAA", + "proposer": "0x479ca442491cfd636f84fa8e56fa420c8038587e459e886d16a0b9d3993b16ba" + } +} \ No newline at end of file