action.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. echo "Pre-commit [check]($check_url) for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
  71. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  72. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  73. -d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}'
  74. if [[ "${{inputs.run_tests}}" == "true" ]];then
  75. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  76. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  77. -d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}'
  78. fi
  79. - name: Clean ya cache
  80. shell: bash
  81. run: rm -rf ~/.ya
  82. - name: Prepare s3cmd
  83. uses: ./.github/actions/s3cmd
  84. with:
  85. s3_bucket: ${{ fromJSON( inputs.vars ).AWS_BUCKET }}
  86. s3_endpoint: ${{ fromJSON( inputs.vars ).AWS_ENDPOINT }}
  87. s3_key_id: ${{ fromJSON( inputs.secs ).AWS_KEY_ID }}
  88. s3_key_secret: ${{ fromJSON( inputs.secs ).AWS_KEY_VALUE }}
  89. folder_prefix: ya-
  90. build_preset: ${{ inputs.build_preset }}
  91. - name: Generate ya.make with affected test suites and modules list
  92. if: inputs.increment == 'true'
  93. uses: ./.github/actions/graph_compare
  94. - name: Change target in case of incremental
  95. id: target_choice
  96. shell: bash
  97. run: |
  98. if [ "${{ inputs.increment }}" == "true" ]; then
  99. echo "target=." >> $GITHUB_OUTPUT
  100. else
  101. echo "target=${{ inputs.build_target }}" >> $GITHUB_OUTPUT
  102. fi
  103. - name: Run build and tests
  104. id: build
  105. uses: ./.github/actions/test_ya
  106. with:
  107. build_target: ${{ steps.target_choice.outputs.target }}
  108. build_preset: ${{ inputs.build_preset }}
  109. test_size: ${{ inputs.test_size }}
  110. test_type: ${{ inputs.test_type }}
  111. run_tests: ${{ inputs.run_tests }}
  112. testman_token: ${{ fromJSON( inputs.secs ).TESTMO_TOKEN2 }}
  113. testman_url: ${{ fromJSON( inputs.vars ).TESTMO_URL }}
  114. testman_project_id: ${{ fromJSON( inputs.vars ).TESTMO_PROJECT_ID }}
  115. link_threads: ${{ inputs.link_threads }}
  116. additional_ya_make_args: ${{ inputs.additional_ya_make_args }}
  117. test_threads: ${{ inputs.test_threads }}
  118. bazel_remote_uri: ${{ fromJSON( inputs.vars ).REMOTE_CACHE_URL || '' }}
  119. bazel_remote_username: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_USERNAME || '' }}
  120. bazel_remote_password: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_PASSWORD || '' }}
  121. put_build_results_to_cache: ${{ inputs.put_build_results_to_cache }}
  122. test_retry_count: ${{ inputs.test_retry_count }}
  123. - name: build_stats
  124. shell: bash
  125. continue-on-error: true
  126. if: always()
  127. run: |
  128. set -x
  129. export build_preset="${{ inputs.build_preset }}"
  130. export commit_git_sha="$(git rev-parse HEAD)"
  131. python3 -m pip install ydb ydb[yc]
  132. python3 .github/scripts/send_build_stats.py
  133. - name: show_build_size_diff
  134. shell: bash
  135. continue-on-error: true
  136. if: always()
  137. env:
  138. GITHUB_TOKEN: ${{ github.token }}
  139. run: |
  140. set -x
  141. export build_preset="${{ inputs.build_preset }}"
  142. export branch_to_compare="$GITHUB_REF_NAME"
  143. export yellow_treshold=102400
  144. export red_treshold=2097152
  145. export commit_git_sha="$(git rev-parse HEAD)"
  146. python3 -m pip install ydb ydb[yc] humanize
  147. get_sizes_comment_script=.github/scripts/get_build_diff.py
  148. comment_raw=`$get_sizes_comment_script`
  149. IFS=';;;'
  150. read -ra comment_arr <<< "$comment_raw"
  151. printf "$comment"
  152. if [[ ${comment_raw} != "Error"* ]];then
  153. color=${comment_arr[0]}
  154. replace=$color";;;"
  155. comment=${comment_raw/$replace/""}
  156. printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
  157. else
  158. echo "Skipped build size difference, comment_raw = ${comment_raw}"
  159. fi
  160. - name: comment-if-cancel
  161. shell: bash
  162. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  163. env:
  164. BUILD_PRESET: ${{ inputs.build_preset }}
  165. GITHUB_TOKEN: ${{ github.token }}
  166. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black