action.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. put_build_results_to_cache:
  12. required: false
  13. default: "true"
  14. bazel_remote_uri:
  15. required: false
  16. description: "bazel-remote endpoint"
  17. bazel_remote_username:
  18. required: false
  19. description: "bazel-remote username"
  20. bazel_remote_password:
  21. required: false
  22. description: "bazel-remote password"
  23. link_threads:
  24. required: false
  25. default: "8"
  26. description: "link threads count"
  27. additional_ya_make_args:
  28. type: string
  29. default: ""
  30. outputs:
  31. success:
  32. value: ${{ steps.build.outputs.status }}
  33. description: "build success"
  34. log_url:
  35. value: ${{ steps.init.outputs.log_url }}
  36. description: "build log url"
  37. runs:
  38. using: "composite"
  39. steps:
  40. - name: Init
  41. id: init
  42. shell: bash
  43. env:
  44. build_preset: ${{ inputs.build_preset }}
  45. run: |
  46. export TMP_DIR=$(pwd)/tmp_build
  47. echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
  48. export log_url="$S3_URL_PREFIX/build_logs/ya_make.log"
  49. rm -rf $TMP_DIR && mkdir $TMP_DIR
  50. echo "BUILD_PRESET=$build_preset" >> $GITHUB_ENV
  51. echo "GITHUB_TOKEN=${{ github.token }}" >> $GITHUB_ENV
  52. echo "LOG_URL=$log_url" >> $GITHUB_ENV
  53. echo "log_url=$log_url" >> $GITHUB_OUTPUT
  54. - name: build
  55. id: build
  56. shell: bash
  57. run: |
  58. set -x
  59. extra_params=()
  60. if [ ! -z "${{ inputs.build_target }}" ]; then
  61. extra_params+=(--target="${{ inputs.build_target }}")
  62. fi
  63. if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
  64. extra_params+=(--bazel-remote-store)
  65. extra_params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
  66. fi
  67. if [ "${{ inputs.put_build_results_to_cache }}" = "true" ]; then
  68. extra_params+=(--bazel-remote-username "${{ inputs.bazel_remote_username }}")
  69. extra_params+=(--bazel-remote-password "${{ inputs.bazel_remote_password }}")
  70. extra_params+=(--bazel-remote-put --dist-cache-evict-bins --add-result .o --add-result .a)
  71. fi
  72. case "${{ inputs.build_preset }}" in
  73. debug)
  74. build_type=debug
  75. ;;
  76. relwithdebinfo)
  77. build_type=relwithdebinfo
  78. ;;
  79. release)
  80. build_type=release
  81. ;;
  82. release-clang14)
  83. build_type=release
  84. extra_params+=(--target-platform="CLANG14-LINUX-X86_64")
  85. extra_params+=(-DLLD_VERSION=16)
  86. ;;
  87. release-asan)
  88. build_type=release
  89. extra_params+=(--sanitize="address")
  90. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  91. ;;
  92. release-tsan)
  93. build_type=release
  94. extra_params+=(--sanitize="thread")
  95. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  96. ;;
  97. release-msan)
  98. build_type=release
  99. extra_params+=(--sanitize="memory")
  100. extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
  101. ;;
  102. *)
  103. echo "Invalid preset: ${{ inputs.build_preset }}"
  104. exit 1
  105. ;;
  106. esac
  107. if [ ! -z "${{ inputs.additional_ya_make_args }}" ]; then
  108. extra_params+=(${{ inputs.additional_ya_make_args }})
  109. fi
  110. echo "::debug::get version"
  111. ./ya --version
  112. echo "Build **{platform_name}-${BUILD_PRESET}** is running..." | .github/scripts/tests/comment-pr.py
  113. # to be sure
  114. set -o pipefail
  115. ./ya make -k --build "${build_type}" --force-build-depends -T --stat -DCONSISTENT_DEBUG \
  116. --log-file "$TMP_DIR/ya_log.txt" --evlog-file "$TMP_DIR/ya_evlog.jsonl" \
  117. --cache-size 512G --link-threads "${{ inputs.link_threads }}" \
  118. "${extra_params[@]}" |& tee $TMP_DIR/ya_make.log && echo "status=true" >> $GITHUB_OUTPUT || (
  119. RC=$?
  120. echo "::debug::ya make RC=$RC"
  121. echo "status=failed" >> $GITHUB_OUTPUT
  122. )
  123. - name: sync logs to s3
  124. if: always()
  125. shell: bash
  126. run: |
  127. set -x
  128. echo "::group::s3-sync"
  129. s3cmd sync --acl-private --exclude="ya_make.log" --no-progress --stats --no-check-md5 "$TMP_DIR/" "$S3_BUCKET_PATH/build_logs/"
  130. s3cmd sync --acl-public --no-progress --stats --no-check-md5 "$TMP_DIR/ya_make.log" "$S3_BUCKET_PATH/build_logs/"
  131. echo "::endgroup::"
  132. - name: comment-build-status
  133. if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
  134. shell: bash
  135. run: |
  136. set -x
  137. if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
  138. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  139. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  140. -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
  141. echo "Build failed. see the [build logs]($LOG_URL)." | .github/scripts/tests/comment-pr.py --fail
  142. else
  143. curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
  144. https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
  145. -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
  146. echo "Build successful." | .github/scripts/tests/comment-pr.py --ok
  147. fi
  148. - name: show free space
  149. if: always()
  150. shell: bash
  151. run: df -h