build_and_test_ya.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: Ya-Build-and-Test
  2. on:
  3. workflow_call:
  4. inputs:
  5. build_target:
  6. type: string
  7. default: "ydb/"
  8. description: "limit build and test to specific target"
  9. build_preset:
  10. type: string
  11. runner_label:
  12. type: string
  13. default: "linux"
  14. description: "runner label"
  15. runner_additional_label:
  16. type: string
  17. default: "linux"
  18. description: "additional runner label, can be empty"
  19. run_build:
  20. type: boolean
  21. default: true
  22. description: "run build"
  23. run_tests:
  24. type: boolean
  25. default: true
  26. description: "run tests"
  27. test_threads:
  28. type: string
  29. default: 28
  30. description: "Test threads count"
  31. link_threads:
  32. type: string
  33. default: 8
  34. description: "link threads count"
  35. test_size:
  36. type: string
  37. default: "small,medium,large"
  38. test_type:
  39. type: string
  40. default: "unittest,py3test,py2test,pytest"
  41. folder_prefix:
  42. type: string
  43. default: "ya-"
  44. cache_tests:
  45. type: boolean
  46. default: false
  47. description: "Use cache for tests"
  48. put_build_results_to_cache:
  49. type: boolean
  50. default: true
  51. commit_sha:
  52. type: string
  53. default: ""
  54. defaults:
  55. run:
  56. shell: bash
  57. jobs:
  58. main:
  59. name: Build and test ${{ inputs.build_preset }}
  60. runs-on: [ self-hosted, "${{ inputs.runner_label }}", "${{ inputs.runner_additional_label || inputs.runner_label }}"]
  61. steps:
  62. - name: Checkout
  63. uses: actions/checkout@v3
  64. with:
  65. ref: ${{ inputs.commit_sha }}
  66. - name: comment-build-start
  67. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  68. shell: bash
  69. env:
  70. BUILD_PRESET: ${{ inputs.build_preset }}
  71. GITHUB_TOKEN: ${{ github.token }}
  72. run: |
  73. jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
  74. # tricky: we are searching job with name that contains build_preset
  75. check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
  76. echo "Pre-commit [check]($check_url) for ${{ inputs.commit_sha }} has started." | .github/scripts/tests/comment-pr.py --rewrite
  77. - name: Prepare s3cmd
  78. uses: ./.github/actions/s3cmd
  79. with:
  80. s3_bucket: ${{ vars.AWS_BUCKET }}
  81. s3_endpoint: ${{ vars.AWS_ENDPOINT }}
  82. s3_key_id: ${{ secrets.AWS_KEY_ID }}
  83. s3_key_secret: ${{ secrets.AWS_KEY_VALUE }}
  84. folder_prefix: ya-
  85. build_preset: ${{ inputs.build_preset }}
  86. - name: Build
  87. uses: ./.github/actions/build_ya
  88. if: inputs.run_build
  89. with:
  90. build_target: ${{ inputs.build_target }}
  91. build_preset: ${{ inputs.build_preset }}
  92. bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
  93. bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
  94. bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
  95. link_threads: ${{ inputs.link_threads }}
  96. - name: Run tests
  97. uses: ./.github/actions/test_ya
  98. if: inputs.run_tests
  99. with:
  100. build_target: ${{ inputs.build_target }}
  101. build_preset: ${{ inputs.build_preset }}
  102. test_size: ${{ inputs.test_size }}
  103. test_type: ${{ inputs.test_type }}
  104. testman_token: ${{ secrets.TESTMO_TOKEN }}
  105. testman_url: ${{ vars.TESTMO_URL }}
  106. testman_project_id: ${{ vars.TESTMO_PROJECT_ID }}
  107. bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
  108. bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
  109. bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
  110. link_threads: ${{ inputs.link_threads }}
  111. test_threads: ${{ inputs.test_threads }}
  112. - name: comment-if-cancel
  113. if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
  114. env:
  115. BUILD_PRESET: ${{ inputs.build_preset }}
  116. GITHUB_TOKEN: ${{ github.token }}
  117. run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black