123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- name: Ya-Build-and-Test
- inputs:
- build_target:
- type: string
- default: "ydb/"
- description: "limit build and test to specific target"
- build_preset:
- type: string
- run_build:
- type: boolean
- default: true
- description: "run build"
- run_tests:
- type: boolean
- default: true
- description: "run tests"
- test_threads:
- type: string
- default: 28
- description: "Test threads count"
- link_threads:
- type: string
- default: 12
- description: "link threads count"
- test_size:
- type: string
- default: "small,medium,large"
- test_type:
- type: string
- default: ""
- description: "run only specific test types (or all by default)"
- increment:
- type: boolean
- required: true
- description: If true, compares build graphs between the current and previous commits to find a list of test suites to run. Otherwise, runs all tests.
- folder_prefix:
- type: string
- default: "ya-"
- put_build_results_to_cache:
- type: boolean
- default: true
- additional_ya_make_args:
- type: string
- default: ""
- test_retry_count:
- default: ""
- description: "how many times to retry failed tests"
- secs:
- type: string
- default: ""
- vars:
- type: string
- default: ""
- defaults:
- run:
- shell: bash
- runs:
- using: "composite"
- steps:
- - name: comment-build-start
- if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
- shell: bash
- env:
- BUILD_PRESET: ${{ inputs.build_preset }}
- GITHUB_TOKEN: ${{ github.token }}
- run: |
- jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
- # tricky: we are searching job with name that contains build_preset
- check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
-
- platform_name="$(echo "$(uname -s)-$(uname -p)" | tr '[:upper:]' '[:lower:]')-$BUILD_PRESET"
- echo "Pre-commit [check]($check_url) **$platform_name** for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
- curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
- https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
- -d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}'
- if [[ "${{inputs.run_tests}}" == "true" ]];then
- curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
- https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
- -d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}'
- fi
-
- - name: Clean ya cache
- shell: bash
- run: rm -rf ~/.ya
- - name: Prepare s3cmd
- uses: ./.github/actions/s3cmd
- with:
- s3_bucket: ${{ fromJSON( inputs.vars ).AWS_BUCKET }}
- s3_endpoint: ${{ fromJSON( inputs.vars ).AWS_ENDPOINT }}
- s3_key_id: ${{ fromJSON( inputs.secs ).AWS_KEY_ID }}
- s3_key_secret: ${{ fromJSON( inputs.secs ).AWS_KEY_VALUE }}
- folder_prefix: ya-
- build_preset: ${{ inputs.build_preset }}
- - name: Generate ya.make with affected test suites and modules list
- if: inputs.increment == 'true'
- uses: ./.github/actions/graph_compare
-
- - name: Change target in case of incremental
- id: target_choice
- shell: bash
- run: |
- if [ "${{ inputs.increment }}" == "true" ]; then
- echo "target=." >> $GITHUB_OUTPUT
- else
- echo "target=${{ inputs.build_target }}" >> $GITHUB_OUTPUT
- fi
- - name: Run build and tests
- id: build
- uses: ./.github/actions/test_ya
- with:
- build_target: ${{ steps.target_choice.outputs.target }}
- build_preset: ${{ inputs.build_preset }}
- test_size: ${{ inputs.test_size }}
- test_type: ${{ inputs.test_type }}
- run_tests: ${{ inputs.run_tests }}
- testman_token: ${{ fromJSON( inputs.secs ).TESTMO_TOKEN2 }}
- testman_url: ${{ fromJSON( inputs.vars ).TESTMO_URL }}
- testman_project_id: ${{ fromJSON( inputs.vars ).TESTMO_PROJECT_ID }}
- link_threads: ${{ inputs.link_threads }}
- additional_ya_make_args: ${{ inputs.additional_ya_make_args }}
- test_threads: ${{ inputs.test_threads }}
- bazel_remote_uri: ${{ fromJSON( inputs.vars ).REMOTE_CACHE_URL || '' }}
- bazel_remote_username: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_USERNAME || '' }}
- bazel_remote_password: ${{ fromJSON( inputs.secs ).REMOTE_CACHE_PASSWORD || '' }}
- put_build_results_to_cache: ${{ inputs.put_build_results_to_cache }}
- test_retry_count: ${{ inputs.test_retry_count }}
-
- - name: build_stats
- shell: bash
- continue-on-error: true
- if: always()
- run: |
- set -x
- export build_preset="${{ inputs.build_preset }}"
- export commit_git_sha="$(git rev-parse HEAD)"
- python3 -m pip install ydb ydb[yc]
- python3 .github/scripts/send_build_stats.py
- - name: show_build_size_diff
- shell: bash
- continue-on-error: true
- if: always()
- env:
- GITHUB_TOKEN: ${{ github.token }}
- run: |
- set -x
- export build_preset="${{ inputs.build_preset }}"
- export branch_to_compare="$GITHUB_REF_NAME"
- export yellow_treshold=102400
- export red_treshold=2097152
- export commit_git_sha="$(git rev-parse HEAD)"
- python3 -m pip install ydb ydb[yc] humanize
- get_sizes_comment_script=.github/scripts/get_build_diff.py
- comment_raw=`$get_sizes_comment_script`
-
- IFS=';;;'
- read -ra comment_arr <<< "$comment_raw"
- printf "$comment"
- if [[ ${comment_raw} != "Error"* ]];then
- color=${comment_arr[0]}
- replace=$color";;;"
- comment=${comment_raw/$replace/""}
-
- printf "$comment" | .github/scripts/tests/comment-pr.py --color $color
- else
- echo "Skipped build size difference, comment_raw = ${comment_raw}"
- fi
- - name: comment-if-cancel
- shell: bash
- if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
- env:
- BUILD_PRESET: ${{ inputs.build_preset }}
- GITHUB_TOKEN: ${{ github.token }}
- run: echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black
|