build_and_test_ondemand.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. name: Build-and-Test-On-demand
  2. on:
  3. workflow_call:
  4. inputs:
  5. sanitizer:
  6. required: false
  7. type: string
  8. test_label_regexp:
  9. required: false
  10. type: string
  11. image:
  12. type: string
  13. required: false
  14. default: fd8earpjmhevh8h6ug5o
  15. extra_compile_flags:
  16. required: false
  17. type: string
  18. run_unit_tests:
  19. type: boolean
  20. default: true
  21. run_functional_tests:
  22. type: boolean
  23. default: true
  24. workflow_dispatch:
  25. inputs:
  26. sanitizer:
  27. required: false
  28. type: string
  29. test_label_regexp:
  30. required: false
  31. type: string
  32. image:
  33. type: string
  34. required: false
  35. default: fd8earpjmhevh8h6ug5o
  36. extra_compile_flags:
  37. required: false
  38. type: string
  39. run_unit_tests:
  40. type: boolean
  41. default: true
  42. run_functional_tests:
  43. type: boolean
  44. default: true
  45. jobs:
  46. provide-runner:
  47. name: Start self-hosted YC runner
  48. timeout-minutes: 5
  49. runs-on: ubuntu-latest
  50. outputs:
  51. label: ${{steps.start-yc-runner.outputs.label}}
  52. instance-id: ${{steps.start-yc-runner.outputs.instance-id}}
  53. steps:
  54. - name: Start YC runner
  55. id: start-yc-runner
  56. uses: yc-actions/yc-github-runner@v1
  57. with:
  58. mode: start
  59. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  60. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  61. folder-id: ${{secrets.YC_FOLDER}}
  62. image-id: ${{inputs.image}}
  63. disk-size: ${{vars.DISK_SIZE && vars.DISK_SIZE || '1023GB'}}
  64. disk-type: network-ssd-nonreplicated
  65. cores: 32
  66. memory: 128GB
  67. core-fraction: 100
  68. zone-id: ru-central1-b
  69. subnet-id: ${{secrets.YC_SUBNET}}
  70. prepare-vm:
  71. name: Prepare runner
  72. needs: provide-runner
  73. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  74. steps:
  75. - name: Checkout PR
  76. uses: actions/checkout@v3
  77. if: github.event.pull_request.head.sha != ''
  78. with:
  79. ref: ${{ github.event.pull_request.head.sha }}
  80. - name: Checkout
  81. uses: actions/checkout@v3
  82. if: github.event.pull_request.head.sha == ''
  83. - name: Prepare VM
  84. uses: ./.github/actions/prepare_vm
  85. main:
  86. name: Build and test
  87. needs:
  88. - provide-runner
  89. - prepare-vm
  90. runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
  91. steps:
  92. - name: Checkout PR
  93. uses: actions/checkout@v3
  94. if: github.event.pull_request.head.sha != ''
  95. with:
  96. ref: ${{ github.event.pull_request.head.sha }}
  97. - name: Checkout
  98. uses: actions/checkout@v3
  99. if: github.event.pull_request.head.sha == ''
  100. - name: Build
  101. id: build
  102. uses: ./.github/actions/build
  103. with:
  104. sanitizer: ${{ inputs.sanitizer }}
  105. ccache_remote_path: ${{ vars.REMOTE_CACHE_URL && format('http://{0}{1}', secrets.REMOTE_CACHE_AUTH, vars.REMOTE_CACHE_URL) || ''}}
  106. extra_compile_flags: ${{ inputs.extra_compile_flags }}
  107. - name: Run tests
  108. uses: ./.github/actions/test
  109. with:
  110. log_suffix: ${{ inputs.sanitizer != '' && format('{0}-{1}', 'x86_64', inputs.sanitizer) || 'x86_64' }}
  111. test_label_regexp: ${{ inputs.test_label_regexp }}
  112. aws_key_id: ${{secrets.AWS_KEY_ID}}
  113. aws_key_value: ${{secrets.AWS_KEY_VALUE}}
  114. aws_bucket: ${{vars.AWS_BUCKET}}
  115. aws_endpoint: ${{vars.AWS_ENDPOINT}}
  116. testman_token: ${{secrets.TESTMO_TOKEN}}
  117. testman_url: ${{vars.TESTMO_URL}}
  118. testman_project_id: ${{vars.TESTMO_PROJECT_ID}}
  119. run_unit_tests: ${{inputs.run_unit_tests}}
  120. run_functional_tests: ${{inputs.run_functional_tests}}
  121. release-runner:
  122. name: Release self-hosted YC runner if provided on-demand
  123. needs:
  124. - provide-runner # required to get output from the start-runner job
  125. - main # required to wait when the main job is done
  126. runs-on: ubuntu-latest
  127. if: always()
  128. steps:
  129. - name: Stop YC runner
  130. uses: yc-actions/yc-github-runner@v1
  131. with:
  132. mode: stop
  133. yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
  134. github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  135. label: ${{ needs.provide-runner.outputs.label }}
  136. instance-id: ${{ needs.provide-runner.outputs.instance-id }}