Skip to content

Commit

Permalink
differentiate between new file vs diff
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Oct 6, 2024
1 parent 9230866 commit 55dc651
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 26 deletions.
103 changes: 77 additions & 26 deletions .github/workflows/indexer-processor-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,39 +92,90 @@ jobs:
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
# id: diff_check
# run: |
# cd ecosystem/indexer-grpc/indexer-test-transactions
#
# # Initialize the diff flag as false
# 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
# else
# echo "No differences in $base_file"
# fi
# else
# echo "No existing file found for $base_file, skipping comparison."
# fi
# done
#
# # Set the output variable based on whether diffs were found
# echo "diff_found=$diff_found" >> $GITHUB_OUTPUT

# 4.i Compare All JSON Files Across Multiple Folders
- 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
# 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" # Output the actual differences
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
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
# Set output flags
echo "diff_found=$diff_found" >> $GITHUB_OUTPUT
echo "new_file_found=$new_file_found" >> $GITHUB_OUTPUT
# Handling New Files vs. Files with Differences
- name: Handle New Files and Differences
run: |
if [ "$new_file_found" = "true" ]; then
echo "::error::New JSON files detected. Manual review required before proceeding."
exit 1 # Stop the workflow for manual review
elif [ "$diff_found" = "true" ]; then
echo "Differences detected. Proceeding with dispatch event."
else
echo "No differences or new files detected."
exit 0
- id: auth
uses: "google-github-actions/auth@v2"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 55dc651

Please sign in to comment.