action.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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-clang14) # TODO: remove after removing from workflow
  186. params+=(--build "release")
  187. params+=(--target-platform="CLANG14-LINUX-X86_64")
  188. params+=(-DLLD_VERSION=16)
  189. params+=(-DSTRIP)
  190. ;;
  191. release-asan)
  192. params+=(
  193. --build "release" --sanitize="address"
  194. )
  195. if [ $TEST_RETRY_COUNT -z ]; then
  196. TEST_RETRY_COUNT=1
  197. fi
  198. IS_TEST_RESULT_IGNORED=1
  199. ;;
  200. release-tsan)
  201. params+=(
  202. --build "release" --sanitize="thread"
  203. )
  204. if [ $TEST_RETRY_COUNT -z ]; then
  205. TEST_RETRY_COUNT=1
  206. fi
  207. IS_TEST_RESULT_IGNORED=1
  208. ;;
  209. release-msan)
  210. params+=(
  211. --build "release" --sanitize="memory"
  212. )
  213. if [ $TEST_RETRY_COUNT -z ]; then
  214. TEST_RETRY_COUNT=1
  215. fi
  216. IS_TEST_RESULT_IGNORED=1
  217. ;;
  218. *)
  219. echo "Invalid preset: $BUILD_PRESET"
  220. exit 1
  221. ;;
  222. esac
  223. echo "IS_TEST_RESULT_IGNORED=$IS_TEST_RESULT_IGNORED" >> $GITHUB_ENV
  224. if [ $TEST_RETRY_COUNT -z ]; then
  225. # default is 3 for ordinary build and 1 for sanitizer builds
  226. TEST_RETRY_COUNT=3
  227. fi
  228. if [ ! -z "${{ inputs.additional_ya_make_args }}" ]; then
  229. params+=(${{ inputs.additional_ya_make_args }})
  230. fi
  231. if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
  232. params+=(--bazel-remote-store)
  233. params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
  234. fi
  235. if [ "${{ inputs.put_build_results_to_cache }}" = "true" ]; then
  236. params+=(--bazel-remote-username "${{ inputs.bazel_remote_username }}")
  237. params+=(--bazel-remote-password-file "$BAZEL_REMOTE_PASSWORD_FILE")
  238. params+=(--bazel-remote-put --dist-cache-max-file-size=209715200)
  239. fi
  240. if [ true = ${{ inputs.run_tests }} ]; then
  241. params+=(-A)
  242. params+=(--retest)
  243. fi
  244. params+=(
  245. --stat -DCONSISTENT_DEBUG --no-dir-outputs
  246. --test-failure-code 0 --build-all
  247. --cache-size 2TB --force-build-depends
  248. )
  249. TESTMO_BRANCH_TAG="$GITHUB_REF_NAME"
  250. TESTMO_ARCH="${{ runner.arch == 'X64' && 'x86-64' || runner.arch == 'ARM64' && 'arm64' || 'unknown' }}"
  251. TESTMO_PR_NUMBER=${{ github.event.number }}
  252. case "$BUILD_PRESET" in
  253. relwithdebinfo)
  254. TESTMO_SOURCE="ya-${TESTMO_ARCH}"
  255. ;;
  256. debug)
  257. TESTMO_SOURCE="ya-${TESTMO_ARCH}-debug"
  258. ;;
  259. release-*)
  260. TESTMO_SOURCE="ya-${TESTMO_ARCH}-${BUILD_PRESET/release-/}"
  261. ;;
  262. *)
  263. echo "Invalid preset: $BUILD_PRESET"
  264. exit 1
  265. ;;
  266. esac
  267. echo "::debug::get version"
  268. ./ya --version
  269. YA_MAKE_OUT_DIR=$TMP_DIR/out
  270. YA_MAKE_OUTPUT="$PUBLIC_DIR/ya_make_output.txt"
  271. YA_MAKE_OUTPUT_URL="$PUBLIC_DIR_URL/ya_make_output.txt"
  272. echo "20 [Ya make output]($YA_MAKE_OUTPUT_URL)" >> $SUMMARY_LINKS
  273. BUILD_FAILED=0
  274. for RETRY in $(seq 1 $TEST_RETRY_COUNT)
  275. do
  276. case $GITHUB_EVENT_NAME in
  277. workflow_dispatch)
  278. TESTMO_RUN_NAME="${{ github.run_id }} manual"
  279. TESTMO_EXTRA_TAG="manual"
  280. ;;
  281. pull_request | pull_request_target)
  282. TESTMO_RUN_NAME="${{ github.run_id }} PR #${TESTMO_PR_NUMBER}"
  283. TESTMO_EXTRA_TAG="pr"
  284. TESTMO_BRANCH_TAG=""
  285. ;;
  286. schedule)
  287. TESTMO_RUN_NAME="${{ github.run_id }} schedule"
  288. TESTMO_EXTRA_TAG="schedule"
  289. ;;
  290. push)
  291. TESTMO_RUN_NAME="${{ github.run_id }} POST"
  292. TESTMO_EXTRA_TAG="post-commit"
  293. ;;
  294. *)
  295. TESTMO_RUN_NAME="${{ github.run_id }}"
  296. TESTMO_EXTRA_TAG=""
  297. ;;
  298. esac
  299. echo "TESTMO_RUN_NAME=$TESTMO_RUN_NAME" >> $GITHUB_ENV
  300. if [ $RETRY != 1 ]; then
  301. IS_RETRY=1
  302. TESTMO_RUN_NAME="$TESTMO_RUN_NAME A$RETRY"
  303. else
  304. IS_RETRY=0
  305. fi
  306. CURRENT_PUBLIC_DIR_RELATIVE=try_$RETRY
  307. # Can be used in tests in which you want to publish the results in s3 for each retry separately
  308. export CURRENT_PUBLIC_DIR=$PUBLIC_DIR/$CURRENT_PUBLIC_DIR_RELATIVE
  309. export CURRENT_PUBLIC_DIR_URL=$PUBLIC_DIR_URL/$CURRENT_PUBLIC_DIR_RELATIVE
  310. mkdir $CURRENT_PUBLIC_DIR
  311. if [ ${{ inputs.testman_token }} ]; then
  312. # inititalize testmo session
  313. TESTMO_RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
  314. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-link --name build --url "$TESTMO_RUN_URL" --resources $CURRENT_PUBLIC_DIR/testmo.json
  315. 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
  316. TESTMO_RUN_ID=$(
  317. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
  318. --name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources $CURRENT_PUBLIC_DIR/testmo.json \
  319. --tags "$TESTMO_BRANCH_TAG" --tags "$TESTMO_EXTRA_TAG"
  320. )
  321. echo "runid=${TESTMO_RUN_ID}" >> $GITHUB_OUTPUT
  322. TESTMO_HISTORY_URL="${TESTMO_URL}/automation/runs/view/${TESTMO_RUN_ID}"
  323. # Replace test history link
  324. cat $SUMMARY_LINKS | (grep -v "Test history" || true) > $TMP_DIR/tmp_summary
  325. mv $TMP_DIR/tmp_summary $SUMMARY_LINKS
  326. echo "10 [Test history](${TESTMO_HISTORY_URL})" >> $SUMMARY_LINKS
  327. fi
  328. CURRENT_MESSAGE="ya make is running..."
  329. if [ $IS_RETRY = 0 ]; then
  330. CURRENT_MESSAGE="$CURRENT_MESSAGE"
  331. RERUN_FAILED_OPT=""
  332. else
  333. CURRENT_MESSAGE="$CURRENT_MESSAGE (failed tests rerun, try $RETRY)"
  334. RERUN_FAILED_OPT="-X"
  335. fi
  336. echo $CURRENT_MESSAGE | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  337. CURRENT_JUNIT_XML_PATH=$CURRENT_PUBLIC_DIR/junit.xml
  338. CURRENT_REPORT=$CURRENT_PUBLIC_DIR/report.json
  339. set +e
  340. (./ya make $YA_MAKE_TARGET "${params[@]}" \
  341. $RERUN_FAILED_OPT --log-file "$PUBLIC_DIR/ya_log.txt" \
  342. --evlog-file "$CURRENT_PUBLIC_DIR/ya_evlog.jsonl" \
  343. --junit "$CURRENT_JUNIT_XML_PATH" --build-results-report "$CURRENT_REPORT" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& cat >> $YA_MAKE_OUTPUT
  344. set -e
  345. RC=`cat exit_code`
  346. .github/scripts/tests/report_analyzer.py --report_file "$CURRENT_REPORT" --summary_file $CURRENT_PUBLIC_DIR/summary_report.txt || true
  347. # convert to chromium trace
  348. # seems analyze-make don't have simple "output" parameter, so change cwd
  349. ya_dir=$(pwd)
  350. (cd $CURRENT_PUBLIC_DIR && $ya_dir/ya analyze-make timeline --evlog ya_evlog.jsonl)
  351. # generate test_bloat
  352. ./ydb/ci/build_bloat/test_bloat.py --junit $CURRENT_JUNIT_XML_PATH --output_dir $CURRENT_PUBLIC_DIR/test_bloat || true
  353. echo "30 [Test bloat](${CURRENT_PUBLIC_DIR_URL}/test_bloat/tree_map.html)" >> $SUMMARY_LINKS
  354. if [ $RC -ne 0 ]; then
  355. echo "ya make returned $RC, build failed"
  356. echo "status=failed" >> $GITHUB_OUTPUT
  357. BUILD_FAILED=1
  358. # sed is to remove richness (tags like '[[rst]]')
  359. (( \
  360. cat $CURRENT_REPORT \
  361. | jq -r '.results[] | select((.status == "FAILED") and (.error_type == "REGULAR") and (.type = "build")) | "path: " + .path + "\n\n" + ."rich-snippet" + "\n\n\n"' \
  362. | sed 's/\[\[[^]]*]\]//g' \
  363. ) || true) > $CURRENT_PUBLIC_DIR/fail_summary.txt
  364. 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
  365. break
  366. fi
  367. # fix junit files (add links, logs etc)
  368. # archive unitest reports (orig)
  369. gzip -c $CURRENT_JUNIT_XML_PATH > $CURRENT_PUBLIC_DIR/orig_junit.xml.gz
  370. # postprocess junit report
  371. .github/scripts/tests/transform_ya_junit.py -i \
  372. -m .github/config/muted_ya.txt \
  373. --ya_out "$YA_MAKE_OUT_DIR" \
  374. --public_dir "$PUBLIC_DIR" \
  375. --public_dir_url "$PUBLIC_DIR_URL" \
  376. --log_out_dir "$CURRENT_PUBLIC_DIR_RELATIVE/artifacts/logs/" \
  377. --test_stuff_out "$CURRENT_PUBLIC_DIR_RELATIVE/test_artifacts/" \
  378. "$CURRENT_JUNIT_XML_PATH"
  379. cp $CURRENT_JUNIT_XML_PATH $LAST_JUNIT_REPORT_XML
  380. TESTS_RESULT=0
  381. .github/scripts/tests/fail-checker.py "$CURRENT_JUNIT_XML_PATH" --output_path $CURRENT_PUBLIC_DIR/failed_count.txt || TESTS_RESULT=$?
  382. FAILED_TESTS_COUNT=$(cat $CURRENT_PUBLIC_DIR/failed_count.txt)
  383. IS_LAST_RETRY=0
  384. if [ $TESTS_RESULT = 0 ] || [ $RETRY = $TEST_RETRY_COUNT ]; then
  385. IS_LAST_RETRY=1
  386. fi
  387. if [ $FAILED_TESTS_COUNT -gt 500 ]; then
  388. IS_LAST_RETRY=1
  389. TOO_MANY_FAILED="Too many tests failed, NOT going to retry"
  390. echo $TOO_MANY_FAILED | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  391. fi
  392. if [ "${{ inputs.run_tests }}" = "true" ]; then
  393. GITHUB_TOKEN=${{ github.token }} .github/scripts/tests/generate-summary.py \
  394. --summary_links "$SUMMARY_LINKS" \
  395. --public_dir "$PUBLIC_DIR" \
  396. --public_dir_url "$PUBLIC_DIR_URL" \
  397. --build_preset "$BUILD_PRESET" \
  398. --status_report_file statusrep.txt \
  399. --is_retry $IS_RETRY \
  400. --is_last_retry $IS_LAST_RETRY \
  401. --is_test_result_ignored $IS_TEST_RESULT_IGNORED \
  402. --comment_color_file summary_color.txt \
  403. --comment_text_file summary_text.txt \
  404. "Tests" $CURRENT_PUBLIC_DIR/ya-test.html "$CURRENT_JUNIT_XML_PATH"
  405. fi
  406. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  407. if [ "${{ inputs.run_tests }}" = "true" ]; then
  408. cat summary_text.txt | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color `cat summary_color.txt`
  409. fi
  410. # upload tests results to YDB
  411. ydb_upload_run_name="${TESTMO_RUN_NAME// /"_"}"
  412. 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}`
  413. if [ ${{ inputs.testman_token }} ]; then
  414. # finish testme session
  415. # split large junit_report
  416. export TESTMO_JUNIT_REPORT_PARTS=$TMP_DIR/try_$RETRY/junit-split
  417. mkdir -p $TESTMO_JUNIT_REPORT_PARTS
  418. .github/scripts/tests/split-junit.py -o "$TESTMO_JUNIT_REPORT_PARTS" "$CURRENT_JUNIT_XML_PATH"
  419. # archive unitest reports (transformed)
  420. tar -C $TESTMO_JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $TESTMO_JUNIT_REPORT_PARTS)
  421. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:submit-thread \
  422. --instance "https://$TESTMO_PROXY_ADDR" --run-id "$TESTMO_RUN_ID" \
  423. --results "$TESTMO_JUNIT_REPORT_PARTS/*.xml"
  424. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
  425. echo "runid=" >> $GITHUB_OUTPUT
  426. fi
  427. if [ $IS_LAST_RETRY = 1 ]; then
  428. break
  429. fi
  430. done;
  431. if [ $BUILD_FAILED = 0 ]; then
  432. echo "status=true" >> $GITHUB_OUTPUT
  433. echo "Build successful." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color green
  434. fi
  435. - name: comment-build-status
  436. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  437. shell: bash
  438. env:
  439. GITHUB_TOKEN: ${{ github.token }}
  440. run: |
  441. set -x
  442. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  443. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  444. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  445. -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
  446. else
  447. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  448. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  449. -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
  450. fi
  451. - name: Clean up unfinished testmo sessions
  452. if: always()
  453. shell: bash
  454. run: |
  455. if [ ${{ steps.build.outputs.runid }} ]; then
  456. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
  457. fi
  458. if [ ${{ inputs.testman_token }} ]; then
  459. kill $TESTMO_PROXY_PID
  460. fi
  461. - name: analyze tests results
  462. shell: bash
  463. env:
  464. GITHUB_TOKEN: ${{ github.token }}
  465. run: |
  466. set -x
  467. if [ true = ${{ inputs.run_tests }} ]; then
  468. teststatus=$(cat statusrep.txt)
  469. if [[ $teststatus == "success" ]]; then
  470. testmessage="The check has been completed successfully"
  471. else
  472. testmessage="The check has been failed"
  473. fi
  474. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  475. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  476. -d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}'
  477. if [[ $teststatus != "success" ]]; then
  478. echo "status=failed" >> $GITHUB_OUTPUT
  479. fi
  480. fi
  481. - name: check test results
  482. if: inputs.run_tests
  483. shell: bash
  484. run: |
  485. if [ $IS_TEST_RESULT_IGNORED == 0 ]; then
  486. .github/scripts/tests/fail-checker.py "$LAST_JUNIT_REPORT_XML"
  487. fi
  488. - name: show diff mute_ya.txt
  489. if: inputs.build_preset == 'relwithdebinfo' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  490. shell: bash
  491. continue-on-error: true
  492. env:
  493. GITHUB_TOKEN: ${{ github.token }}
  494. run: |
  495. ORIGINAL_HEAD=$(git rev-parse HEAD)
  496. get_file_diff_script=.github/scripts/tests/get_diff_lines_of_file.py
  497. file_to_check=.github/config/muted_ya.txt
  498. check_result=`$get_file_diff_script --base_sha $ORIGINAL_HEAD~1 --head_sha $ORIGINAL_HEAD --file_path $file_to_check`
  499. if [[ ${check_result} == *"not changed" ]];then
  500. echo file ${file_to_check} NOT changed
  501. else
  502. echo file ${file_to_check} changed
  503. .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}"
  504. FILE_PATH=$PUBLIC_DIR/mute_info/2_new_muted_tests.txt
  505. SEPARATOR=""
  506. if [ -f "$FILE_PATH" ]; then
  507. LINE_COUNT=$(wc -l < "$FILE_PATH")
  508. if [ "$LINE_COUNT" -gt 0 ]; then
  509. SEPARATOR=', '
  510. MESSAGE="Muted new $LINE_COUNT [tests](${PUBLIC_DIR_URL}/mute_info/2_new_muted_tests.txt)"
  511. fi
  512. fi
  513. FILE_PATH=$PUBLIC_DIR/mute_info/3_unmuted_tests.txt
  514. if [ -f "$FILE_PATH" ]; then
  515. LINE_COUNT_unmute=$(wc -l < "$FILE_PATH")
  516. if [ "$LINE_COUNT_unmute" -gt 0 ]; then
  517. MESSAGE="${MESSAGE}${SEPARATOR}Unmuted $LINE_COUNT_unmute [tests](${PUBLIC_DIR_URL}/mute_info/3_unmuted_tests.txt)"
  518. fi
  519. fi
  520. if [ -n "$MESSAGE" ]; then
  521. printf "$MESSAGE" | .github/scripts/tests/comment-pr.py --color orange
  522. fi
  523. fi
  524. - name: sync results to s3 and publish links
  525. if: always()
  526. shell: bash
  527. run: |
  528. set -x
  529. echo "::group::s3-sync"
  530. .github/scripts/Indexer/indexer.py -r "$PUBLIC_DIR/"
  531. echo "00 [Artifacts](${PUBLIC_DIR_URL}/index.html)" >> $SUMMARY_LINKS
  532. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  533. 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
  534. echo "::endgroup::"
  535. - name: show free space
  536. if: always()
  537. shell: bash
  538. run: df -h
  539. - name: build_stats
  540. shell: bash
  541. continue-on-error: true
  542. if: always()
  543. run: |
  544. set -x
  545. export build_preset="${{ inputs.build_preset }}"
  546. export commit_git_sha="$(git rev-parse HEAD)"
  547. python3 .github/scripts/send_build_stats.py
  548. - name: show_build_size_diff
  549. shell: bash
  550. continue-on-error: true
  551. if: always()
  552. env:
  553. GITHUB_TOKEN: ${{ github.token }}
  554. run: |
  555. set -x
  556. export build_preset="${{ inputs.build_preset }}"
  557. export branch_to_compare="$GITHUB_REF_NAME"
  558. export yellow_treshold=102400
  559. export red_treshold=2097152
  560. export commit_git_sha="$(git rev-parse HEAD)"
  561. get_sizes_comment_script=.github/scripts/get_build_diff.py
  562. comment_raw=`$get_sizes_comment_script`
  563. IFS=';;;'
  564. read -ra comment_arr <<< "$comment_raw"
  565. printf "$comment"
  566. if [[ ${comment_raw} != "Error"* ]]; then
  567. color=${comment_arr[0]}
  568. replace=$color";;;"
  569. comment=${comment_raw/$replace/""}
  570. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  571. else
  572. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  573. fi
  574. - name: comment-if-cancel
  575. shell: bash
  576. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  577. env:
  578. BUILD_PRESET: ${{ inputs.build_preset }}
  579. GITHUB_TOKEN: ${{ github.token }}
  580. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black