find_unreachable_targets_from_root.sh 1.6 KB

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # Used to find targets without RECURSE/RECURCE_FOR_TESTS/.. paths from ydb/ya.make
  3. # TODO: run this check in CI
  4. set -e
  5. # find all modules+tests from ydb/ya.make
  6. ./ya make -Gj0 -ttt ydb --build release -k --cache-tests --build-all > output_dump
  7. cat output_dump | jq '.graph[]' | jq 'select( ."node-type"=="test")' | jq -r ".kv.path" | sort | uniq | sed -E 's/\/[^/]*$//g;/^null$/d' | sort | uniq | { grep "^ydb" || true; } > tests.txt
  8. cat output_dump | jq '.graph[]' | jq -r 'select( ."target_properties"."module_type" != null) | select( ( ."target_properties"."module_tag" // "-" | strings | contains("proto") ) | not ) | .target_properties.module_dir' | sort | uniq | { grep "^ydb" || true; } > modules.txt
  9. cat modules.txt tests.txt | (echo 'RECURSE(';cat;echo ')') > ya.make
  10. # find all modules+tests from generated ya.make, which contains all paths as RECURSE from previous step
  11. ./ya make -Gj0 -ttt . --build release -k --cache-tests --build-all > output_dump2
  12. cat output_dump2 | jq '.graph[]' | jq 'select( ."node-type"=="test")' | jq -r ".kv.path" | sort | uniq | sed -E 's/\/[^/]*$//g;/^null$/d' | sort | uniq | { grep "^ydb" || true; } > tests2.txt
  13. cat output_dump2 | jq '.graph[]' | jq -r 'select( ."target_properties"."module_type" != null) | select( ( ."target_properties"."module_tag" // "-" | strings | contains("proto") ) | not ) | .target_properties.module_dir' | sort | uniq | { grep "^ydb" || true; } > modules2.txt
  14. # put all targets together
  15. cat modules.txt tests.txt | sort | uniq > targets.txt
  16. cat modules2.txt tests2.txt | sort | uniq > targets2.txt
  17. # print targets which need to be fixes
  18. comm -13 targets.txt targets2.txt