action.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. name: Ya-Build-and-Test
  2. inputs:
  3. build_target:
  4. type: string
  5. default: "ydb/"
  6. description: "limit build and test to specific target"
  7. build_preset:
  8. type: string
  9. run_build:
  10. type: boolean
  11. default: true
  12. description: "run build"
  13. run_tests:
  14. type: boolean
  15. default: true
  16. description: "run tests"
  17. test_threads:
  18. type: string
  19. default: 28
  20. description: "Test threads count"
  21. link_threads:
  22. type: string
  23. default: 12
  24. description: "link threads count"
  25. test_size:
  26. type: string
  27. default: "small,medium,large"
  28. test_type:
  29. type: string
  30. default: ""
  31. description: "run only specific test types (or all by default)"
  32. increment:
  33. type: boolean
  34. required: true
  35. 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.
  36. folder_prefix:
  37. type: string
  38. default: "ya-"
  39. put_build_results_to_cache:
  40. type: boolean
  41. default: true
  42. additional_ya_make_args:
  43. type: string
  44. default: ""
  45. test_retry_count:
  46. default: ""
  47. description: "how many times to retry failed tests"
  48. secs:
  49. type: string
  50. default: ""
  51. vars:
  52. type: string
  53. default: ""
  54. defaults:
  55. run:
  56. shell: bash
  57. runs:
  58. using: "composite"
  59. steps:
  60. - name: comment-build-start
  61. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  62. shell: bash
  63. env:
  64. BUILD_PRESET: ${{ inputs.build_preset }}
  65. GITHUB_TOKEN: ${{ github.token }}
  66. run: |
  67. jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
  68. # tricky: we are searching job with name that contains build_preset
  69. check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
  70. platform_name="$(echo "$(uname -s)-$(uname -p)" | tr '[:upper:]' '[:lower:]')-$BUILD_PRESET"
  71. echo "Pre-commit [check]($check_url) **$platform_name** for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
  72. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  73. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  74. -d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}'
  75. if [[ "${{inputs.run_tests}}" == "true" ]];then
  76. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  77. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  78. -d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}'
  79. fi
  80. - name: Clean ya cache
  81. shell: bash
  82. run: rm -rf ~/.ya
  83. - name: Prepare s3cmd
  84. uses: ./.github/actions/s3cmd
  85. with:
  86. s3_bucket: ${{ fromJSON( inputs.vars ).AWS_BUCKET }}
  87. s3_endpoint: ${{ fromJSON( inputs.vars ).AWS_ENDPOINT }}
  88. s3_key_id: ${{ fromJSON( inputs.secs ).AWS_KEY_ID }}
  89. s3_key_secret: ${{ fromJSON( inputs.secs ).AWS_KEY_VALUE }}
  90. folder_prefix: ya-
  91. build_preset: ${{ inputs.build_preset }}
  92. - name: Generate ya.make with affected test suites and modules list
  93. if: inputs.increment == 'true'
  94. uses: ./.github/actions/graph_compare
  95. - name: Change target in case of incremental
  96. id: target_choice
  97. shell: bash
  98. run: |
  99. if [ "${{ inputs.increment }}" == "true" ]; then
  100. echo "target=." >> $GITHUB_OUTPUT
  101. else
  102. echo "target=${{ inputs.build_target }}" >> $GITHUB_OUTPUT
  103. fi
  104. - name: Run build and tests
  105. id: build
  106. uses: ./.github/actions/test_ya
  107. with:
  108. build_target: ${{ steps.target_choice.outputs.target }}
  109. build_preset: ${{ inputs.build_preset }}
  110. test_size: ${{ inputs.test_size }}
  111. test_type: ${{ inputs.test_type }}
  112. run_tests: ${{ inputs.run_tests }}
  113. testman_token: ${{ fromJSON( inputs.secs ).TESTMO_TOKEN2 }}
  114. testman_url: ${{ fromJSON( inputs.vars ).TESTMO_URL }}
  115. testman_project_id: ${{ fromJSON( inputs.vars ).TESTMO_PROJECT_ID }}
  116. link_threads: ${{ inputs.link_threads }}
  117. additional_ya_make_args: ${{ inputs.additional_ya_make_args }}
  118. test_threads: ${{ inputs.test_threads }}
  119. bazel_remote_uri: ${{ fromJSON( inputs.vars ).REMOTE_CACHE_URL || '' }}
  120. bazel_remote_username: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_USERNAME || '' }}
  121. bazel_remote_password: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_PASSWORD || '' }}
  122. put_build_results_to_cache: ${{ inputs.put_build_results_to_cache }}
  123. test_retry_count: ${{ inputs.test_retry_count }}
  124. - name: build_stats
  125. shell: bash
  126. continue-on-error: true
  127. if: always()
  128. run: |
  129. set -x
  130. export build_preset="${{ inputs.build_preset }}"
  131. export commit_git_sha="$(git rev-parse HEAD)"
  132. python3 -m pip install ydb ydb[yc]
  133. python3 .github/scripts/send_build_stats.py
  134. - name: show_build_size_diff
  135. shell: bash
  136. continue-on-error: true
  137. if: always()
  138. env:
  139. GITHUB_TOKEN: ${{ github.token }}
  140. run: |
  141. set -x
  142. export build_preset="${{ inputs.build_preset }}"
  143. export branch_to_compare="$GITHUB_REF_NAME"
  144. export yellow_treshold=102400
  145. export red_treshold=2097152
  146. export commit_git_sha="$(git rev-parse HEAD)"
  147. python3 -m pip install ydb ydb[yc] humanize
  148. get_sizes_comment_script=.github/scripts/get_build_diff.py
  149. comment_raw=`$get_sizes_comment_script`
  150. IFS=';;;'
  151. read -ra comment_arr <<< "$comment_raw"
  152. printf "$comment"
  153. if [[ ${comment_raw} != "Error"* ]];then
  154. color=${comment_arr[0]}
  155. replace=$color";;;"
  156. comment=${comment_raw/$replace/""}
  157. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  158. else
  159. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  160. fi
  161. - name: comment-if-cancel
  162. shell: bash
  163. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  164. env:
  165. BUILD_PRESET: ${{ inputs.build_preset }}
  166. GITHUB_TOKEN: ${{ github.token }}
  167. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black