Skip to content

Commit 50d5fe9

Browse files
Merge 735faa2 into 7d3baf9
2 parents 7d3baf9 + 735faa2 commit 50d5fe9

File tree

9 files changed

+146
-144
lines changed

9 files changed

+146
-144
lines changed

.github/actions/build_and_test_ya/action.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@ inputs:
3131
test_type:
3232
type: string
3333
default: "unittest,py3test,py2test,pytest"
34+
increment:
35+
type: boolean
36+
required: true
37+
description: If true, compares build graphs between the current and previous commits to find a list of test suites to run. Otherwise, runs all tests.
3438
folder_prefix:
3539
type: string
3640
default: "ya-"
37-
cache_tests:
38-
type: boolean
39-
default: false
40-
description: "Use cache for tests"
4141
put_build_results_to_cache:
4242
type: boolean
4343
default: true
44-
commit_sha:
45-
type: string
46-
default: ""
4744
secs:
4845
type: string
4946
default: ""
@@ -67,7 +64,7 @@ runs:
6764
# tricky: we are searching job with name that contains build_preset
6865
check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
6966
70-
echo "Pre-commit [check]($check_url) for ${{ inputs.commit_sha }} has started." | .github/scripts/tests/comment-pr.py --rewrite
67+
echo "Pre-commit [check]($check_url) for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
7168
7269
- name: Prepare s3cmd
7370
uses: ./.github/actions/s3cmd
@@ -91,24 +88,32 @@ runs:
9188
bazel_remote_password: ${{ inputs.put_build_results_to_cache && fromJSON( inputs.secs ).REMOTE_CACHE_PASSWORD || '' }}
9289
link_threads: ${{ inputs.link_threads }}
9390

94-
- name: debug1
91+
- name: Generate ya.make with affected test suites list
92+
if: inputs.run_tests == 'true' && inputs.increment == 'true'
93+
uses: ./.github/actions/graph_compare
94+
95+
- name: Check if there's a list of tests to run
96+
id: test_run_choice
9597
shell: bash
96-
run: echo "Run tests? ${{ inputs.run_tests }}"
98+
run: |
99+
if [ -f ya.make ];then
100+
echo "target='.'" >> $GITHUB_OUTPUT
101+
echo "Listed test targets: "
102+
cat ya.make
103+
else
104+
echo "target=${{ inputs.build_target }}" >> $GITHUB_OUTPUT
105+
fi
97106
98107
- name: Run tests
99108
uses: ./.github/actions/test_ya
100109
if: ${{ inputs.run_tests == 'true' && (steps.build.outputs.success == 'true' || inputs.run_tests_if_build_fails == 'true') }}
101110
with:
102-
build_target: ${{ inputs.build_target }}
111+
build_target: ${{ steps.test_run_choice.outputs.target }}
103112
build_preset: ${{ inputs.build_preset }}
104113
test_size: ${{ inputs.test_size }}
105-
test_type: ${{ inputs.test_type }}
106114
testman_token: ${{ fromJSON( inputs.secs ).TESTMO_TOKEN }}
107115
testman_url: ${{ fromJSON( inputs.vars ).TESTMO_URL }}
108116
testman_project_id: ${{ fromJSON( inputs.vars ).TESTMO_PROJECT_ID }}
109-
bazel_remote_uri: ${{ fromJSON( inputs.vars ).REMOTE_CACHE_URL || '' }}
110-
bazel_remote_username: ${{ inputs.put_build_results_to_cache && fromJSON( inputs.secs ).REMOTE_CACHE_USERNAME || '' }}
111-
bazel_remote_password: ${{ inputs.put_build_results_to_cache && fromJSON( inputs.secs ).REMOTE_CACHE_PASSWORD || '' }}
112117
link_threads: ${{ inputs.link_threads }}
113118
test_threads: ${{ inputs.test_threads }}
114119

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: graph_compare
2+
description: Compare graphs between current and previous commits (merge commit base in case of a merge commit), and list affected tests in ya.make
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: original_ref
7+
id: oref
8+
shell: bash
9+
run: |
10+
echo "value=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
11+
- name: generate_ya_make
12+
shell: bash
13+
run: |
14+
./.github/scripts/graph_compare.sh ${{ steps.oref.outputs.value }}~1 ${{ steps.oref.outputs.value }}
15+
- name: restore_ref
16+
shell: bash
17+
run: |
18+
git checkout ${{ steps.oref.outputs.value }}

.github/actions/test_ya/action.yml

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
name: Run tests (ya make)
2-
description: Run tests using ya make
2+
description: Run test targets listed in repository root ya.make (to be created previously)
33
inputs:
44
build_target:
5-
required: false
6-
description: "build target"
7-
5+
required: true
86
build_preset:
97
required: true
108
default: "relwithdebinfo"
119
description: "relwithdebinfo, release-asan, release-tsan"
12-
1310
test_size:
1411
required: false
1512
default: "small,medium,large"
1613
description: "small or small-medium or all"
17-
18-
test_type:
19-
required: false
20-
default: "unittest,py3test,py2test,pytest"
21-
description: "run "
22-
2314
test_threads:
2415
required: false
25-
default: "28"
16+
default: "56"
2617
description: "Test threads count"
2718
link_threads:
2819
required: false
29-
default: "8"
20+
default: "12"
3021
description: "link threads count"
31-
3222
testman_token:
3323
required: false
3424
description: "test manager auth token"
@@ -38,15 +28,6 @@ inputs:
3828
testman_project_id:
3929
required: false
4030
description: "test manager project id"
41-
bazel_remote_uri:
42-
required: false
43-
description: "bazel-remote endpoint"
44-
bazel_remote_username:
45-
required: false
46-
description: "bazel-remote username"
47-
bazel_remote_password:
48-
required: false
49-
description: "bazel-remote password"
5031
runs:
5132
using: "composite"
5233
steps:
@@ -161,13 +142,12 @@ runs:
161142
shell: bash
162143
run: |
163144
readarray -d ',' -t test_size < <(printf "%s" "${{ inputs.test_size }}")
164-
readarray -d ',' -t test_type < <(printf "%s" "${{ inputs.test_type }}")
165145
166146
params=(
167-
-T -k -D'BUILD_LANGUAGES=CPP PY3 PY2 GO'
168-
${test_size[@]/#/--test-size=} ${test_type[@]/#/--test-type=}
147+
-T -k
148+
${test_size[@]/#/--test-size=}
169149
--cache-size 512G --do-not-output-stderrs
170-
--stat --canonization-backend=ydb-canondata.storage.yandexcloud.net
150+
--stat
171151
--test-threads "${{ inputs.test_threads }}" --link-threads "${{ inputs.link_threads }}"
172152
)
173153
@@ -203,36 +183,14 @@ runs:
203183
;;
204184
esac
205185
206-
if [ ! -z "${{ inputs.build_target }}" ]; then
207-
params+=(--target="${{ inputs.build_target }}")
208-
fi
209-
210-
if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
211-
params+=(--bazel-remote-store)
212-
params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
213-
fi
214-
215186
echo "::debug::get version"
216187
./ya --version
217188
218189
echo "Tests are running..." | .github/scripts/tests/comment-pr.py
219-
220-
if [ ! -z "${{ inputs.bazel_remote_username }}" ]; then
221-
echo "::debug::start tests"
222190
223-
./ya test "${params[@]}" \
224-
--bazel-remote-put --bazel-remote-username "${{ inputs.bazel_remote_username }}" --bazel-remote-password "${{ inputs.bazel_remote_password }}" -DCONSISTENT_DEBUG \
225-
--log-file "$LOG_DIR/ya_log_prewarm.txt" --evlog-file "$LOG_DIR/ya_evlog_prewarm.jsonl" \
226-
--dist-cache-evict-bins --cache-tests --no-dir-outputs --test-node-output-limit 1000000 --drop-graph-result-before-tests || (
227-
RC=$?
228-
echo "::debug::ya test RC=$RC"
229-
)
230-
fi
231-
232-
echo "::debug::save tests reports"
233-
./ya test "${params[@]}" \
191+
./ya test ${{ inputs.build_target }} "${params[@]}" \
234192
--stat --log-file "$LOG_DIR/ya_log.txt" --evlog-file "$LOG_DIR/ya_evlog.jsonl" -DCONSISTENT_DEBUG \
235-
--cache-tests --dist-cache-evict-bins --no-dir-outputs --test-node-output-limit 1000000 --drop-graph-result-before-tests \
193+
--no-dir-outputs \
236194
--junit "$JUNIT_REPORT_XML" --output "$OUT_DIR" || (
237195
RC=$?
238196
if [ $RC -ne 0 ]; then

.github/scripts/graph_compare.sh

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

.github/workflows/build_and_test_ya.yml

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ on:
2727
description: "run tests"
2828
test_threads:
2929
type: string
30-
default: 28
30+
default: 56
3131
description: "Test threads count"
3232
link_threads:
3333
type: string
34-
default: 8
34+
default: 12
3535
description: "link threads count"
3636
test_size:
3737
type: string
@@ -65,60 +65,18 @@ jobs:
6565
with:
6666
ref: ${{ inputs.commit_sha }}
6767

68-
- name: comment-build-start
69-
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
70-
shell: bash
71-
env:
72-
BUILD_PRESET: ${{ inputs.build_preset }}
73-
GITHUB_TOKEN: ${{ github.token }}
74-
run: |
75-
jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
76-
# tricky: we are searching job with name that contains build_preset
77-
check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
78-
79-
echo "Pre-commit [check]($check_url) for ${{ inputs.commit_sha }} has started." | .github/scripts/tests/comment-pr.py --rewrite
80-
81-
- name: Prepare s3cmd
82-
uses: ./.github/actions/s3cmd
68+
- name: Build and test
69+
uses: ./.github/actions/build_and_test_ya
8370
with:
84-
s3_bucket: ${{ vars.AWS_BUCKET }}
85-
s3_endpoint: ${{ vars.AWS_ENDPOINT }}
86-
s3_key_id: ${{ secrets.AWS_KEY_ID }}
87-
s3_key_secret: ${{ secrets.AWS_KEY_VALUE }}
88-
folder_prefix: ya-
8971
build_preset: ${{ inputs.build_preset }}
90-
91-
- name: Build
92-
uses: ./.github/actions/build_ya
93-
if: inputs.run_build
94-
with:
9572
build_target: ${{ inputs.build_target }}
96-
build_preset: ${{ inputs.build_preset }}
97-
bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
98-
bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
99-
bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
100-
link_threads: ${{ inputs.link_threads }}
101-
102-
- name: Run tests
103-
uses: ./.github/actions/test_ya
104-
if: inputs.run_tests
105-
with:
106-
build_target: ${{ inputs.build_target }}
107-
build_preset: ${{ inputs.build_preset }}
73+
increment: false
74+
run_tests: ${{ inputs.run_tests }}
10875
test_size: ${{ inputs.test_size }}
10976
test_type: ${{ inputs.test_type }}
110-
testman_token: ${{ secrets.TESTMO_TOKEN }}
111-
testman_url: ${{ vars.TESTMO_URL }}
112-
testman_project_id: ${{ vars.TESTMO_PROJECT_ID }}
113-
bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
114-
bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
115-
bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
116-
link_threads: ${{ inputs.link_threads }}
11777
test_threads: ${{ inputs.test_threads }}
118-
119-
- name: comment-if-cancel
120-
if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
121-
env:
122-
BUILD_PRESET: ${{ inputs.build_preset }}
123-
GITHUB_TOKEN: ${{ github.token }}
124-
run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black
78+
put_build_results_to_cache: ${{ inputs.put_build_results_to_cache }}
79+
secs: ${{ format('{{"TESTMO_TOKEN":"{0}","AWS_KEY_ID":"{1}","AWS_KEY_VALUE":"{2}","REMOTE_CACHE_USERNAME":"{3}","REMOTE_CACHE_PASSWORD":"{4}"}}',
80+
secrets.TESTMO_TOKEN, secrets.AWS_KEY_ID, secrets.AWS_KEY_VALUE, secrets.REMOTE_CACHE_USERNAME, secrets.REMOTE_CACHE_PASSWORD ) }}
81+
vars: ${{ format('{{"AWS_BUCKET":"{0}","AWS_ENDPOINT":"{1}","REMOTE_CACHE_URL":"{2}","TESTMO_URL":"{3}","TESTMO_PROJECT_ID":"{4}"}}',
82+
vars.AWS_BUCKET, vars.AWS_ENDPOINT, vars.REMOTE_CACHE_URL_YA, vars.TESTMO_URL, vars.TESTMO_PROJECT_ID ) }}

.github/workflows/build_and_test_ya_provisioned.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ on:
4545
description: "run tests"
4646
test_threads:
4747
type: string
48-
default: "28"
48+
default: "56"
4949
description: "Test threads count"
5050
link_threads:
5151
type: string
52-
default: "8"
52+
default: "12"
5353
description: "link threads count"
5454
runner_label:
5555
type: string
@@ -80,11 +80,11 @@ on:
8080
default: true
8181
test_threads:
8282
type: string
83-
default: 28
83+
default: 56
8484
description: "Test threads count"
8585
link_threads:
8686
type: string
87-
default: 8
87+
default: 12
8888
description: "link threads count"
8989
runner_label:
9090
type: string

.github/workflows/postcommit_asan.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,25 @@ on:
1313
jobs:
1414
build_and_test:
1515
if: ${{vars.CHECKS_SWITCH != '' && fromJSON(vars.CHECKS_SWITCH).postcommit_asan == true}}
16+
runs-on: [ self-hosted, auto-provisioned, build-preset-release-asan ]
1617
name: Build and test release-asan
17-
uses: ./.github/workflows/build_and_test_ya_provisioned.yml
18-
with:
19-
build_preset: "release-asan"
20-
build_target: "ydb/"
21-
test_size: "small,medium"
22-
test_type: "unittest,py3test,py2test,pytest"
23-
test_threads: 52
24-
runner_label: auto-provisioned
25-
put_build_results_to_cache: true
26-
secrets: inherit
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 2
23+
- name: Build and test
24+
uses: ./.github/actions/build_and_test_ya
25+
with:
26+
build_preset: "release-asan"
27+
build_target: "ydb/"
28+
increment: true
29+
run_tests: true
30+
test_size: "small,medium"
31+
test_type: "unittest,py3test,py2test,pytest"
32+
test_threads: 52
33+
put_build_results_to_cache: true
34+
secs: ${{ format('{{"TESTMO_TOKEN":"{0}","AWS_KEY_ID":"{1}","AWS_KEY_VALUE":"{2}","REMOTE_CACHE_USERNAME":"{3}","REMOTE_CACHE_PASSWORD":"{4}"}}',
35+
secrets.TESTMO_TOKEN, secrets.AWS_KEY_ID, secrets.AWS_KEY_VALUE, secrets.REMOTE_CACHE_USERNAME, secrets.REMOTE_CACHE_PASSWORD ) }}
36+
vars: ${{ format('{{"AWS_BUCKET":"{0}","AWS_ENDPOINT":"{1}","REMOTE_CACHE_URL":"{2}","TESTMO_URL":"{3}","TESTMO_PROJECT_ID":"{4}"}}',
37+
vars.AWS_BUCKET, vars.AWS_ENDPOINT, vars.REMOTE_CACHE_URL_YA, vars.TESTMO_URL, vars.TESTMO_PROJECT_ID ) }}

0 commit comments

Comments
 (0)