build_and_test_ya_ondemand.yml 4.6 KB

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