action.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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. export TEST_META_INFO=$CURRENT_PUBLIC_DIR/tests_meta
  303. mkdir $TEST_META_INFO
  304. if [ ${{ inputs.testman_token }} ]; then
  305. # inititalize testmo session
  306. TESTMO_RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
  307. TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-link --name build --url "$TESTMO_RUN_URL" --resources $CURRENT_PUBLIC_DIR/testmo.json
  308. 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
  309. TESTMO_RUN_ID=$(
  310. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
  311. --name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources $CURRENT_PUBLIC_DIR/testmo.json \
  312. --tags "$TESTMO_BRANCH_TAG" --tags "$TESTMO_EXTRA_TAG"
  313. )
  314. echo "runid=${TESTMO_RUN_ID}" >> $GITHUB_OUTPUT
  315. TESTMO_HISTORY_URL="${TESTMO_URL}/automation/runs/view/${TESTMO_RUN_ID}"
  316. # Replace test history link
  317. cat $SUMMARY_LINKS | (grep -v "Test history" || true) > $TMP_DIR/tmp_summary
  318. mv $TMP_DIR/tmp_summary $SUMMARY_LINKS
  319. echo "10 [Test history](${TESTMO_HISTORY_URL})" >> $SUMMARY_LINKS
  320. fi
  321. CURRENT_MESSAGE="ya make is running..."
  322. if [ $IS_RETRY = 0 ]; then
  323. CURRENT_MESSAGE="$CURRENT_MESSAGE"
  324. RERUN_FAILED_OPT=""
  325. else
  326. CURRENT_MESSAGE="$CURRENT_MESSAGE (failed tests rerun, try $RETRY)"
  327. RERUN_FAILED_OPT="-X"
  328. fi
  329. echo $CURRENT_MESSAGE | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py
  330. CURRENT_JUNIT_XML_PATH=$CURRENT_PUBLIC_DIR/junit.xml
  331. CURRENT_REPORT=$CURRENT_PUBLIC_DIR/report.json
  332. set +e
  333. (./ya make $YA_MAKE_TARGET "${params[@]}" \
  334. $RERUN_FAILED_OPT --log-file "$PUBLIC_DIR/ya_log.txt" \
  335. --evlog-file "$CURRENT_PUBLIC_DIR/ya_evlog.jsonl" \
  336. --junit "$CURRENT_JUNIT_XML_PATH" --build-results-report "$CURRENT_REPORT" --output "$YA_MAKE_OUT_DIR"; echo $? > exit_code) |& cat >> $YA_MAKE_OUTPUT
  337. set -e
  338. RC=`cat exit_code`
  339. .github/scripts/tests/report_analyzer.py --report_file "$CURRENT_REPORT" --summary_file $CURRENT_PUBLIC_DIR/summary_report.txt || true
  340. # convert to chromium trace
  341. # seems analyze-make don't have simple "output" parameter, so change cwd
  342. ya_dir=$(pwd)
  343. (cd $CURRENT_PUBLIC_DIR && $ya_dir/ya analyze-make timeline --evlog ya_evlog.jsonl)
  344. # generate test_bloat
  345. ./ydb/ci/build_bloat/test_bloat.py --junit $CURRENT_JUNIT_XML_PATH --output_dir $CURRENT_PUBLIC_DIR/test_bloat || true
  346. echo "30 [Test bloat](${CURRENT_PUBLIC_DIR_URL}/test_bloat/tree_map.html)" >> $SUMMARY_LINKS
  347. if [ $RC -ne 0 ]; then
  348. echo "ya make returned $RC, build failed"
  349. echo "status=failed" >> $GITHUB_OUTPUT
  350. BUILD_FAILED=1
  351. # sed is to remove richness (tags like '[[rst]]')
  352. (( \
  353. cat $CURRENT_REPORT \
  354. | jq -r '.results[] | select((.status == "FAILED") and (.error_type == "REGULAR") and (.type = "build")) | "path: " + .path + "\n\n" + ."rich-snippet" + "\n\n\n"' \
  355. | sed 's/\[\[[^]]*]\]//g' \
  356. ) || true) > $CURRENT_PUBLIC_DIR/fail_summary.txt
  357. 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
  358. break
  359. fi
  360. # fix junit files (add links, logs etc)
  361. # archive unitest reports (orig)
  362. gzip -c $CURRENT_JUNIT_XML_PATH > $CURRENT_PUBLIC_DIR/orig_junit.xml.gz
  363. # postprocess junit user_attributesreport
  364. .github/scripts/tests/apply_user_properties_to_junit.py \
  365. --test_dir="$TEST_META_INFO" \
  366. --in_file="$CURRENT_JUNIT_XML_PATH" \
  367. --out_file="$CURRENT_JUNIT_XML_PATH" || true
  368. # postprocess junit report
  369. .github/scripts/tests/transform_ya_junit.py -i \
  370. -m .github/config/muted_ya.txt \
  371. --ya_out "$YA_MAKE_OUT_DIR" \
  372. --public_dir "$PUBLIC_DIR" \
  373. --public_dir_url "$PUBLIC_DIR_URL" \
  374. --log_out_dir "$CURRENT_PUBLIC_DIR_RELATIVE/artifacts/logs/" \
  375. --test_stuff_out "$CURRENT_PUBLIC_DIR_RELATIVE/test_artifacts/" \
  376. "$CURRENT_JUNIT_XML_PATH"
  377. cp $CURRENT_JUNIT_XML_PATH $LAST_JUNIT_REPORT_XML
  378. TESTS_RESULT=0
  379. .github/scripts/tests/fail-checker.py "$CURRENT_JUNIT_XML_PATH" --output_path $CURRENT_PUBLIC_DIR/failed_count.txt || TESTS_RESULT=$?
  380. FAILED_TESTS_COUNT=$(cat $CURRENT_PUBLIC_DIR/failed_count.txt)
  381. IS_LAST_RETRY=0
  382. if [ $TESTS_RESULT = 0 ] || [ $RETRY = $TEST_RETRY_COUNT ]; then
  383. IS_LAST_RETRY=1
  384. fi
  385. if [ $FAILED_TESTS_COUNT -gt 500 ]; then
  386. IS_LAST_RETRY=1
  387. TOO_MANY_FAILED="Too many tests failed, NOT going to retry"
  388. echo $TOO_MANY_FAILED | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color red
  389. fi
  390. if [ "${{ inputs.run_tests }}" = "true" ]; then
  391. GITHUB_TOKEN=${{ github.token }} .github/scripts/tests/generate-summary.py \
  392. --summary_links "$SUMMARY_LINKS" \
  393. --public_dir "$PUBLIC_DIR" \
  394. --public_dir_url "$PUBLIC_DIR_URL" \
  395. --build_preset "$BUILD_PRESET" \
  396. --status_report_file statusrep.txt \
  397. --is_retry $IS_RETRY \
  398. --is_last_retry $IS_LAST_RETRY \
  399. --is_test_result_ignored $IS_TEST_RESULT_IGNORED \
  400. --comment_color_file summary_color.txt \
  401. --comment_text_file summary_text.txt \
  402. "Tests" $CURRENT_PUBLIC_DIR/ya-test.html "$CURRENT_JUNIT_XML_PATH"
  403. fi
  404. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  405. if [ "${{ inputs.run_tests }}" = "true" ]; then
  406. cat summary_text.txt | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color `cat summary_color.txt`
  407. fi
  408. # upload tests results to YDB
  409. ydb_upload_run_name="${TESTMO_RUN_NAME// /"_"}"
  410. 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}`
  411. if [ ${{ inputs.testman_token }} ]; then
  412. # finish testme session
  413. # split large junit_report
  414. export TESTMO_JUNIT_REPORT_PARTS=$TMP_DIR/try_$RETRY/junit-split
  415. mkdir -p $TESTMO_JUNIT_REPORT_PARTS
  416. .github/scripts/tests/split-junit.py -o "$TESTMO_JUNIT_REPORT_PARTS" "$CURRENT_JUNIT_XML_PATH"
  417. # archive unitest reports (transformed)
  418. tar -C $TESTMO_JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $TESTMO_JUNIT_REPORT_PARTS)
  419. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:submit-thread \
  420. --instance "https://$TESTMO_PROXY_ADDR" --run-id "$TESTMO_RUN_ID" \
  421. --results "$TESTMO_JUNIT_REPORT_PARTS/*.xml"
  422. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
  423. echo "runid=" >> $GITHUB_OUTPUT
  424. fi
  425. if [ $IS_LAST_RETRY = 1 ]; then
  426. break
  427. fi
  428. done;
  429. if [ $BUILD_FAILED = 0 ]; then
  430. echo "status=true" >> $GITHUB_OUTPUT
  431. echo "Build successful." | GITHUB_TOKEN="${{ github.token }}" .github/scripts/tests/comment-pr.py --color green
  432. fi
  433. - name: comment-build-status
  434. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  435. shell: bash
  436. env:
  437. GITHUB_TOKEN: ${{ github.token }}
  438. run: |
  439. set -x
  440. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  441. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  442. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  443. -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
  444. else
  445. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  446. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  447. -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
  448. fi
  449. - name: Clean up unfinished testmo sessions
  450. if: always()
  451. shell: bash
  452. run: |
  453. if [ ${{ steps.build.outputs.runid }} ]; then
  454. TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
  455. fi
  456. if [ ${{ inputs.testman_token }} ]; then
  457. kill $TESTMO_PROXY_PID
  458. fi
  459. - name: analyze tests results
  460. shell: bash
  461. env:
  462. GITHUB_TOKEN: ${{ github.token }}
  463. run: |
  464. set -x
  465. if [ true = ${{ inputs.run_tests }} ]; then
  466. teststatus=$(cat statusrep.txt)
  467. if [[ $teststatus == "success" ]]; then
  468. testmessage="The check has been completed successfully"
  469. else
  470. testmessage="The check has been failed"
  471. fi
  472. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  473. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  474. -d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}'
  475. if [[ $teststatus != "success" ]]; then
  476. echo "status=failed" >> $GITHUB_OUTPUT
  477. fi
  478. fi
  479. - name: check test results
  480. if: inputs.run_tests
  481. shell: bash
  482. run: |
  483. if [ $IS_TEST_RESULT_IGNORED == 0 ]; then
  484. .github/scripts/tests/fail-checker.py "$LAST_JUNIT_REPORT_XML"
  485. fi
  486. - name: show diff mute_ya.txt
  487. if: inputs.build_preset == 'relwithdebinfo' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  488. shell: bash
  489. continue-on-error: true
  490. env:
  491. GITHUB_TOKEN: ${{ github.token }}
  492. run: |
  493. ORIGINAL_HEAD=$(git rev-parse HEAD)
  494. get_file_diff_script=.github/scripts/tests/get_diff_lines_of_file.py
  495. file_to_check=.github/config/muted_ya.txt
  496. check_result=`$get_file_diff_script --base_sha $ORIGINAL_HEAD~1 --head_sha $ORIGINAL_HEAD --file_path $file_to_check`
  497. if [[ ${check_result} == *"not changed" ]];then
  498. echo file ${file_to_check} NOT changed
  499. else
  500. echo file ${file_to_check} changed
  501. .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}"
  502. FILE_PATH=$PUBLIC_DIR/mute_info/2_new_muted_tests.txt
  503. SEPARATOR=""
  504. if [ -f "$FILE_PATH" ]; then
  505. LINE_COUNT=$(wc -l < "$FILE_PATH")
  506. if [ "$LINE_COUNT" -gt 0 ]; then
  507. SEPARATOR=', '
  508. MESSAGE="Muted new $LINE_COUNT [tests](${PUBLIC_DIR_URL}/mute_info/2_new_muted_tests.txt)"
  509. fi
  510. fi
  511. FILE_PATH=$PUBLIC_DIR/mute_info/3_unmuted_tests.txt
  512. if [ -f "$FILE_PATH" ]; then
  513. LINE_COUNT_unmute=$(wc -l < "$FILE_PATH")
  514. if [ "$LINE_COUNT_unmute" -gt 0 ]; then
  515. MESSAGE="${MESSAGE}${SEPARATOR}Unmuted $LINE_COUNT_unmute [tests](${PUBLIC_DIR_URL}/mute_info/3_unmuted_tests.txt)"
  516. fi
  517. fi
  518. if [ -n "$MESSAGE" ]; then
  519. printf "$MESSAGE" | .github/scripts/tests/comment-pr.py --color orange
  520. fi
  521. fi
  522. - name: sync results to s3 and publish links
  523. if: always()
  524. shell: bash
  525. run: |
  526. set -x
  527. echo "::group::s3-sync"
  528. .github/scripts/Indexer/indexer.py -r "$PUBLIC_DIR/"
  529. echo "00 [Artifacts](${PUBLIC_DIR_URL}/index.html)" >> $SUMMARY_LINKS
  530. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-mime-magic --guess-mime-type --no-check-md5 "$PUBLIC_DIR/" "$S3_BUCKET_PATH/"
  531. 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
  532. echo "::endgroup::"
  533. - name: show free space
  534. if: always()
  535. shell: bash
  536. run: df -h
  537. - name: build_stats
  538. shell: bash
  539. continue-on-error: true
  540. if: always()
  541. run: |
  542. set -x
  543. export build_preset="${{ inputs.build_preset }}"
  544. export commit_git_sha="$(git rev-parse HEAD)"
  545. python3 .github/scripts/send_build_stats.py
  546. - name: show_build_size_diff
  547. shell: bash
  548. continue-on-error: true
  549. if: always()
  550. env:
  551. GITHUB_TOKEN: ${{ github.token }}
  552. run: |
  553. set -x
  554. export build_preset="${{ inputs.build_preset }}"
  555. export branch_to_compare="$GITHUB_REF_NAME"
  556. export yellow_treshold=102400
  557. export red_treshold=2097152
  558. export commit_git_sha="$(git rev-parse HEAD)"
  559. get_sizes_comment_script=.github/scripts/get_build_diff.py
  560. comment_raw=`$get_sizes_comment_script`
  561. IFS=';;;'
  562. read -ra comment_arr <<< "$comment_raw"
  563. printf "$comment"
  564. if [[ ${comment_raw} != "Error"* ]]; then
  565. color=${comment_arr[0]}
  566. replace=$color";;;"
  567. comment=${comment_raw/$replace/""}
  568. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  569. else
  570. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  571. fi
  572. - name: comment-if-cancel
  573. shell: bash
  574. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  575. env:
  576. BUILD_PRESET: ${{ inputs.build_preset }}
  577. GITHUB_TOKEN: ${{ github.token }}
  578. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black