action.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. name: Run tests (ya make)
  2. description: Run tests using ya make
  3. inputs:
  4. build_target:
  5. required: false
  6. description: "build target"
  7. sanitizer:
  8. required: false
  9. description: "sanitizer type (address, memory, thread, undefined, leak)"
  10. log_suffix:
  11. required: true
  12. description: "log suffix"
  13. test_threads:
  14. required: false
  15. default: "28"
  16. description: "Test threads count"
  17. testman_token:
  18. required: false
  19. description: "test manager auth token"
  20. testman_url:
  21. required: false
  22. description: "test manager endpoint"
  23. testman_project_id:
  24. required: false
  25. description: "test manager project id"
  26. runs:
  27. using: "composite"
  28. steps:
  29. - name: Init
  30. id: init
  31. shell: bash
  32. run: |
  33. echo "SHELLOPTS=xtrace" >> $GITHUB_ENV
  34. export TMP_DIR=$(pwd)/tmp
  35. echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
  36. echo "OUT_DIR=$TMP_DIR/out" >> $GITHUB_ENV
  37. echo "ARTIFACTS_DIR=$TMP_DIR/artifacts" >> $GITHUB_ENV
  38. echo "JUNIT_REPORT_XML=$TMP_DIR/junit.xml" >> $GITHUB_ENV
  39. echo "TESTMO_TOKEN=${{ inputs.testman_token }}" >> $GITHUB_ENV
  40. echo "TESTMO_URL=${{ inputs.testman_url }}" >> $GITHUB_ENV
  41. echo "SUMMARY_LINKS=$(mktemp)" >> $GITHUB_ENV
  42. - name: prepare
  43. shell: bash
  44. run: |
  45. rm -rf $TMP_DIR $JUNIT_REPORT_XML
  46. mkdir -p $TMP_DIR $OUT_DIR $ARTIFACTS_DIR
  47. - name: Install Node required for Testmo CLI
  48. uses: actions/setup-node@v3
  49. with:
  50. node-version: 19
  51. - name: Install Testmo CLI
  52. shell: bash
  53. run: npm install -g @testmo/testmo-cli
  54. - name: Test history run create
  55. id: th
  56. if: inputs.testman_token
  57. shell: bash
  58. env:
  59. PR_NUMBER: ${{ github.event.number }}
  60. run: |
  61. RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
  62. BRANCH_TAG="$GITHUB_REF_NAME"
  63. TESTMO_SOURCE="${{ inputs.log_suffix }}"
  64. TESTMO_SOURCE="${TESTMO_SOURCE/_/-}"
  65. case $GITHUB_EVENT_NAME in
  66. workflow_dispatch)
  67. TESTMO_RUN_NAME="${{ github.run_id }} manual"
  68. EXTRA_TAG="manual"
  69. ;;
  70. pull_request | pull_request_target)
  71. TESTMO_RUN_NAME="${{ github.run_id }} PR #${PR_NUMBER}"
  72. EXTRA_TAG="pr"
  73. BRANCH_TAG=""
  74. ;;
  75. schedule)
  76. TESTMO_RUN_NAME="${{ github.run_id }} schedule"
  77. EXTRA_TAG="schedule"
  78. ;;
  79. *)
  80. TESTMO_RUN_NAME="${{ github.run_id }}"
  81. EXTRA_TAG=""
  82. ;;
  83. esac
  84. testmo automation:resources:add-link --name build --url "$RUN_URL" --resources testmo.json
  85. testmo automation:resources:add-field --name git-sha --type string --value "${GITHUB_SHA:0:7}" --resources testmo.json
  86. testmo automation:run:create --instance "$TESTMO_URL" --project-id "${{ inputs.testman_project_id }}" --name "$TESTMO_RUN_NAME" \
  87. --source "$TESTMO_SOURCE" --resources testmo.json \
  88. --tags "$BRANCH_TAG" --tags "$EXTRA_TAG" | \
  89. echo "runid=$(cat)" >> $GITHUB_OUTPUT
  90. - name: Print test history link
  91. shell: bash
  92. run: |
  93. echo "10 [Test history](${TESTMO_URL}/automation/runs/view/${{steps.th.outputs.runid}})" >> $SUMMARY_LINKS
  94. - name: ya test
  95. shell: bash
  96. run: |
  97. extra_params=()
  98. if [ ! -z "${{ inputs.build_target }}" ]; then
  99. extra_params+=(--target="${{ inputs.build_target }}")
  100. fi
  101. if [ ! -z "${{ inputs.sanitizer }}" ] && [ "${{ inputs.sanitizer }}" != "none" ]; then
  102. extra_params+=(--sanitize="${{ inputs.sanitizer }}")
  103. fi
  104. ./ya test -A --build relwithdebinfo -D'BUILD_LANGUAGES=CPP PY3' --test-threads "${{ inputs.test_threads }}" \
  105. --do-not-output-stderrs -T \
  106. --junit "$JUNIT_REPORT_XML" --output "$OUT_DIR" "${extra_params[@]}" || (
  107. RC=$?
  108. if [ $RC == 10 ]; then
  109. echo "ya test returned failed tests status, recovering.."
  110. else
  111. exit $RC
  112. fi
  113. )
  114. - name: postprocess junit report
  115. shell: bash
  116. run: |
  117. .github/scripts/tests/transform-ya-junit.py -i \
  118. --mu .github/config/muted_test.txt \
  119. --mf .github/config/muted_functest.txt \
  120. --ya-out "$OUT_DIR" \
  121. --log-url-prefix "$S3_URL_PREFIX/logs/" \
  122. --log-out-dir "$ARTIFACTS_DIR/logs/" \
  123. "$JUNIT_REPORT_XML"
  124. - name: write tests summary
  125. if: always()
  126. shell: bash
  127. env:
  128. GITHUB_TOKEN: ${{ github.token }}
  129. run: |
  130. 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
  131. mkdir $ARTIFACTS_DIR/summary/
  132. .github/scripts/tests/generate-summary.py \
  133. --summary-out-path $ARTIFACTS_DIR/summary/ \
  134. --summary-url-prefix $S3_URL_PREFIX/summary/ \
  135. "Tests" ya-test.html "$JUNIT_REPORT_XML"
  136. - name: Unit test history upload results
  137. if: always() && inputs.testman_token
  138. shell: bash
  139. run: |
  140. testmo automation:run:submit-thread \
  141. --instance "$TESTMO_URL" --run-id ${{ steps.th.outputs.runid }} \
  142. --results "$JUNIT_REPORT_XML"
  143. - name: sync test results to s3
  144. if: always()
  145. shell: bash
  146. run: |
  147. echo "::group::s3-sync"
  148. s3cmd sync --follow-symlinks --acl-public --no-progress --stats --no-check-md5 "$ARTIFACTS_DIR/" "$S3_BUCKET_PATH/"
  149. echo "::endgroup::"
  150. - name: Test history run complete
  151. if: always() && inputs.testman_token
  152. shell: bash
  153. run: |
  154. testmo automation:run:complete --instance "$TESTMO_URL" --run-id ${{ steps.th.outputs.runid }}
  155. - name: check test results
  156. shell: bash
  157. run: |
  158. .github/scripts/tests/fail-checker.py "$JUNIT_REPORT_XML"