Skip to content

Commit 54af18c

Browse files
authored
Merge 4d7fda7 into a04e6ba
2 parents a04e6ba + 4d7fda7 commit 54af18c

File tree

2 files changed

+22
-62
lines changed

2 files changed

+22
-62
lines changed

.github/actions/test_ya/action.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,12 @@ runs:
252252
echo "::debug::get version"
253253
./ya --version
254254
255-
export YA_MAKE_COMMAND="./ya make ${params[@]}"
256255
if [ "${{ inputs.increment }}" = "true" ]; then
257256
GRAPH_COMPARE_OUTPUT="$PUBLIC_DIR/graph_compare_log.txt"
258257
GRAPH_COMPARE_OUTPUT_URL="$PUBLIC_DIR_URL/graph_compare_log.txt"
259258
260259
set +e
261-
./.github/scripts/graph_compare.py $ORIGINAL_HEAD~1 $ORIGINAL_HEAD |& tee $GRAPH_COMPARE_OUTPUT
260+
./.github/scripts/graph_compare.py --ya-make-command "./ya make ${params[@]}" --result-graph-path graph.json --result-context-path context.json $ORIGINAL_HEAD~1 $ORIGINAL_HEAD |& tee $GRAPH_COMPARE_OUTPUT
262261
RC=${PIPESTATUS[0]}
263262
set -e
264263
@@ -271,7 +270,7 @@ runs:
271270
fi
272271
273272
git checkout $ORIGINAL_HEAD
274-
YA_MAKE_TARGET=.
273+
YA_MAKE_TARGET="--build-custom-json graph.json --custom-context context.json"
275274
else
276275
YA_MAKE_TARGET=""
277276
for TARGET in ${{ inputs.build_target }}; do
@@ -297,8 +296,6 @@ runs:
297296
params+=(--retest)
298297
fi
299298
300-
export YA_MAKE_COMMAND="./ya make ${params[@]}"
301-
302299
YA_MAKE_OUT_DIR=$TMP_DIR/out
303300
304301
YA_MAKE_OUTPUT="$PUBLIC_DIR/ya_make_output.txt"
@@ -369,7 +366,7 @@ runs:
369366
MONITOR_PID=$!
370367
371368
set +e
372-
($YA_MAKE_COMMAND $YA_MAKE_TARGET \
369+
(./ya make ${params[@]} $YA_MAKE_TARGET \
373370
$RERUN_FAILED_OPT --log-file "$PUBLIC_DIR/ya_log.txt" \
374371
--evlog-file "$CURRENT_PUBLIC_DIR/ya_evlog.jsonl" \
375372
--junit "$CURRENT_JUNIT_XML_PATH" --build-results-report "$CURRENT_REPORT" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& cat >> $YA_MAKE_OUTPUT

.github/scripts/graph_compare.py

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import os
88
import tempfile
9-
import sys
109
import json
10+
import argparse
1111

1212

1313
def exec(command: str):
@@ -22,77 +22,40 @@ def log(msg: str):
2222
print(msg)
2323

2424

25-
def do_compare():
26-
if len(sys.argv) < 3:
27-
print('base or head commit not set')
28-
exit(1)
29-
base_commit = sys.argv[1]
30-
head_commit = sys.argv[2]
31-
32-
ya_make_command = os.getenv('YA_MAKE_COMMAND')
33-
if not ya_make_command:
34-
print('YA_MAKE_COMMAND not set')
25+
def do_compare(opts):
26+
if opts.ya_make_command:
27+
print('--ya-make-command not set')
3528
exit(1)
29+
ya = opts.ya_make_command.split(' ')[0]
3630

3731
workdir = os.getenv('workdir')
3832
if not workdir:
3933
workdir = tempfile.mkdtemp()
4034

4135
log(f'Workdir: {workdir}')
4236
log('Checkout base commit...')
43-
exec(f'git checkout {base_commit}')
37+
exec(f'git checkout {opts.base_commit}')
4438
log('Build graph for base commit...')
45-
exec(f'{ya_make_command} ydb -k -A --cache-tests -Gj0 > {workdir}/graph_base.json')
39+
exec(f'{opts.ya_make_command} ydb -k --cache-tests --save-graph-to {workdir}/graph_base.json --save-context-to {workdir}/context_base.json')
4640

4741
log('Checkout head commit...')
48-
exec(f'git checkout {head_commit}')
42+
exec(f'git checkout {opts.head_commit}')
4943
log('Build graph for head commit...')
50-
exec(f'{ya_make_command} ydb -k -A --cache-tests -Gj0 > {workdir}/graph_head.json')
44+
exec(f'{opts.ya_make_command} ydb -k --cache-tests --save-graph-to {workdir}/graph_head.json --save-context-to {workdir}/context_head.json')
5145

5246
log('Generate diff graph...')
53-
exec(f'./ya tool ygdiff --old {workdir}/graph_base.json --new {workdir}/graph_head.json --cut {workdir}/graph_diff.json --dump-uids-for-affected-nodes {workdir}/affected_uids.json')
54-
55-
log('Read diff graph...')
56-
with open(f'{workdir}/graph_diff.json', 'r') as f:
57-
diff_graph = json.load(f)
58-
59-
with open(f'{workdir}/affected_uids.json', 'r') as f:
60-
uids = set(json.load(f))
61-
62-
tests = set()
63-
modules = set()
64-
65-
log('Scan diff graph...')
66-
for target in diff_graph.get('graph', []):
67-
if target.get('uid') not in uids:
68-
continue
69-
if target.get('node-type') == 'test':
70-
path = target.get('kv', {}).get('path')
71-
if path is not None:
72-
tests.add(os.path.dirname(path))
73-
tp = target.get('target_properties')
74-
if (
75-
tp is not None
76-
and tp.get('module_type') is not None
77-
and tp.get('module_dir', '').startswith('ydb')
78-
and tp.get('module_tag', '').find('proto') < 0
79-
):
80-
modules.add(tp.get('module_dir'))
81-
82-
log('Create ya.make')
47+
exec(f'{ya} tool ygdiff --old {workdir}/graph_base.json --new {workdir}/graph_head.json --cut {opts.result_graph_path} --dump-uids {workdir}/uids.json')
8348

84-
with open('ya.make', 'w') as ya_make:
85-
ya_make.write('RECURSE_FOR_TESTS(\n')
86-
for test in sorted(tests):
87-
ya_make.write(f' {test}\n')
88-
ya_make.write(')\n\nRECURSE (\n')
89-
for module in sorted(modules):
90-
ya_make.write(f' {module}\n')
91-
ya_make.write(')\n')
92-
log('ya.make content:')
93-
exec('cat ya.make')
49+
log('Generate diff context...')
50+
exec(f'{ya} tool context_difference {workdir}/context_base.json {workdir}/context_head.json {opts.result_context_path} {workdir}/uids.json {opts.result_graph_path}')
9451
exit(0)
9552

9653

9754
if __name__ == '__main__':
98-
do_compare()
55+
parser = argparse.ArgumentParser()
56+
parser.add_argument('--result-graph-path', '-g', type=str, help='Path for result graph', dest='graph_path', required=True)
57+
parser.add_argument('--result-context-path', '-c', type=str, help='Path for result context', dest='context_path', required=True)
58+
parser.add_argument('--ya-make-command', '-y', type=str, help='Ya make command', dest='ya_make_command', required=True)
59+
parser.add_argument(dest='base_commit', help='Base commit')
60+
parser.add_argument(dest='head_commit', help='Head commit')
61+
do_compare(parser.parse_args())

0 commit comments

Comments
 (0)