build_and_test_ya_ondemand.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. jobs:
  86. provide-runner:
  87. name: Start self-hosted YC runner
  88. timeout-minutes: 5
  89. runs-on: ubuntu-latest
  90. outputs:
  91. label: ${{ steps.start-yc-runner.outputs.label }}
  92. instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
  93. steps:
  94. - name: Start YC runner
  95. id: start-yc-runner
  96. uses: yc-actions/yc-github-runner@v1
  97. with:
  98. mode: start
  99. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  100. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  101. folder-id: ${{ secrets.YC_FOLDER }}
  102. image-id: ${{ inputs.image }}
  103. disk-size: ${{ vars.DISK_SIZE && vars.DISK_SIZE || '1023GB' }}
  104. disk-type: network-ssd-nonreplicated
  105. cores: 64
  106. memory: 192GB
  107. core-fraction: 100
  108. zone-id: ru-central1-b
  109. subnet-id: ${{ secrets.YC_SUBNET }}
  110. prepare-vm:
  111. name: Prepare runner
  112. needs: provide-runner
  113. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  114. steps:
  115. - name: Checkout PR
  116. uses: actions/checkout@v3
  117. if: github.event.pull_request.head.sha != ''
  118. with:
  119. ref: ${{ github.event.pull_request.head.sha }}
  120. - name: Checkout
  121. uses: actions/checkout@v3
  122. if: github.event.pull_request.head.sha == ''
  123. - name: Prepare VM
  124. uses: ./.github/actions/prepare_vm
  125. main:
  126. uses: ./.github/workflows/build_and_test_ya.yml
  127. needs:
  128. - provide-runner
  129. - prepare-vm
  130. with:
  131. runner_kind: self-hosted
  132. runner_label: ${{ needs.provide-runner.outputs.label }}
  133. build_target: ${{ inputs.build_target }}
  134. build_preset: ${{ inputs.build_preset }}
  135. run_build: ${{ inputs.run_build }}
  136. run_tests: ${{ inputs.run_tests }}
  137. test_size: ${{ inputs.test_size }}
  138. test_type: ${{ inputs.test_type }}
  139. link_threads: ${{ inputs.link_threads }}
  140. test_threads: ${{ inputs.test_threads }}
  141. secrets: inherit
  142. release-runner:
  143. name: Release self-hosted YC runner if provided on-demand
  144. needs:
  145. - provide-runner # required to get output from the start-runner job
  146. - main # required to wait when the main job is done
  147. runs-on: ubuntu-latest
  148. if: always()
  149. steps:
  150. - name: Stop YC runner
  151. uses: yc-actions/yc-github-runner@v1
  152. with:
  153. mode: stop
  154. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  155. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  156. label: ${{ needs.provide-runner.outputs.label }}
  157. instance-id: ${{ needs.provide-runner.outputs.instance-id }}