123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- name: Run tests (ya make)
- description: Run tests using ya make
- inputs:
- build_target:
- required: false
- description: "build target"
- build_preset:
- required: true
- default: "relwithdebinfo"
- description: "relwithdebinfo, release-asan, release-tsan"
-
- test_size:
- required: false
- default: "small,medium,large"
- description: "small or small-medium or all"
-
- test_type:
- required: false
- default: "unittest,py3test,py2test,pytest"
- description: "run "
-
- test_threads:
- required: false
- default: "28"
- description: "Test threads count"
- link_threads:
- required: false
- default: "8"
- description: "link threads count"
- testman_token:
- required: false
- description: "test manager auth token"
- testman_url:
- required: false
- description: "test manager endpoint"
- testman_project_id:
- required: false
- description: "test manager project id"
- bazel_remote_uri:
- required: false
- description: "bazel-remote endpoint"
- cache_tests:
- required: false
- description: "Use cache for tests"
- runs:
- using: "composite"
- steps:
- - name: Init
- id: init
- shell: bash
- run: |
- echo "SHELLOPTS=xtrace" >> $GITHUB_ENV
- export TMP_DIR=$(pwd)/tmp
- echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
- echo "LOG_DIR=$TMP_DIR/logs" >> $GITHUB_ENV
- echo "OUT_DIR=$TMP_DIR/out" >> $GITHUB_ENV
- echo "ARTIFACTS_DIR=$TMP_DIR/artifacts" >> $GITHUB_ENV
- echo "JUNIT_REPORT_XML=$TMP_DIR/junit.xml" >> $GITHUB_ENV
- echo "TESTMO_TOKEN=${{ inputs.testman_token }}" >> $GITHUB_ENV
- echo "TESTMO_URL=${{ inputs.testman_url }}" >> $GITHUB_ENV
- echo "SUMMARY_LINKS=$(mktemp)" >> $GITHUB_ENV
-
- - name: prepare
- shell: bash
- run: |
- rm -rf $TMP_DIR $JUNIT_REPORT_XML
- mkdir -p $TMP_DIR $OUT_DIR $ARTIFACTS_DIR $LOG_DIR
-
- - name: Install Node required for Testmo CLI
- uses: actions/setup-node@v3
- with:
- node-version: 19
-
- - name: Install Testmo CLI
- shell: bash
- run: npm install -g @testmo/testmo-cli
- - name: Test history run create
- id: th
- if: inputs.testman_token
- shell: bash
- env:
- PR_NUMBER: ${{ github.event.number }}
- run: |
- RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
- BRANCH_TAG="$GITHUB_REF_NAME"
- ARCH="${{ runner.arch == 'X64' && 'x86-64' || runner.arch == 'ARM64' && 'arm64' || 'unknown' }}"
-
-
- case "${{ inputs.build_preset }}" in
- relwithdebinfo)
- TESTMO_SOURCE="ya-${ARCH}"
- ;;
- release-asan)
- TESTMO_SOURCE="ya-${ARCH}-asan"
- ;;
- release-tsan)
- TESTMO_SOURCE="ya-${ARCH}-tsan"
- ;;
- *)
- echo "Invalid preset: ${{ inputs.build_preset }}"
- exit 1
- ;;
- esac
-
- case $GITHUB_EVENT_NAME in
- workflow_dispatch)
- TESTMO_RUN_NAME="${{ github.run_id }} manual"
- EXTRA_TAG="manual"
- ;;
- pull_request | pull_request_target)
- TESTMO_RUN_NAME="${{ github.run_id }} PR #${PR_NUMBER}"
- EXTRA_TAG="pr"
- BRANCH_TAG=""
- ;;
- schedule)
- TESTMO_RUN_NAME="${{ github.run_id }} schedule"
- EXTRA_TAG="schedule"
- ;;
- *)
- TESTMO_RUN_NAME="${{ github.run_id }}"
- EXTRA_TAG=""
- ;;
- esac
-
- testmo automation:resources:add-link --name build --url "$RUN_URL" --resources testmo.json
- testmo automation:resources:add-field --name git-sha --type string --value "${GITHUB_SHA:0:7}" --resources testmo.json
- RUN_ID=$(
- testmo automation:run:create --instance "$TESTMO_URL" --project-id ${{ inputs.testman_project_id }} \
- --name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources testmo.json \
- --tags "$BRANCH_TAG" --tags "$EXTRA_TAG"
- )
- echo "runid=${RUN_ID}" >> $GITHUB_OUTPUT
- echo "TEST_HISTORY_URL=${TESTMO_URL}/automation/runs/view/${RUN_ID}" >> $GITHUB_ENV
- - name: Print test history link
- shell: bash
- run: |
- echo "10 [Test history](${TEST_HISTORY_URL})" >> $SUMMARY_LINKS
- - name: set environment variables required by some tests
- shell: bash
- run: |
- echo "PSQL_BINARY=/usr/bin/psql" >> $GITHUB_ENV
- - name: ya test
- shell: bash
- run: |
- extra_params=()
-
- # FIXME: copy-paste from build_ya
- case "${{ inputs.build_preset }}" in
- relwithdebinfo)
- build_type=relwithdebinfo
- ;;
- 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)
- ;;
- *)
- echo "Invalid preset: ${{ inputs.build_preset }}"
- exit 1
- ;;
- esac
- 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 [ "${{ inputs.cache_tests }}" = "true" ]; then
- extra_params+=(--cache-tests)
- fi
-
- readarray -d ',' -t test_size < <(printf "%s" "${{ inputs.test_size }}")
- readarray -d ',' -t test_type < <(printf "%s" "${{ inputs.test_type }}")
-
- ./ya test -k --build "${build_type}" -D'BUILD_LANGUAGES=CPP PY3 PY2' \
- ${test_size[@]/#/--test-size=} ${test_type[@]/#/--test-type=} \
- --test-threads "${{ inputs.test_threads }}" --link-threads "${{ inputs.link_threads }}" \
- --cache-size 512G --do-not-output-stderrs -T \
- --stat --log-file "$LOG_DIR/ya_log.txt" --evlog-file "$LOG_DIR/ya_evlog.jsonl" \
- --canonization-backend=ydb-canondata.storage.yandexcloud.net \
- --junit "$JUNIT_REPORT_XML" --output "$OUT_DIR" "${extra_params[@]}" || (
- RC=$?
- if [[ $RC -ge 10 && $RC -le 14 ]]; then
- echo "ya test returned failed tests status, recovering.."
- else
- exit $RC
- fi
- )
- - name: postprocess junit report
- shell: bash
- run: |
- .github/scripts/tests/transform-ya-junit.py -i \
- --mu .github/config/muted_test.txt \
- --mf .github/config/muted_functest.txt \
- --ya-out "$OUT_DIR" \
- --log-url-prefix "$S3_URL_PREFIX/logs/" \
- --log-out-dir "$ARTIFACTS_DIR/logs/" \
- "$JUNIT_REPORT_XML"
- - name: write tests summary
- shell: bash
- env:
- GITHUB_TOKEN: ${{ github.token }}
- run: |
- mkdir $ARTIFACTS_DIR/summary/
- cat $SUMMARY_LINKS | python3 -c 'import sys; print(" | ".join([v for _, v in sorted([l.strip().split(" ", 1) for l in sys.stdin], key=lambda a: (int(a[0]), a))]))' >> $GITHUB_STEP_SUMMARY
-
- platform_name=$(uname | tr '[:upper:]' '[:lower:]')-$(arch)
-
- .github/scripts/tests/generate-summary.py \
- --summary-out-path $ARTIFACTS_DIR/summary/ \
- --summary-url-prefix $S3_URL_PREFIX/summary/ \
- --test-history-url $TEST_HISTORY_URL \
- --build-preset "${platform_name}-${{ inputs.build_preset }}" \
- "Tests" ya-test.html "$JUNIT_REPORT_XML"
- - name: Unit test history upload results
- if: inputs.testman_token
- shell: bash
- run: |
- testmo automation:run:submit-thread \
- --instance "$TESTMO_URL" --run-id ${{ steps.th.outputs.runid }} \
- --results "$JUNIT_REPORT_XML"
- - name: sync test results to s3
- if: always()
- shell: bash
- run: |
- echo "::group::s3-sync"
- s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$ARTIFACTS_DIR/" "$S3_BUCKET_PATH/"
- echo "::endgroup::"
- - name: sync logs results to s3
- if: always()
- shell: bash
- run: |
- echo "::group::s3-sync"
- s3cmd sync --follow-symlinks --acl-private --no-progress --stats --no-check-md5 "$LOG_DIR/" "$S3_BUCKET_PATH/test_logs/"
- echo "::endgroup::"
- - name: Test history run complete
- if: always() && inputs.testman_token
- shell: bash
- run: |
- testmo automation:run:complete --instance "$TESTMO_URL" --run-id ${{ steps.th.outputs.runid }}
- - name: check test results
- shell: bash
- run: |
- .github/scripts/tests/fail-checker.py "$JUNIT_REPORT_XML"
- - name: show free space
- if: always()
- shell: bash
- run: df -h
|