aboutsummaryrefslogtreecommitdiffstats
path: root/.github/scripts/graph_compare.sh
blob: ae155c35c60a42b2dba93005e29c50b29f6b4536 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Compares build graphs for two given refs in the current directory git repo
# Creates ya.make in the current directory listing affected ydb targets
# Parameters: base_commit_sha head_commit_sha

set -exo pipefail

workdir=$(mktemp -d)
echo Workdir: $workdir
echo Checkout base commit...
git checkout $1
echo Build graph for base commit...
./ya make -Gj0 -ttt ydb --build release -k --cache-tests --build-all | jq '.graph[]' > $workdir/graph_base

echo Checkout head commit...
git checkout $2
echo Build graph for head commit...
./ya make -Gj0 -ttt ydb --build release -k --cache-tests --build-all | jq '.graph[]' > $workdir/graph_head

echo Generate lists of uids for base and head...
cat $workdir/graph_base | jq '.uid' > $workdir/uid_base
cat $workdir/graph_head | jq '.uid' > $workdir/uid_head

echo Create a list of changed uids in the head graph...
(cat $workdir/uid_head;(cat $workdir/uid_base;cat $workdir/uid_head) | sort | uniq -u) | sort | uniq -d > $workdir/uids_new

echo Create ya.make
echo "" > ya.make

echo Generate list of test shard names from the head graph based on the list of uids...
cat $workdir/graph_head | jq -r --slurpfile uids $workdir/uids_new 'select( ."node-type"=="test") | select( any( .uid; .==$uids[] )) | .kv.path' | sort | uniq > $workdir/testsuites

echo Number of test suites:
cat $workdir/testsuites | wc -l

echo Removing test suite name from the list to get target names...
sed -E 's/\/[^/]*$//g;/^null$/d' $workdir/testsuites > $workdir/ts2

echo Append into ya.make RECURSE_FOR_TESTS to all required tests...
cat $workdir/ts2 | (echo 'RECURSE_FOR_TESTS(';cat;echo ')') >> ya.make

echo Generate list of module names from the head graph based on the list of uids...
cat $workdir/graph_head | jq -r --slurpfile uids $workdir/uids_new 'select( ."target_properties"."module_type" != null) | select( ( ."target_properties"."module_tag" // "-" | strings | contains("proto") ) | not ) | select( any( .uid; .==$uids[] )) | .target_properties.module_dir' | sort | uniq > $workdir/modules

echo Number of modules:
cat $workdir/modules | wc -l

echo Filter only modules in ydb
cat $workdir/modules | { grep "^ydb" || true; } > $workdir/modules2

echo Number of modules:
cat $workdir/modules2 | wc -l

echo Append into ya.make RECURSE to all required modules...
cat $workdir/modules2 | (echo 'RECURSE(';cat;echo ')') >> ya.make

echo "ya.make content:"
cat ya.make