action.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. name: Run build and tests (ya make)
  2. description: Run test targets listed in repository root ya.make (to be created previously)
  3. inputs:
  4. build_target:
  5. required: true
  6. build_preset:
  7. required: true
  8. default: "relwithdebinfo"
  9. description: "relwithdebinfo, release-asan, release-tsan"
  10. test_type:
  11. required: false
  12. type: string
  13. default: ""
  14. description: "run only specific test types (or all by default)"
  15. test_size:
  16. required: false
  17. default: "small,medium,large"
  18. description: "small or small-medium or all"
  19. test_threads:
  20. required: false
  21. default: "56"
  22. description: "Test threads count"
  23. link_threads:
  24. required: false
  25. default: "12"
  26. description: "link threads count"
  27. additional_ya_make_args:
  28. type: string
  29. default: ""
  30. testman_token:
  31. required: false
  32. description: "test manager auth token"
  33. testman_url:
  34. required: false
  35. description: "test manager endpoint"
  36. testman_project_id:
  37. required: false
  38. description: "test manager project id"
  39. increment:
  40. type: boolean
  41. required: true
  42. 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.
  43. put_build_results_to_cache:
  44. required: false
  45. default: "true"
  46. bazel_remote_uri:
  47. required: false
  48. description: "bazel-remote endpoint"
  49. bazel_remote_username:
  50. required: false
  51. description: "bazel-remote username"
  52. bazel_remote_password:
  53. required: false
  54. description: "bazel-remote password"
  55. run_tests:
  56. type: boolean
  57. default: true
  58. description: "run tests"
  59. test_retry_count:
  60. type: string
  61. default: ""
  62. description: "how many times to retry failed tests"
  63. outputs:
  64. success:
  65. value: ${{ steps.build.outputs.status }}
  66. description: "build success"
  67. runs:
  68. using: "composite"
  69. steps:
  70. - name: comment-build-start
  71. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  72. shell: bash
  73. env:
  74. BUILD_PRESET: ${{ inputs.build_preset }}
  75. GITHUB_TOKEN: ${{ github.token }}
  76. run: |
  77. jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
  78. # tricky: we are searching job with name that contains build_preset
  79. check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
  80. platform_name="$(echo "$(uname -s)-$(uname -p)" | tr '[:upper:]' '[:lower:]')-$BUILD_PRESET"
  81. echo "Pre-commit [check]($check_url) **$platform_name** for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
  82. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  83. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  84. -d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}'
  85. if [[ "${{inputs.run_tests}}" == "true" ]]; then
  86. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  87. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  88. -d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}'
  89. fi
  90. - name: Clean ya cache
  91. shell: bash
  92. run: rm -rf ~/.ya
  93. - name: Init
  94. id: init
  95. shell: bash
  96. run: |
  97. set -x
  98. echo "$(pwd)/ydb/ci/scripts" >> $GITHUB_PATH
  99. export TMP_DIR=$(pwd)/tmp
  100. rm -rf $TMP_DIR
  101. mkdir -p $TMP_DIR
  102. echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
  103. # The whole dir will be uploaded to s3 with public (=wild internet) ACL
  104. export PUBLIC_DIR=$TMP_DIR/results
  105. echo "PUBLIC_DIR=$PUBLIC_DIR" >> $GITHUB_ENV
  106. export PUBLIC_DIR_URL=$S3_URL_PREFIX
  107. echo "PUBLIC_DIR_URL=$PUBLIC_DIR_URL" >> $GITHUB_ENV
  108. mkdir -p $PUBLIC_DIR
  109. echo "LAST_JUNIT_REPORT_XML=$PUBLIC_DIR/last_junit.xml" >> $GITHUB_ENV
  110. export TESTMO_URL=${{ inputs.testman_url }}
  111. echo "TESTMO_URL=$TESTMO_URL" >> $GITHUB_ENV
  112. echo "SUMMARY_LINKS=$PUBLIC_DIR/summary_links.txt" >> $GITHUB_ENV
  113. echo "BUILD_PRESET=${{ inputs.build_preset }}" >> $GITHUB_ENV
  114. python3 -m pip install ydb ydb[yc] codeowners humanize junitparser
  115. if [ ${{ inputs.testman_token }} ]; then
  116. TESTMO_PROXY_ADDR=127.0.0.1:8888
  117. openssl req -x509 -newkey rsa:2048 \
  118. -keyout $TMP_DIR/key.pem -out $TMP_DIR/cert.pem \
  119. -sha256 -days 1 -nodes -subj "/CN=127.0.0.1"
  120. TESTMO_TOKEN=${{ inputs.testman_token }} ./ydb/ci/testmo-proxy/testmo-proxy.py -l $TESTMO_PROXY_ADDR \
  121. --cert-file "$TMP_DIR/cert.pem" \
  122. --cert-key "$TMP_DIR/key.pem" \
  123. --target-timeout 3,60 \
  124. --max-request-time 200 \
  125. "$TESTMO_URL" > $PUBLIC_DIR/testmo_proxy_log.txt 2>&1 &
  126. TESTMO_PROXY_PID=$!
  127. echo "TESTMO_PROXY_ADDR=$TESTMO_PROXY_ADDR" >> $GITHUB_ENV
  128. echo "TESTMO_PROXY_PID=$TESTMO_PROXY_PID" >> $GITHUB_ENV
  129. # testmo rejects self-signed cert without this setting
  130. echo "NODE_TLS_REJECT_UNAUTHORIZED=0" >> $GITHUB_ENV
  131. fi
  132. - name: Setup cache
  133. shell: bash
  134. run: |
  135. export BAZEL_REMOTE_PASSWORD_FILE=$(mktemp)
  136. echo -n "${{ inputs.bazel_remote_password }}" > $BAZEL_REMOTE_PASSWORD_FILE
  137. echo "BAZEL_REMOTE_PASSWORD_FILE=$BAZEL_REMOTE_PASSWORD_FILE" >> $GITHUB_ENV
  138. - name: ya build and test
  139. id: build
  140. shell: bash
  141. run: |
  142. set -ex
  143. echo "Artifacts will be uploaded [here](${PUBLIC_DIR_URL}/index.html)" | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  144. ORIGINAL_HEAD=$(git rev-parse HEAD)
  145. if [ "${{ inputs.increment }}" = "true" ]; then
  146. GRAPH_COMPARE_OUTPUT="$PUBLIC_DIR/graph_compare_log.txt"
  147. GRAPH_COMPARE_OUTPUT_URL="$PUBLIC_DIR_URL/graph_compare_log.txt"
  148. set +e
  149. ./.github/scripts/graph_compare.sh $ORIGINAL_HEAD~1 $ORIGINAL_HEAD |& tee $GRAPH_COMPARE_OUTPUT
  150. RC=${PIPESTATUS[0]}
  151. set -e
  152. if [ $RC -ne 0 ]; then
  153. echo "graph_compare.sh returned $RC, build failed"
  154. echo "status=failed" >> $GITHUB_OUTPUT
  155. BUILD_FAILED=1
  156. echo "Graph compare failed, see the [logs]($GRAPH_COMPARE_OUTPUT_URL)." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  157. exit $RC
  158. fi
  159. git checkout $ORIGINAL_HEAD
  160. YA_MAKE_TARGET=.
  161. else
  162. YA_MAKE_TARGET="${{ inputs.build_target }}"
  163. fi
  164. readarray -d ',' -t test_size < <(printf "%s" "${{ inputs.test_size }}")
  165. readarray -d ',' -t test_type < <(printf "%s" "${{ inputs.test_type }}")
  166. params=(
  167. -T
  168. ${test_size[@]/#/--test-size=} ${test_type[@]/#/--test-type=}
  169. --stat
  170. --test-threads "${{ inputs.test_threads }}" --link-threads "${{ inputs.link_threads }}"
  171. -DUSE_EAT_MY_DATA
  172. )
  173. TEST_RETRY_COUNT=${{ inputs.test_retry_count }}
  174. IS_TEST_RESULT_IGNORED=0
  175. case "$BUILD_PRESET" in
  176. debug)
  177. params+=(--build "debug")
  178. ;;
  179. relwithdebinfo)
  180. params+=(--build "relwithdebinfo")
  181. ;;
  182. release)
  183. params+=(--build "release")
  184. ;;
  185. release-asan)
  186. params+=(
  187. --build "release" --sanitize="address"
  188. )
  189. IS_TEST_RESULT_IGNORED=1
  190. ;;
  191. release-tsan)
  192. params+=(
  193. --build "release" --sanitize="thread"
  194. )
  195. if [ $TEST_RETRY_COUNT -z ]; then
  196. TEST_RETRY_COUNT=1
  197. fi
  198. IS_TEST_RESULT_IGNORED=1
  199. ;;
  200. release-msan)
  201. params+=(
  202. --build "release" --sanitize="memory"
  203. )
  204. if [ $TEST_RETRY_COUNT -z ]; then
  205. TEST_RETRY_COUNT=1
  206. fi
  207. IS_TEST_RESULT_IGNORED=1
  208. ;;
  209. *)
  210. echo "Invalid preset: $BUILD_PRESET"
  211. exit 1
  212. ;;
  213. esac
  214. echo "IS_TEST_RESULT_IGNORED=$IS_TEST_RESULT_IGNORED" >> $GITHUB_ENV
  215. if [ $TEST_RETRY_COUNT -z ]; then
  216. # default is 3 for ordinary build and 1 for sanitizer builds
  217. TEST_RETRY_COUNT=3
  218. fi
  219. if [ ! -z "${{ inputs.additional_ya_make_args }}" ]; then
  220. params+=(${{ inputs.additional_ya_make_args }})
  221. fi
  222. if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
  223. params+=(--bazel-remote-store)
  224. params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
  225. fi
  226. if [ "${{ inputs.put_build_results_to_cache }}" = "true" ]; then
  227. params+=(--bazel-remote-username "${{ inputs.bazel_remote_username }}")
  228. params+=(--bazel-remote-password-file "$BAZEL_REMOTE_PASSWORD_FILE")
  229. params+=(--bazel-remote-put --dist-cache-max-file-size=209715200)
  230. fi
  231. if [ true = ${{ inputs.run_tests }} ]; then
  232. params+=(-A)
  233. params+=(--retest)
  234. fi
  235. params+=(
  236. --stat -DCONSISTENT_DEBUG --no-dir-outputs
  237. --test-failure-code 0 --build-all
  238. --cache-size 2TB --force-build-depends
  239. )
  240. TESTMO_BRANCH_TAG="$GITHUB_REF_NAME"
  241. TESTMO_ARCH="${{ runner.arch == 'X64' && 'x86-64' || runner.arch == 'ARM64' && 'arm64' || 'unknown' }}"
  242. TESTMO_PR_NUMBER=${{ github.event.number }}
  243. case "$BUILD_PRESET" in
  244. relwithdebinfo)
  245. TESTMO_SOURCE="ya-${TESTMO_ARCH}"
  246. ;;
  247. debug)
  248. TESTMO_SOURCE="ya-${TESTMO_ARCH}-debug"
  249. ;;
  250. release*)
  251. TESTMO_SOURCE="ya-${TESTMO_ARCH}-${BUILD_PRESET/release-/}"
  252. ;;
  253. *)
  254. echo "Invalid preset: $BUILD_PRESET"
  255. exit 1
  256. ;;
  257. esac
  258. echo "::debug::get version"
  259. ./ya --version
  260. YA_MAKE_OUT_DIR=$TMP_DIR/out
  261. YA_MAKE_OUTPUT="$PUBLIC_DIR/ya_make_output.txt"
  262. YA_MAKE_OUTPUT_URL="$PUBLIC_DIR_URL/ya_make_output.txt"
  263. echo "20 [Ya make output]($YA_MAKE_OUTPUT_URL)" >> $SUMMARY_LINKS
  264. BUILD_FAILED=0
  265. for RETRY in $(seq 1 $TEST_RETRY_COUNT)
  266. do
  267. case $GITHUB_EVENT_NAME in
  268. workflow_dispatch)
  269. TESTMO_RUN_NAME="${{ github.run_id }} manual"
  270. TESTMO_EXTRA_TAG="manual"
  271. ;;
  272. pull_request | pull_request_target)
  273. TESTMO_RUN_NAME="${{ github.run_id }} PR #${TESTMO_PR_NUMBER}"
  274. TESTMO_EXTRA_TAG="pr"
  275. TESTMO_BRANCH_TAG=""
  276. ;;
  277. schedule)
  278. TESTMO_RUN_NAME="${{ github.run_id }} schedule"
  279. TESTMO_EXTRA_TAG="schedule"
  280. ;;
  281. push)
  282. TESTMO_RUN_NAME="${{ github.run_id }} POST"
  283. TESTMO_EXTRA_TAG="post-commit"
  284. ;;
  285. *)
  286. TESTMO_RUN_NAME="${{ github.run_id }}"
  287. TESTMO_EXTRA_TAG=""
  288. ;;
  289. esac
  290. echo "TESTMO_RUN_NAME=$TESTMO_RUN_NAME" >> $GITHUB_ENV
  291. if [ $RETRY != 1 ]; then
  292. IS_RETRY=1
  293. TESTMO_RUN_NAME="$TESTMO_RUN_NAME A$RETRY"
  294. else
  295. IS_RETRY=0
  296. fi
  297. CURRENT_PUBLIC_DIR_RELATIVE=try_$RETRY
  298. # Can be used in tests in which you want to publish the results in s3 for each retry separately
  299. export CURRENT_PUBLIC_DIR=$PUBLIC_DIR/$CURRENT_PUBLIC_DIR_RELATIVE
  300. export CURRENT_PUBLIC_DIR_URL=$PUBLIC_DIR_URL/$CURRENT_PUBLIC_DIR_RELATIVE
  301. mkdir $CURRENT_PUBLIC_DIR
  302. if [ ${{ inputs.testman_token }} ]; then
  303. # inititalize testmo session
  304. TESTMO_RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
  305. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-link --name build --url "$TESTMO_RUN_URL" --resources $CURRENT_PUBLIC_DIR/testmo.json
  306. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-field --name git-sha --type string --value "${GITHUB_SHA:0:7}" --resources $CURRENT_PUBLIC_DIR/testmo.json
  307. TESTMO_RUN_ID=$(
  308. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
  309. --name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources $CURRENT_PUBLIC_DIR/testmo.json \
  310. --tags "$TESTMO_BRANCH_TAG" --tags "$TESTMO_EXTRA_TAG"
  311. )
  312. echo "runid=${TESTMO_RUN_ID}" >> $GITHUB_OUTPUT
  313. TESTMO_HISTORY_URL="${TESTMO_URL}/automation/runs/view/${TESTMO_RUN_ID}"
  314. # Replace test history link
  315. cat $SUMMARY_LINKS | (grep -v "Test history" || true) > $TMP_DIR/tmp_summary
  316. mv $TMP_DIR/tmp_summary $SUMMARY_LINKS
  317. echo "10 [Test history](${TESTMO_HISTORY_URL})" >> $SUMMARY_LINKS
  318. fi
  319. CURRENT_MESSAGE="ya make is running..."
  320. if [ $IS_RETRY = 0 ]; then
  321. CURRENT_MESSAGE="$CURRENT_MESSAGE"
  322. RERUN_FAILED_OPT=""
  323. else
  324. CURRENT_MESSAGE="$CURRENT_MESSAGE (failed tests rerun, try $RETRY)"
  325. RERUN_FAILED_OPT="-X"
  326. fi
  327. echo $CURRENT_MESSAGE | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  328. CURRENT_JUNIT_XML_PATH=$CURRENT_PUBLIC_DIR/junit.xml
  329. CURRENT_REPORT=$CURRENT_PUBLIC_DIR/report.json
  330. set +e
  331. (./ya make $YA_MAKE_TARGET "${params[@]}" \
  332. $RERUN_FAILED_OPT --log-file "$PUBLIC_DIR/ya_log.txt" \
  333. --evlog-file "$CURRENT_PUBLIC_DIR/ya_evlog.jsonl" \
  334. --junit "$CURRENT_JUNIT_XML_PATH" --build-results-report "$CURRENT_REPORT" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& cat >> $YA_MAKE_OUTPUT
  335. set -e
  336. RC=`cat exit_code`
  337. .github/scripts/tests/report_analyzer.py --report_file "$CURRENT_REPORT" --summary_file $CURRENT_PUBLIC_DIR/summary_report.txt || true
  338. # convert to chromium trace
  339. # seems analyze-make don't have simple "output" parameter, so change cwd
  340. ya_dir=$(pwd)
  341. (cd $CURRENT_PUBLIC_DIR && $ya_dir/ya analyze-make timeline --evlog ya_evlog.jsonl)
  342. # generate test_bloat
  343. ./ydb/ci/build_bloat/test_bloat.py --junit $CURRENT_JUNIT_XML_PATH --output_dir $CURRENT_PUBLIC_DIR/test_bloat || true
  344. echo "30 [Test bloat](${CURRENT_PUBLIC_DIR_URL}/test_bloat/tree_map.html)" >> $SUMMARY_LINKS
  345. if [ $RC -ne 0 ]; then
  346. echo "ya make returned $RC, build failed"
  347. echo "status=failed" >> $GITHUB_OUTPUT
  348. BUILD_FAILED=1
  349. # sed is to remove richness (tags like '[[rst]]')
  350. (( \
  351. cat $CURRENT_REPORT \
  352. | jq -r '.results[] | select((.status == "FAILED") and (.error_type == "REGULAR") and (.type = "build")) | "path: " + .path + "\n\n" + ."rich-snippet" + "\n\n\n"' \
  353. | sed 's/\[\[[^]]*]\]//g' \
  354. ) || true) > $CURRENT_PUBLIC_DIR/fail_summary.txt
  355. echo "Build failed, see the [logs]($YA_MAKE_OUTPUT_URL). Also see [fail summary]($CURRENT_PUBLIC_DIR_URL/fail_summary.txt)" | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  356. break
  357. fi
  358. # fix junit files (add links, logs etc)
  359. # archive unitest reports (orig)
  360. gzip -c $CURRENT_JUNIT_XML_PATH > $CURRENT_PUBLIC_DIR/orig_junit.xml.gz
  361. # postprocess junit report
  362. .github/scripts/tests/transform_ya_junit.py -i \
  363. -m .github/config/muted_ya.txt \
  364. --ya_out "$YA_MAKE_OUT_DIR" \
  365. --public_dir "$PUBLIC_DIR" \
  366. --public_dir_url "$PUBLIC_DIR_URL" \
  367. --log_out_dir "$CURRENT_PUBLIC_DIR_RELATIVE/artifacts/logs/" \
  368. --test_stuff_out "$CURRENT_PUBLIC_DIR_RELATIVE/test_artifacts/" \
  369. "$CURRENT_JUNIT_XML_PATH"
  370. cp $CURRENT_JUNIT_XML_PATH $LAST_JUNIT_REPORT_XML
  371. TESTS_RESULT=0
  372. .github/scripts/tests/fail-checker.py "$CURRENT_JUNIT_XML_PATH" --output_path $CURRENT_PUBLIC_DIR/failed_count.txt || TESTS_RESULT=$?
  373. FAILED_TESTS_COUNT=$(cat $CURRENT_PUBLIC_DIR/failed_count.txt)
  374. IS_LAST_RETRY=0
  375. if [ $TESTS_RESULT = 0 ] || [ $RETRY = $TEST_RETRY_COUNT ]; then
  376. IS_LAST_RETRY=1
  377. fi
  378. if [ $FAILED_TESTS_COUNT -gt 500 ]; then
  379. IS_LAST_RETRY=1
  380. TOO_MANY_FAILED="Too many tests failed, NOT going to retry"
  381. echo $TOO_MANY_FAILED | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  382. fi
  383. if [ "${{ inputs.run_tests }}" = "true" ]; then
  384. GITHUB_TOKEN=${{ github.token }} .github/scripts/tests/generate-summary.py \
  385. --summary_links "$SUMMARY_LINKS" \
  386. --public_dir "$PUBLIC_DIR" \
  387. --public_dir_url "$PUBLIC_DIR_URL" \
  388. --build_preset "$BUILD_PRESET" \
  389. --status_report_file statusrep.txt \
  390. --is_retry $IS_RETRY \
  391. --is_last_retry $IS_LAST_RETRY \
  392. --is_test_result_ignored $IS_TEST_RESULT_IGNORED \
  393. --comment_color_file summary_color.txt \
  394. --comment_text_file summary_text.txt \
  395. "Tests" $CURRENT_PUBLIC_DIR/ya-test.html "$CURRENT_JUNIT_XML_PATH"
  396. fi
  397. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  398. if [ "${{ inputs.run_tests }}" = "true" ]; then
  399. cat summary_text.txt | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color `cat summary_color.txt`
  400. fi
  401. # upload tests results to YDB
  402. ydb_upload_run_name="${TESTMO_RUN_NAME// /"_"}"
  403. result=`.github/scripts/analytics/upload_tests_results.py --test-results-file ${CURRENT_JUNIT_XML_PATH} --run-timestamp $(date +%s) --commit $(git rev-parse HEAD) --build-type ${BUILD_PRESET} --pull $ydb_upload_run_name --job-name "${{ github.workflow }}" --job-id "${{ github.run_id }}" --branch ${GITHUB_REF_NAME}`
  404. if [ ${{ inputs.testman_token }} ]; then
  405. # finish testme session
  406. # split large junit_report
  407. export TESTMO_JUNIT_REPORT_PARTS=$TMP_DIR/try_$RETRY/junit-split
  408. mkdir -p $TESTMO_JUNIT_REPORT_PARTS
  409. .github/scripts/tests/split-junit.py -o "$TESTMO_JUNIT_REPORT_PARTS" "$CURRENT_JUNIT_XML_PATH"
  410. # archive unitest reports (transformed)
  411. tar -C $TESTMO_JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $TESTMO_JUNIT_REPORT_PARTS)
  412. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:submit-thread \
  413. --instance "https://$TESTMO_PROXY_ADDR" --run-id "$TESTMO_RUN_ID" \
  414. --results "$TESTMO_JUNIT_REPORT_PARTS/*.xml"
  415. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
  416. echo "runid=" >> $GITHUB_OUTPUT
  417. fi
  418. if [ $IS_LAST_RETRY = 1 ]; then
  419. break
  420. fi
  421. done;
  422. if [ $BUILD_FAILED = 0 ]; then
  423. echo "status=true" >> $GITHUB_OUTPUT
  424. echo "Build successful." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color green
  425. fi
  426. - name: comment-build-status
  427. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  428. shell: bash
  429. env:
  430. GITHUB_TOKEN: ${{ github.token }}
  431. run: |
  432. set -x
  433. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  434. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  435. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  436. -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
  437. else
  438. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  439. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  440. -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
  441. fi
  442. - name: Clean up unfinished testmo sessions
  443. if: always()
  444. shell: bash
  445. run: |
  446. if [ ${{ steps.build.outputs.runid }} ]; then
  447. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
  448. fi
  449. if [ ${{ inputs.testman_token }} ]; then
  450. kill $TESTMO_PROXY_PID
  451. fi
  452. - name: analyze tests results
  453. shell: bash
  454. env:
  455. GITHUB_TOKEN: ${{ github.token }}
  456. run: |
  457. set -x
  458. if [ true = ${{ inputs.run_tests }} ]; then
  459. teststatus=$(cat statusrep.txt)
  460. if [[ $teststatus == "success" ]]; then
  461. testmessage="The check has been completed successfully"
  462. else
  463. testmessage="The check has been failed"
  464. fi
  465. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  466. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  467. -d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}'
  468. if [[ $teststatus != "success" ]]; then
  469. echo "status=failed" >> $GITHUB_OUTPUT
  470. fi
  471. fi
  472. - name: check test results
  473. if: inputs.run_tests
  474. shell: bash
  475. run: |
  476. if [ $IS_TEST_RESULT_IGNORED == 0 ]; then
  477. .github/scripts/tests/fail-checker.py "$LAST_JUNIT_REPORT_XML"
  478. fi
  479. - name: show diff mute_ya.txt
  480. if: inputs.build_preset == 'relwithdebinfo' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  481. shell: bash
  482. continue-on-error: true
  483. env:
  484. GITHUB_TOKEN: ${{ github.token }}
  485. run: |
  486. ORIGINAL_HEAD=$(git rev-parse HEAD)
  487. get_file_diff_script=.github/scripts/tests/get_diff_lines_of_file.py
  488. file_to_check=.github/config/muted_ya.txt
  489. check_result=`$get_file_diff_script --base_sha $ORIGINAL_HEAD~1 --head_sha $ORIGINAL_HEAD --file_path $file_to_check`
  490. if [[ ${check_result} == *"not changed" ]];then
  491. echo file ${file_to_check} NOT changed
  492. else
  493. echo file ${file_to_check} changed
  494. .github/scripts/tests/get_muted_tests.py --output_folder "$PUBLIC_DIR/mute_info/" get_mute_diff --base_sha $ORIGINAL_HEAD~1 --head_sha $ORIGINAL_HEAD --job-id "${{ github.run_id }}" --branch "${GITHUB_REF_NAME}"
  495. FILE_PATH=$PUBLIC_DIR/mute_info/2_new_muted_tests.txt
  496. SEPARATOR=""
  497. if [ -f "$FILE_PATH" ]; then
  498. LINE_COUNT=$(wc -l < "$FILE_PATH")
  499. if [ "$LINE_COUNT" -gt 0 ]; then
  500. SEPARATOR=', '
  501. MESSAGE="Muted new $LINE_COUNT [tests](${PUBLIC_DIR_URL}/mute_info/2_new_muted_tests.txt)"
  502. fi
  503. fi
  504. FILE_PATH=$PUBLIC_DIR/mute_info/3_unmuted_tests.txt
  505. if [ -f "$FILE_PATH" ]; then
  506. LINE_COUNT_unmute=$(wc -l < "$FILE_PATH")
  507. if [ "$LINE_COUNT_unmute" -gt 0 ]; then
  508. MESSAGE="${MESSAGE}${SEPARATOR}Unmuted $LINE_COUNT_unmute [tests](${PUBLIC_DIR_URL}/mute_info/3_unmuted_tests.txt)"
  509. fi
  510. fi
  511. if [ -n "$MESSAGE" ]; then
  512. printf "$MESSAGE" | .github/scripts/tests/comment-pr.py --color orange
  513. fi
  514. fi
  515. - name: sync results to s3 and publish links
  516. if: always()
  517. shell: bash
  518. run: |
  519. set -x
  520. echo "::group::s3-sync"
  521. .github/scripts/Indexer/indexer.py -r "$PUBLIC_DIR/"
  522. echo "00 [Artifacts](${PUBLIC_DIR_URL}/index.html)" >> $SUMMARY_LINKS
  523. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  524. cat $SUMMARY_LINKS | python3 -c 'import sys; print(" | ".join([v for _, v in sorted([l.strip().split(" ", 1) for l in sys.stdin], key=lambda a: (int(a[0]), a))]))' >> $GITHUB_STEP_SUMMARY
  525. echo "::endgroup::"
  526. - name: show free space
  527. if: always()
  528. shell: bash
  529. run: df -h
  530. - name: build_stats
  531. shell: bash
  532. continue-on-error: true
  533. if: always()
  534. run: |
  535. set -x
  536. export build_preset="${{ inputs.build_preset }}"
  537. export commit_git_sha="$(git rev-parse HEAD)"
  538. python3 .github/scripts/send_build_stats.py
  539. - name: show_build_size_diff
  540. shell: bash
  541. continue-on-error: true
  542. if: always()
  543. env:
  544. GITHUB_TOKEN: ${{ github.token }}
  545. run: |
  546. set -x
  547. export build_preset="${{ inputs.build_preset }}"
  548. export branch_to_compare="$GITHUB_REF_NAME"
  549. export yellow_treshold=102400
  550. export red_treshold=2097152
  551. export commit_git_sha="$(git rev-parse HEAD)"
  552. get_sizes_comment_script=.github/scripts/get_build_diff.py
  553. comment_raw=`$get_sizes_comment_script`
  554. IFS=';;;'
  555. read -ra comment_arr <<< "$comment_raw"
  556. printf "$comment"
  557. if [[ ${comment_raw} != "Error"* ]]; then
  558. color=${comment_arr[0]}
  559. replace=$color";;;"
  560. comment=${comment_raw/$replace/""}
  561. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  562. else
  563. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  564. fi
  565. - name: comment-if-cancel
  566. shell: bash
  567. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  568. env:
  569. BUILD_PRESET: ${{ inputs.build_preset }}
  570. GITHUB_TOKEN: ${{ github.token }}
  571. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black