build_and_test_ya_ondemand.yml 4.6 KB

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