action.yml 5.0 KB

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