build_and_test_ya_ondemand.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. name: Ya-Build-and-Test-On-demand
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. image:
  6. type: string
  7. default: fd8earpjmhevh8h6ug5o
  8. description: "VM image"
  9. build_target:
  10. type: string
  11. default: "ydb/"
  12. description: "limit build and test to specific target"
  13. build_preset:
  14. type: choice
  15. default: "relwithdebinfo"
  16. description: "Build preset"
  17. options:
  18. - debug
  19. - relwithdebinfo
  20. - release-asan
  21. - release-tsan
  22. - release-msan
  23. test_size:
  24. type: choice
  25. default: "small,medium,large"
  26. description: "test size to run"
  27. options:
  28. - small
  29. - small,medium
  30. - small,medium,large
  31. test_type:
  32. type: choice
  33. default: "unittest,py3test,py2test,pytest"
  34. description: "type of tests to run"
  35. options:
  36. - unittest
  37. - py3test,py2test,pytest
  38. - unittest,py3test,py2test,pytest
  39. test_threads:
  40. type: string
  41. default: "28"
  42. description: "Test threads count"
  43. link_threads:
  44. type: string
  45. default: "8"
  46. description: "link threads count"
  47. run_build:
  48. type: boolean
  49. default: true
  50. description: "run build"
  51. run_tests:
  52. type: boolean
  53. default: true
  54. description: "run tests"
  55. workflow_call:
  56. inputs:
  57. image:
  58. type: string
  59. default: fd8earpjmhevh8h6ug5o
  60. build_target:
  61. type: string
  62. default: "ydb/"
  63. build_preset:
  64. type: string
  65. default: "relwithdebinfo"
  66. test_size:
  67. type: string
  68. default: "small,medium,large"
  69. test_type:
  70. type: string
  71. default: "unittest,py3test,py2test,pytest"
  72. run_build:
  73. type: boolean
  74. default: true
  75. run_tests:
  76. type: boolean
  77. default: true
  78. test_threads:
  79. type: string
  80. default: 28
  81. description: "Test threads count"
  82. link_threads:
  83. type: string
  84. default: 8
  85. description: "link threads count"
  86. put_build_results_to_cache:
  87. type: boolean
  88. default: true
  89. jobs:
  90. provide-runner:
  91. name: Start self-hosted YC runner
  92. timeout-minutes: 5
  93. runs-on: ubuntu-latest
  94. outputs:
  95. label: ${{ steps.start-yc-runner.outputs.label }}
  96. instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
  97. steps:
  98. - name: Start YC runner
  99. id: start-yc-runner
  100. uses: yc-actions/yc-github-runner@v1
  101. with:
  102. mode: start
  103. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  104. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  105. folder-id: ${{ secrets.YC_FOLDER }}
  106. image-id: ${{ inputs.image }}
  107. disk-size: ${{ vars.DISK_SIZE && vars.DISK_SIZE || '1023GB' }}
  108. disk-type: network-ssd-nonreplicated
  109. cores: 64
  110. memory: 192GB
  111. core-fraction: 100
  112. zone-id: ru-central1-b
  113. subnet-id: ${{ secrets.YC_SUBNET }}
  114. prepare-vm:
  115. name: Prepare runner
  116. needs: provide-runner
  117. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  118. steps:
  119. - name: Checkout PR
  120. uses: actions/checkout@v3
  121. if: github.event.pull_request.head.sha != ''
  122. with:
  123. ref: ${{ github.event.pull_request.head.sha }}
  124. - name: Checkout
  125. uses: actions/checkout@v3
  126. if: github.event.pull_request.head.sha == ''
  127. - name: Prepare VM
  128. uses: ./.github/actions/prepare_vm
  129. main:
  130. uses: ./.github/workflows/build_and_test_ya.yml
  131. needs:
  132. - provide-runner
  133. - prepare-vm
  134. with:
  135. runner_label: ${{ needs.provide-runner.outputs.label }}
  136. build_target: ${{ inputs.build_target }}
  137. build_preset: ${{ inputs.build_preset }}
  138. run_build: ${{ inputs.run_build }}
  139. run_tests: ${{ inputs.run_tests }}
  140. test_size: ${{ inputs.test_size }}
  141. test_type: ${{ inputs.test_type }}
  142. link_threads: ${{ inputs.link_threads }}
  143. test_threads: ${{ inputs.test_threads }}
  144. put_build_results_to_cache: ${{ inputs.put_build_results_to_cache || true }}
  145. secrets: inherit
  146. release-runner:
  147. name: Release self-hosted YC runner if provided on-demand
  148. needs:
  149. - provide-runner # required to get output from the start-runner job
  150. - main # required to wait when the main job is done
  151. runs-on: ubuntu-latest
  152. if: always()
  153. steps:
  154. - name: Stop YC runner
  155. uses: yc-actions/yc-github-runner@v1
  156. with:
  157. mode: stop
  158. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  159. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  160. label: ${{ needs.provide-runner.outputs.label }}
  161. instance-id: ${{ needs.provide-runner.outputs.instance-id }}