aboutsummaryrefslogtreecommitdiffstats
path: root/.github/actions/build_ya/action.yml
blob: df56694d0ee01d91ac6e7f5ea89f4b6f0c00d8c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Build (ya make)
description: Build targets
inputs:
  build_target:
    required: false
    description: "build target"
  build_preset:
    required: true
    default: "relwithdebinfo"
    description: "debug, relwithdebinfo, release-asan, release-tsan, release, release-cmake14"
  bazel_remote_uri:
    required: false
    description: "bazel-remote endpoint"
  bazel_remote_username:
    required: false
    description: "bazel-remote username"
  bazel_remote_password:
    required: false
    description: "bazel-remote password"
  link_threads:
    required: false
    default: "8"
    description: "link threads count"
outputs:
  success:
    value: ${{ steps.build.outputs.status }}
    description: "build success"
  log_url:
    value: ${{ steps.init.outputs.log_url }}
    description: "build log url"
runs:
  using: "composite"
  steps:
    - name: Init
      id: init
      shell: bash
      env:
        build_preset: ${{ inputs.build_preset }}
      run: |
        echo "SHELLOPTS=xtrace" >> $GITHUB_ENV
        export TMP_DIR=$(pwd)/tmp_build
        echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
        
        export log_url="$S3_URL_PREFIX/build_logs/ya_make.log"
        
        rm -rf $TMP_DIR && mkdir $TMP_DIR
        
        echo "BUILD_PRESET=$build_preset" >> $GITHUB_ENV
        echo "GITHUB_TOKEN=${{ github.token }}" >> $GITHUB_ENV
        echo "LOG_URL=$log_url" >> $GITHUB_ENV
        echo "log_url=$log_url" >> $GITHUB_OUTPUT

    - name: build
      id: build
      shell: bash
      run: |
        extra_params=()

        if [ ! -z "${{ inputs.build_target }}" ]; then
          extra_params+=(--target="${{ inputs.build_target }}")
        fi

        if [ ! -z "${{ inputs.bazel_remote_uri }}" ]; then
          extra_params+=(--bazel-remote-store)
          extra_params+=(--bazel-remote-base-uri "${{ inputs.bazel_remote_uri }}")
        fi
        
        if [ ! -z "${{ inputs.bazel_remote_username }}" ]; then
          extra_params+=(--bazel-remote-username "${{ inputs.bazel_remote_username }}")
          extra_params+=(--bazel-remote-password "${{ inputs.bazel_remote_password }}")
          extra_params+=(--bazel-remote-put --dist-cache-evict-bins --add-result .o --add-result .a)
        fi
        
        case "${{ inputs.build_preset }}" in
          debug)
            build_type=debug
            ;;
          relwithdebinfo)
            build_type=relwithdebinfo
            ;;
          release)
            build_type=release
            ;;
          release-clang14)
            build_type=release
            extra_params+=(--target-platform="CLANG14-LINUX-X86_64")
            extra_params+=(-DLLD_VERSION=16)
            ;;
          release-asan)
            build_type=release
            extra_params+=(--sanitize="address")
            extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
            ;;
          release-tsan)
            build_type=release
            extra_params+=(--sanitize="thread")
            extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
            ;;
          release-msan)
            build_type=release
            extra_params+=(--sanitize="memory")
            extra_params+=(-DSKIP_JUNK -DUSE_EAT_MY_DATA -DDEBUGINFO_LINES_ONLY)
            ;;
          *)
            echo "Invalid preset: ${{ inputs.build_preset }}"
            exit 1
            ;;
        esac
        
        echo "::debug::get version"
        ./ya --version
        
        echo "Build **{platform_name}-${BUILD_PRESET}** is running..." | .github/scripts/tests/comment-pr.py
        
        # to be sure
        set -o pipefail
        
        ./ya make -k --build "${build_type}" --force-build-depends -D'BUILD_LANGUAGES=CPP PY3 PY2 GO' -T --stat -DCONSISTENT_DEBUG \
          --log-file "$TMP_DIR/ya_log.txt" --evlog-file "$TMP_DIR/ya_evlog.jsonl" \
          --cache-size 512G --link-threads "${{ inputs.link_threads }}" \
          "${extra_params[@]}" |& tee $TMP_DIR/ya_make.log && echo "status=true" >> $GITHUB_OUTPUT || (
              RC=$?
              echo "::debug::ya make RC=$RC"
              echo "status=failed" >> $GITHUB_OUTPUT
          )

    - name: sync logs to s3
      if: always()
      shell: bash
      run: |
        echo "::group::s3-sync"
        s3cmd sync --acl-private --exclude="ya_make.log" --no-progress --stats --no-check-md5 "$TMP_DIR/" "$S3_BUCKET_PATH/build_logs/"
        s3cmd sync --acl-public --no-progress --stats --no-check-md5 "$TMP_DIR/ya_make.log" "$S3_BUCKET_PATH/build_logs/"
        echo "::endgroup::"

    - name: comment-build-status
      if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
      shell: bash
      run: |
        if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
          echo "Build failed. see the [build logs]($LOG_URL)." | .github/scripts/tests/comment-pr.py --fail
        else
          echo "Build successful." | .github/scripts/tests/comment-pr.py --ok
        fi

    - name: show free space
      if: always()
      shell: bash
      run: df -h