build_and_test_ya_ondemand.yml 4.8 KB

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