build_and_test_ya_ondemand.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. sanitizer:
  14. type: choice
  15. default: "none"
  16. description: "sanitizer type"
  17. options:
  18. - none
  19. - address
  20. - memory
  21. - thread
  22. - undefined
  23. - leak
  24. run_build:
  25. type: boolean
  26. default: true
  27. description: "run build"
  28. run_tests:
  29. type: boolean
  30. default: true
  31. description: "run tests"
  32. workflow_call:
  33. inputs:
  34. image:
  35. type: string
  36. default: fd8earpjmhevh8h6ug5o
  37. build_target:
  38. type: string
  39. default: "ydb/"
  40. sanitizer:
  41. type: string
  42. default: "none"
  43. run_build:
  44. type: boolean
  45. default: true
  46. run_tests:
  47. type: boolean
  48. default: true
  49. jobs:
  50. provide-runner:
  51. name: Start self-hosted YC runner
  52. timeout-minutes: 5
  53. runs-on: ubuntu-latest
  54. outputs:
  55. label: ${{ steps.start-yc-runner.outputs.label }}
  56. instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
  57. steps:
  58. - name: Start YC runner
  59. id: start-yc-runner
  60. uses: yc-actions/yc-github-runner@v1
  61. with:
  62. mode: start
  63. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  64. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  65. folder-id: ${{ secrets.YC_FOLDER }}
  66. image-id: ${{ inputs.image }}
  67. disk-size: ${{ vars.DISK_SIZE && vars.DISK_SIZE || '1023GB' }}
  68. disk-type: network-ssd-nonreplicated
  69. cores: 64
  70. memory: 192GB
  71. core-fraction: 100
  72. zone-id: ru-central1-b
  73. subnet-id: ${{ secrets.YC_SUBNET }}
  74. prepare-vm:
  75. name: Prepare runner
  76. needs: provide-runner
  77. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  78. steps:
  79. - name: Checkout PR
  80. uses: actions/checkout@v3
  81. if: github.event.pull_request.head.sha != ''
  82. with:
  83. ref: ${{ github.event.pull_request.head.sha }}
  84. - name: Checkout
  85. uses: actions/checkout@v3
  86. if: github.event.pull_request.head.sha == ''
  87. - name: Prepare VM
  88. uses: ./.github/actions/prepare_vm
  89. main:
  90. uses: ./.github/workflows/build_and_test_ya.yml
  91. needs:
  92. - provide-runner
  93. - prepare-vm
  94. with:
  95. runner_kind: self-hosted
  96. runner_label: ${{ needs.provide-runner.outputs.label }}
  97. build_target: ${{ inputs.build_target }}
  98. sanitizer: ${{ inputs.sanitizer }}
  99. run_build: ${{ inputs.run_build }}
  100. run_tests: ${{ inputs.run_tests }}
  101. log_suffix: ya-x86-64${{ inputs.sanitizer != 'none' && format('-{0}', inputs.sanitizer) || '' }}
  102. secrets: inherit
  103. release-runner:
  104. name: Release self-hosted YC runner if provided on-demand
  105. needs:
  106. - provide-runner # required to get output from the start-runner job
  107. - main # required to wait when the main job is done
  108. runs-on: ubuntu-latest
  109. if: always()
  110. steps:
  111. - name: Stop YC runner
  112. uses: yc-actions/yc-github-runner@v1
  113. with:
  114. mode: stop
  115. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  116. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  117. label: ${{ needs.provide-runner.outputs.label }}
  118. instance-id: ${{ needs.provide-runner.outputs.instance-id }}