build_and_test_ya_ondemand.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. jobs:
  33. provide-runner:
  34. name: Start self-hosted YC runner
  35. timeout-minutes: 5
  36. runs-on: ubuntu-latest
  37. outputs:
  38. label: ${{ steps.start-yc-runner.outputs.label }}
  39. instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
  40. steps:
  41. - name: Start YC runner
  42. id: start-yc-runner
  43. uses: yc-actions/yc-github-runner@v1
  44. with:
  45. mode: start
  46. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  47. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  48. folder-id: ${{ secrets.YC_FOLDER }}
  49. image-id: ${{ inputs.image }}
  50. disk-size: ${{ vars.DISK_SIZE && vars.DISK_SIZE || '1023GB' }}
  51. disk-type: network-ssd-nonreplicated
  52. cores: 32
  53. memory: 256GB
  54. core-fraction: 100
  55. zone-id: ru-central1-b
  56. subnet-id: ${{ secrets.YC_SUBNET }}
  57. prepare-vm:
  58. name: Prepare runner
  59. needs: provide-runner
  60. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  61. steps:
  62. - name: Checkout PR
  63. uses: actions/checkout@v3
  64. if: github.event.pull_request.head.sha != ''
  65. with:
  66. ref: ${{ github.event.pull_request.head.sha }}
  67. - name: Checkout
  68. uses: actions/checkout@v3
  69. if: github.event.pull_request.head.sha == ''
  70. - name: Prepare VM
  71. uses: ./.github/actions/prepare_vm
  72. main:
  73. uses: ./.github/workflows/build_and_test_ya.yml
  74. needs:
  75. - provide-runner
  76. - prepare-vm
  77. with:
  78. runner_kind: self-hosted
  79. runner_label: ${{ needs.provide-runner.outputs.label }}
  80. build_target: ${{ inputs.build_target }}
  81. sanitizer: ${{ inputs.sanitizer }}
  82. run_build: ${{ inputs.run_build }}
  83. run_tests: ${{ inputs.run_tests }}
  84. log_suffix: ya-x86-64${{ inputs.sanitizer != 'none' && format('-{1}', inputs.sanitizer) || '' }}
  85. secrets: inherit
  86. release-runner:
  87. name: Release self-hosted YC runner if provided on-demand
  88. needs:
  89. - provide-runner # required to get output from the start-runner job
  90. - main # required to wait when the main job is done
  91. runs-on: ubuntu-latest
  92. if: always()
  93. steps:
  94. - name: Stop YC runner
  95. uses: yc-actions/yc-github-runner@v1
  96. with:
  97. mode: stop
  98. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  99. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  100. label: ${{ needs.provide-runner.outputs.label }}
  101. instance-id: ${{ needs.provide-runner.outputs.instance-id }}