action.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. name: Build (ya make)
  2. description: Build targets
  3. inputs:
  4. build_target:
  5. required: false
  6. description: "build target"
  7. build_preset:
  8. required: true
  9. default: "relwithdebinfo"
  10. description: "relwithdebinfo, release-asan, release-tsan"
  11. bazel_remote_uri:
  12. required: false
  13. description: "bazel-remote endpoint"
  14. bazel_remote_username:
  15. required: false
  16. description: "bazel-remote username"
  17. bazel_remote_password:
  18. required: false
  19. description: "bazel-remote password"
  20. link_threads:
  21. required: false
  22. default: "8"
  23. description: "link threads count"
  24. runs:
  25. using: "composite"
  26. steps:
  27. - name: Init
  28. id: init
  29. shell: bash
  30. env:
  31. build_preset: ${{ inputs.build_preset }}
  32. run: |
  33. echo "SHELLOPTS=xtrace" >> $GITHUB_ENV
  34. export TMP_DIR=$(pwd)/tmp_build
  35. echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
  36. rm -rf $TMP_DIR && mkdir $TMP_DIR
  37. echo "BUILD_PRESET=$build_preset" >> $GITHUB_ENV
  38. echo "GITHUB_TOKEN=${{ github.token }}" >> $GITHUB_ENV
  39. - name: build
  40. id: build
  41. shell: bash
  42. run: |
  43. extra_params=()
  44. if [ ! -z "${{ inputs.build_target }}" ]; then
  45. extra_params+=(--target="${{ inputs.build_target }}")
  46. fi
  47. if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
  48. extra_params+=(--bazel-remote-store)
  49. extra_params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
  50. fi
  51. if [ ! -z "${{ inputs.bazel_remote_username }}" ]; then
  52. extra_params+=(--bazel-remote-username "${{ inputs.bazel_remote_username }}")
  53. extra_params+=(--bazel-remote-password "${{ inputs.bazel_remote_password }}")
  54. extra_params+=(--bazel-remote-put --dist-cache-evict-bins --add-result .o --add-result .a)
  55. fi
  56. case "${{ inputs.build_preset }}" in
  57. debug)
  58. build_type=debug
  59. ;;
  60. relwithdebinfo)
  61. build_type=relwithdebinfo
  62. ;;
  63. release-asan)
  64. build_type=release
  65. extra_params+=(--sanitize="address")
  66. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  67. ;;
  68. release-tsan)
  69. build_type=release
  70. extra_params+=(--sanitize="thread")
  71. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  72. ;;
  73. release-msan)
  74. build_type=release
  75. extra_params+=(--sanitize="memory")
  76. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  77. ;;
  78. *)
  79. echo "Invalid preset: ${{ inputs.build_preset }}"
  80. exit 1
  81. ;;
  82. esac
  83. echo "::debug::get version"
  84. ./ya --version
  85. echo "Build **{platform_name}-${BUILD_PRESET}** is running..." | .github/scripts/tests/comment-pr.py
  86. # to be sure
  87. set -o pipefail
  88. ./ya make -k --build "${build_type}" --force-build-depends -D'BUILD_LANGUAGES=CPP PY3 PY2 GO' -T --stat -DCONSISTENT_DEBUG \
  89. --log-file "$TMP_DIR/ya_log.txt" --evlog-file "$TMP_DIR/ya_evlog.jsonl" \
  90. --cache-size 512G --link-threads "${{ inputs.link_threads }}" \
  91. "${extra_params[@]}" |& tee $TMP_DIR/ya_make.log || (
  92. RC=$?
  93. echo "::debug::ya make RC=$RC"
  94. echo "status=failed" >> $GITHUB_OUTPUT
  95. )
  96. - name: sync logs to s3
  97. if: always()
  98. shell: bash
  99. run: |
  100. echo "::group::s3-sync"
  101. s3cmd sync --acl-private --exclude="ya_make.log" --no-progress --stats --no-check-md5 "$TMP_DIR/" "$S3_BUCKET_PATH/build_logs/"
  102. s3cmd sync --acl-public --no-progress --stats --no-check-md5 "$TMP_DIR/ya_make.log" "$S3_BUCKET_PATH/build_logs/"
  103. echo "::endgroup::"
  104. - name: comment-build-status
  105. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  106. shell: bash
  107. run: |
  108. log_url="$S3_URL_PREFIX/build_logs/ya_make.log"
  109. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  110. echo "Build failed. see the [build logs]($log_url)." | .github/scripts/tests/comment-pr.py --fail
  111. else
  112. echo "Build successful." | .github/scripts/tests/comment-pr.py --ok
  113. fi
  114. - name: show free space
  115. if: always()
  116. shell: bash
  117. run: df -h