action.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. export TMP_DIR=$(pwd)/tmp
  99. rm -rf $TMP_DIR
  100. mkdir -p $TMP_DIR
  101. echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
  102. # The whole dir will be uploaded to s3 with public (=wild internet) ACL
  103. export PUBLIC_DIR=$TMP_DIR/results
  104. echo "PUBLIC_DIR=$PUBLIC_DIR" >> $GITHUB_ENV
  105. export PUBLIC_DIR_URL=$S3_URL_PREFIX
  106. echo "PUBLIC_DIR_URL=$PUBLIC_DIR_URL" >> $GITHUB_ENV
  107. mkdir -p $PUBLIC_DIR
  108. echo "LAST_JUNIT_REPORT_XML=$PUBLIC_DIR/last_junit.xml" >> $GITHUB_ENV
  109. export TESTMO_URL=${{ inputs.testman_url }}
  110. echo "TESTMO_URL=$TESTMO_URL" >> $GITHUB_ENV
  111. echo "SUMMARY_LINKS=$PUBLIC_DIR/summary_links.txt" >> $GITHUB_ENV
  112. echo "BUILD_PRESET=${{ inputs.build_preset }}" >> $GITHUB_ENV
  113. python3 -m pip install ydb ydb[yc] codeowners
  114. if [ ${{ inputs.testman_token }} ]; then
  115. TESTMO_PROXY_ADDR=127.0.0.1:8888
  116. openssl req -x509 -newkey rsa:2048 \
  117. -keyout $TMP_DIR/key.pem -out $TMP_DIR/cert.pem \
  118. -sha256 -days 1 -nodes -subj "/CN=127.0.0.1"
  119. TESTMO_TOKEN=${{ inputs.testman_token }} ./ydb/ci/testmo-proxy/testmo-proxy.py -l $TESTMO_PROXY_ADDR \
  120. --cert-file "$TMP_DIR/cert.pem" \
  121. --cert-key "$TMP_DIR/key.pem" \
  122. --target-timeout 3,60 \
  123. --max-request-time 200 \
  124. "$TESTMO_URL" > $PUBLIC_DIR/testmo_proxy.log 2>&1 &
  125. TESTMO_PROXY_PID=$!
  126. echo "TESTMO_PROXY_ADDR=$TESTMO_PROXY_ADDR" >> $GITHUB_ENV
  127. echo "TESTMO_PROXY_PID=$TESTMO_PROXY_PID" >> $GITHUB_ENV
  128. # testmo rejects self-signed cert without this setting
  129. echo "NODE_TLS_REJECT_UNAUTHORIZED=0" >> $GITHUB_ENV
  130. fi
  131. - name: ya build and test
  132. id: build
  133. shell: bash
  134. run: |
  135. set -x
  136. echo "Artifacts will be uploaded [here](${PUBLIC_DIR_URL}/index.html)" | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  137. ORIGINAL_HEAD=$(git rev-parse HEAD)
  138. if [ "${{ inputs.increment }}" = "true" ]; then
  139. GRAPH_COMPARE_OUTPUT="$PUBLIC_DIR/graph_compare.log"
  140. GRAPH_COMPARE_OUTPUT_URL="$PUBLIC_DIR_URL/graph_compare.log"
  141. set +e
  142. ./.github/scripts/graph_compare.sh $ORIGINAL_HEAD~1 $ORIGINAL_HEAD |& tee $GRAPH_COMPARE_OUTPUT
  143. RC=${PIPESTATUS[0]}
  144. set -e
  145. if [ $RC -ne 0 ]; then
  146. echo "graph_compare.sh returned $RC, build failed"
  147. echo "status=failed" >> $GITHUB_OUTPUT
  148. BUILD_FAILED=1
  149. echo "Graph compare failed, see the [logs]($GRAPH_COMPARE_OUTPUT_URL)." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  150. exit $RC
  151. fi
  152. git checkout $ORIGINAL_HEAD
  153. YA_MAKE_TARGET=.
  154. else
  155. YA_MAKE_TARGET=${{ inputs.build_target }}
  156. fi
  157. readarray -d ',' -t test_size < <(printf "%s" "${{ inputs.test_size }}")
  158. readarray -d ',' -t test_type < <(printf "%s" "${{ inputs.test_type }}")
  159. params=(
  160. -T
  161. ${test_size[@]/#/--test-size=} ${test_type[@]/#/--test-type=}
  162. --stat
  163. --test-threads "${{ inputs.test_threads }}" --link-threads "${{ inputs.link_threads }}"
  164. -DUSE_EAT_MY_DATA
  165. )
  166. TEST_RETRY_COUNT=${{ inputs.test_retry_count }}
  167. case "$BUILD_PRESET" in
  168. debug)
  169. params+=(--build "debug")
  170. ;;
  171. relwithdebinfo)
  172. params+=(--build "relwithdebinfo")
  173. ;;
  174. release)
  175. params+=(--build "release")
  176. ;;
  177. release-clang14)
  178. params+=(--build "release")
  179. params+=(--target-platform="CLANG14-LINUX-X86_64")
  180. params+=(-DLLD_VERSION=16)
  181. params+=(-DSTRIP)
  182. ;;
  183. release-asan)
  184. params+=(
  185. --build "release" --sanitize="address"
  186. -DDEBUGINFO_LINES_ONLY
  187. )
  188. if [ $TEST_RETRY_COUNT -z ]; then
  189. TEST_RETRY_COUNT=1
  190. fi
  191. ;;
  192. release-tsan)
  193. params+=(
  194. --build "release" --sanitize="thread"
  195. -DDEBUGINFO_LINES_ONLY
  196. )
  197. if [ $TEST_RETRY_COUNT -z ]; then
  198. TEST_RETRY_COUNT=1
  199. fi
  200. ;;
  201. release-msan)
  202. params+=(
  203. --build "release" --sanitize="memory"
  204. -DDEBUGINFO_LINES_ONLY
  205. )
  206. if [ $TEST_RETRY_COUNT -z ]; then
  207. TEST_RETRY_COUNT=1
  208. fi
  209. ;;
  210. *)
  211. echo "Invalid preset: $BUILD_PRESET"
  212. exit 1
  213. ;;
  214. esac
  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 "${{ inputs.bazel_remote_password }}")
  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.log"
  262. YA_MAKE_OUTPUT_URL="$PUBLIC_DIR_URL/ya_make_output.log"
  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. mkdir $CURRENT_PUBLIC_DIR
  301. if [ ${{ inputs.testman_token }} ]; then
  302. # inititalize testmo session
  303. TESTMO_RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
  304. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-link --name build --url "$TESTMO_RUN_URL" --resources $CURRENT_PUBLIC_DIR/testmo.json
  305. 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
  306. TESTMO_RUN_ID=$(
  307. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
  308. --name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources $CURRENT_PUBLIC_DIR/testmo.json \
  309. --tags "$TESTMO_BRANCH_TAG" --tags "$TESTMO_EXTRA_TAG"
  310. )
  311. echo "runid=${TESTMO_RUN_ID}" >> $GITHUB_OUTPUT
  312. TESTMO_HISTORY_URL="${TESTMO_URL}/automation/runs/view/${TESTMO_RUN_ID}"
  313. # Replace test history link
  314. cat $SUMMARY_LINKS | (grep -v "Test history" || true) > $TMP_DIR/tmp_summary
  315. mv $TMP_DIR/tmp_summary $SUMMARY_LINKS
  316. echo "10 [Test history](${TESTMO_HISTORY_URL})" >> $SUMMARY_LINKS
  317. fi
  318. CURRENT_MESSAGE="ya make is running..."
  319. if [ $IS_RETRY = 0 ]; then
  320. CURRENT_MESSAGE="$CURRENT_MESSAGE"
  321. RERUN_FAILED_OPT=""
  322. else
  323. CURRENT_MESSAGE="$CURRENT_MESSAGE (failed tests rerun, try $RETRY)"
  324. RERUN_FAILED_OPT="-X"
  325. fi
  326. echo $CURRENT_MESSAGE | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  327. CURRENT_JUNIT_XML_PATH=$CURRENT_PUBLIC_DIR/junit.xml
  328. CURRENT_REPORT=$CURRENT_PUBLIC_DIR/report.json
  329. set +ex
  330. (./ya make $YA_MAKE_TARGET "${params[@]}" \
  331. $RERUN_FAILED_OPT --log-file "$PUBLIC_DIR/ya_log.log" \
  332. --evlog-file "$CURRENT_PUBLIC_DIR/ya_evlog.jsonl" \
  333. --junit "$CURRENT_JUNIT_XML_PATH" --build-results-report "$CURRENT_REPORT" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& cat >> $YA_MAKE_OUTPUT
  334. set -ex
  335. RC=`cat exit_code`
  336. .github/scripts/tests/report_analyzer.py --report_file "$CURRENT_REPORT" --summary_file $CURRENT_PUBLIC_DIR/summary_report.txt || true
  337. # convert to chromium trace
  338. # seems analyze-make don't have simple "output" parameter, so change cwd
  339. ya_dir=$(pwd)
  340. (cd $CURRENT_PUBLIC_DIR && $ya_dir/ya analyze-make timeline --evlog ya_evlog.jsonl)
  341. if [ $RC -ne 0 ]; then
  342. echo "ya make returned $RC, build failed"
  343. echo "status=failed" >> $GITHUB_OUTPUT
  344. BUILD_FAILED=1
  345. echo "Build failed, see the [logs]($YA_MAKE_OUTPUT_URL)." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  346. break
  347. fi
  348. # fix junit files (add links, logs etc)
  349. # archive unitest reports (orig)
  350. gzip -c $CURRENT_JUNIT_XML_PATH > $CURRENT_PUBLIC_DIR/orig_junit.xml.gz
  351. # postprocess junit report
  352. .github/scripts/tests/transform-ya-junit.py -i \
  353. -m .github/config/muted_ya.txt \
  354. --ya_out "$YA_MAKE_OUT_DIR" \
  355. --public_dir "$PUBLIC_DIR" \
  356. --public_dir_url "$PUBLIC_DIR_URL" \
  357. --log_out_dir "$CURRENT_PUBLIC_DIR_RELATIVE/artifacts/logs/" \
  358. --test_stuff_out "$CURRENT_PUBLIC_DIR_RELATIVE/test_artifacts/" \
  359. "$CURRENT_JUNIT_XML_PATH"
  360. cp $CURRENT_JUNIT_XML_PATH $LAST_JUNIT_REPORT_XML
  361. TESTS_RESULT=0
  362. .github/scripts/tests/fail-checker.py "$CURRENT_JUNIT_XML_PATH" --output_path $CURRENT_PUBLIC_DIR/failed_count.txt || TESTS_RESULT=$?
  363. FAILED_TESTS_COUNT=$(cat $CURRENT_PUBLIC_DIR/failed_count.txt)
  364. IS_LAST_RETRY=0
  365. if [ $TESTS_RESULT = 0 ] || [ $RETRY = $TEST_RETRY_COUNT ]; then
  366. IS_LAST_RETRY=1
  367. fi
  368. if [ $FAILED_TESTS_COUNT -gt 500 ]; then
  369. IS_LAST_RETRY=1
  370. TOO_MANY_FAILED="Too many tests failed, NOT going to retry"
  371. echo $TOO_MANY_FAILED | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  372. fi
  373. if [ "${{ inputs.run_tests }}" = "true" ]; then
  374. GITHUB_TOKEN=${{ github.token }} .github/scripts/tests/generate-summary.py \
  375. --summary_links "$SUMMARY_LINKS" \
  376. --public_dir "$PUBLIC_DIR" \
  377. --public_dir_url "$PUBLIC_DIR_URL" \
  378. --build_preset "$BUILD_PRESET" \
  379. --status_report_file statusrep.txt \
  380. --is_retry $IS_RETRY \
  381. --is_last_retry $IS_LAST_RETRY \
  382. --comment_color_file summary_color.txt \
  383. --comment_text_file summary_text.txt \
  384. "Tests" $CURRENT_PUBLIC_DIR/ya-test.html "$CURRENT_JUNIT_XML_PATH"
  385. fi
  386. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  387. if [ "${{ inputs.run_tests }}" = "true" ]; then
  388. cat summary_text.txt | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color `cat summary_color.txt`
  389. fi
  390. # upload tests results to YDB
  391. ydb_upload_run_name="${TESTMO_RUN_NAME// /"_"}"
  392. 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}`
  393. if [ ${{ inputs.testman_token }} ]; then
  394. # finish testme session
  395. # split large junit_report
  396. export TESTMO_JUNIT_REPORT_PARTS=$TMP_DIR/try_$RETRY/junit-split
  397. mkdir -p $TESTMO_JUNIT_REPORT_PARTS
  398. .github/scripts/tests/split-junit.py -o "$TESTMO_JUNIT_REPORT_PARTS" "$CURRENT_JUNIT_XML_PATH"
  399. # archive unitest reports (transformed)
  400. tar -C $TESTMO_JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $TESTMO_JUNIT_REPORT_PARTS)
  401. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:submit-thread \
  402. --instance "https://$TESTMO_PROXY_ADDR" --run-id "$TESTMO_RUN_ID" \
  403. --results "$TESTMO_JUNIT_REPORT_PARTS/*.xml"
  404. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
  405. echo "runid=" >> $GITHUB_OUTPUT
  406. fi
  407. if [ $IS_LAST_RETRY = 1 ]; then
  408. break
  409. fi
  410. done;
  411. if [ $BUILD_FAILED = 0 ]; then
  412. echo "status=true" >> $GITHUB_OUTPUT
  413. echo "Build successful." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color green
  414. fi
  415. - name: comment-build-status
  416. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  417. shell: bash
  418. env:
  419. GITHUB_TOKEN: ${{ github.token }}
  420. run: |
  421. set -x
  422. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  423. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  424. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  425. -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
  426. else
  427. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  428. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  429. -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
  430. fi
  431. - name: Clean up unfinished testmo sessions
  432. if: always()
  433. shell: bash
  434. run: |
  435. if [ ${{ steps.build.outputs.runid }} ]; then
  436. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
  437. fi
  438. if [ ${{ inputs.testman_token }} ]; then
  439. kill $TESTMO_PROXY_PID
  440. fi
  441. - name: analyze tests results
  442. shell: bash
  443. env:
  444. GITHUB_TOKEN: ${{ github.token }}
  445. run: |
  446. set -x
  447. if [ true = ${{ inputs.run_tests }} ]; then
  448. teststatus=$(cat statusrep.txt)
  449. if [[ $teststatus == "success" ]];then
  450. testmessage="The check has been completed successfully"
  451. else
  452. testmessage="The check has been failed"
  453. fi
  454. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  455. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  456. -d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}'
  457. if [[ $teststatus != "success" ]];then
  458. echo "status=failed" >> $GITHUB_OUTPUT
  459. fi
  460. fi
  461. - name: check test results
  462. if: inputs.run_tests
  463. shell: bash
  464. run: |
  465. .github/scripts/tests/fail-checker.py "$LAST_JUNIT_REPORT_XML"
  466. - name: sync results to s3 and publish links
  467. if: always()
  468. shell: bash
  469. run: |
  470. set -x
  471. echo "::group::s3-sync"
  472. .github/scripts/Indexer/indexer.py -r "$PUBLIC_DIR/"
  473. echo "00 [Artifacts](${PUBLIC_DIR_URL}/index.html)" >> $SUMMARY_LINKS
  474. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  475. 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
  476. echo "::endgroup::"
  477. - name: show free space
  478. if: always()
  479. shell: bash
  480. run: df -h
  481. - name: build_stats
  482. shell: bash
  483. continue-on-error: true
  484. if: always()
  485. run: |
  486. set -x
  487. export build_preset="${{ inputs.build_preset }}"
  488. export commit_git_sha="$(git rev-parse HEAD)"
  489. python3 -m pip install ydb ydb[yc]
  490. python3 .github/scripts/send_build_stats.py
  491. - name: show_build_size_diff
  492. shell: bash
  493. continue-on-error: true
  494. if: always()
  495. env:
  496. GITHUB_TOKEN: ${{ github.token }}
  497. run: |
  498. set -x
  499. export build_preset="${{ inputs.build_preset }}"
  500. export branch_to_compare="$GITHUB_REF_NAME"
  501. export yellow_treshold=102400
  502. export red_treshold=2097152
  503. export commit_git_sha="$(git rev-parse HEAD)"
  504. python3 -m pip install ydb ydb[yc] humanize
  505. get_sizes_comment_script=.github/scripts/get_build_diff.py
  506. comment_raw=`$get_sizes_comment_script`
  507. IFS=';;;'
  508. read -ra comment_arr <<< "$comment_raw"
  509. printf "$comment"
  510. if [[ ${comment_raw} != "Error"* ]];then
  511. color=${comment_arr[0]}
  512. replace=$color";;;"
  513. comment=${comment_raw/$replace/""}
  514. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  515. else
  516. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  517. fi
  518. - name: comment-if-cancel
  519. shell: bash
  520. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  521. env:
  522. BUILD_PRESET: ${{ inputs.build_preset }}
  523. GITHUB_TOKEN: ${{ github.token }}
  524. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black