Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 70 additions & 65 deletions .github/actions/test_ya/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,74 @@ runs:
shell: bash
run: npm install -g @testmo/testmo-cli

- name: Upload tests result to testmo
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' }}"

BUILD_PRESET="${{ inputs.build_preset }}"
case "$BUILD_PRESET" in
relwithdebinfo)
TESTMO_SOURCE="ya-${ARCH}"
;;
debug)
TESTMO_SOURCE="ya-${ARCH}-debug"
;;
release-*)
TESTMO_SOURCE="ya-${ARCH}-${BUILD_PRESET/release-/}"
;;
*)
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"
;;
push)
TESTMO_RUN_NAME="${{ github.run_id }} POST"
EXTRA_TAG="post-commit"
;;
*)
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
if: inputs.testman_token
run: |
echo "10 [Test history](${TEST_HISTORY_URL})" >> $SUMMARY_LINKS

- name: set environment variables required by some tests
shell: bash
run: |
Expand Down Expand Up @@ -199,68 +267,10 @@ runs:
run: |
tar -C $JUNIT_REPORT_PARTS/.. -czf $REPORTS_ARTIFACTS_DIR/junit_parts.xml.tar.gz $(basename $JUNIT_REPORT_PARTS)

- name: Upload tests result to testmo
id: th
- name: Unit test history upload results
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' }}"

BUILD_PRESET="${{ inputs.build_preset }}"
case "$BUILD_PRESET" in
relwithdebinfo)
TESTMO_SOURCE="ya-${ARCH}"
;;
debug)
TESTMO_SOURCE="ya-${ARCH}-debug"
;;
release-*)
TESTMO_SOURCE="ya-${ARCH}-${BUILD_PRESET/release-/}"
;;
*)
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"
;;
push)
TESTMO_RUN_NAME="${{ github.run_id }} POST"
EXTRA_TAG="post-commit"
;;
*)
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

PROXY_ADDR=127.0.0.1:8888

openssl req -x509 -newkey rsa:2048 \
Expand All @@ -277,16 +287,11 @@ runs:
proxy_pid=$!

NODE_TLS_REJECT_UNAUTHORIZED=0 testmo automation:run:submit-thread \
--instance "https://$PROXY_ADDR" --run-id "$RUN_ID" \
--instance "https://$PROXY_ADDR" --run-id "${{ steps.th.outputs.runid }}" \
--results "$JUNIT_REPORT_PARTS/*.xml"

kill $proxy_pid

- name: Print test history link
shell: bash
run: |
echo "10 [Test history](${TEST_HISTORY_URL})" >> $SUMMARY_LINKS

- name: Test history run complete
if: always() && inputs.testman_token
shell: bash
Expand Down