graph_compare.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Compares build graphs for two given refs in the current directory git repo
  2. # Creates ya.make in the current directory listing affected ydb test suites
  3. # Parameters: base_commit_sha head_commit_sha
  4. set -e
  5. workdir=$(mktemp -d)
  6. echo Workdir: $workdir
  7. echo Checkout base commit...
  8. git checkout $1
  9. echo Build graph for base commit...
  10. ./ya make -Gj0 -ttt ydb --build release -k --cache-tests | jq '.graph[] | select( ."node-type"=="test")' > $workdir/graph_base
  11. echo Checkout head commit...
  12. git checkout $2
  13. echo Build graph for head commit...
  14. ./ya make -Gj0 -ttt ydb --build release -k --cache-tests | jq '.graph[] | select( ."node-type"=="test")' > $workdir/graph_head
  15. echo Generate lists of uids for base and head...
  16. cat $workdir/graph_base | jq '.uid' > $workdir/uid_base
  17. cat $workdir/graph_head | jq '.uid' > $workdir/uid_head
  18. echo Create a list of changed uids in the head graph...
  19. (cat $workdir/uid_head;(cat $workdir/uid_base;cat $workdir/uid_head) | sort | uniq -u) | sort | uniq -d > $workdir/uids_new
  20. echo Generate list of test shard names from the head graph based on the list of uids...
  21. cat $workdir/graph_head | jq -r --slurpfile uids $workdir/uids_new 'select( any( .uid; .==$uids[] )) | .kv.path' | sort | uniq > $workdir/testsuites
  22. echo Number of test suites:
  23. cat $workdir/testsuites | wc -l
  24. echo Removing test suite name from the list to get target names...
  25. sed -E 's/\/[^/]*$//g;/^null$/d' $workdir/testsuites > $workdir/ts2
  26. echo Generating temp ya.make with recurses to all required tests...
  27. cat $workdir/ts2 | (echo 'RECURSE_FOR_TESTS(';cat;echo ')') > ya.make
  28. # echo Running ya test...
  29. # ./ya make -A -R --build relwithdebinfo .