action.yml 6.3 KB

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