build_and_test_ondemand.yml 4.1 KB

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