aboutsummaryrefslogtreecommitdiffstats
path: root/.github/actions/test
diff options
context:
space:
mode:
authorAlexander Smirnov <alexv-smirnov@yandex-team.ru>2023-05-31 19:05:05 +0200
committerAlexander Smirnov <alexv-smirnov@yandex-team.ru>2023-05-31 19:05:05 +0200
commit10ba5cc0c3d130ce4b33d307d265b937dd572c39 (patch)
treef5de7deac53b0989332e9e8571d75c8916239f3f /.github/actions/test
parent1db08b73476ce8a181ff6163ec91305fe7a8cc56 (diff)
downloadydb-10ba5cc0c3d130ce4b33d307d265b937dd572c39.tar.gz
bring workflows from main
Diffstat (limited to '.github/actions/test')
-rw-r--r--.github/actions/test/action.yml128
1 files changed, 128 insertions, 0 deletions
diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml
new file mode 100644
index 0000000000..0a3c848c84
--- /dev/null
+++ b/.github/actions/test/action.yml
@@ -0,0 +1,128 @@
+name: build-and-test
+description: Build YDB and run Tests
+inputs:
+ log_suffix:
+ required: true
+ type: string
+ test_label_regexp:
+ required: false
+ type: string
+ aws_key_id:
+ required: true
+ type: string
+ aws_key_value:
+ required: true
+ type: string
+ testman_token:
+ required: false
+ type: string
+ testman_url:
+ required: false
+ type: string
+ testman_project_id:
+ required: false
+ type: string
+ aws_bucket:
+ required: true
+ type: string
+ aws_endpoint:
+ required: true
+ type: string
+
+runs:
+ using: "composite"
+ steps:
+ - name: Init
+ id: init
+ shell: bash
+ run: |
+ mkdir -p artifacts tmp test_reports
+ rm -rf artifacts/* tmp/* test_reports/*
+ echo "WORKDIR=$(pwd)" >> $GITHUB_ENV
+ echo "TESTREPDIR=$(pwd)/test_reports" >> $GITHUB_ENV
+ echo "TESTMO_TOKEN=${{inputs.testman_token}}" >> $GITHUB_ENV
+ echo "TESTMO_URL=${{inputs.testman_url}}" >> $GITHUB_ENV
+ echo "logfilename=${{inputs.log_suffix}}-ctest-stdout.gz" >> $GITHUB_OUTPUT
+ - 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"
+
+ 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
+ testmo automation:run:create --instance "$TESTMO_URL" --project-id ${{inputs.testman_project_id}} --name "$TESTMO_RUN_NAME" \
+ --source "${{inputs.log_suffix}}" --resources testmo.json \
+ --tags "$BRANCH_TAG" --tags "$EXTRA_TAG" | \
+ echo "runid=$(cat)" >> $GITHUB_OUTPUT
+
+ - name: Test
+ shell: bash
+ run: |
+ cd $WORKDIR/../build/ydb
+
+ echo "Stdout log (gzip archive): ${{inputs.aws_endpoint}}/${{inputs.aws_bucket}}/${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}/${{steps.init.outputs.logfilename}}" >> $GITHUB_STEP_SUMMARY
+
+ # Sed removes coloring from the output
+
+ TMPDIR=$WORKDIR/tmp GTEST_OUTPUT="xml:$TESTREPDIR/unittests/" Y_UNITTEST_OUTPUT="xml:$TESTREPDIR/unittests/" \
+ ctest -j28 --timeout 1200 --force-new-ctest-process --output-on-failure \
+ --output-junit $TESTREPDIR/suites/ctest_report.xml \
+ -L '${{inputs.test_label_regexp}}' | \
+ sed -e 's/\x1b\[[0-9;]*m//g' | \
+ tee >(gzip --stdout > $WORKDIR/artifacts/${{steps.init.outputs.logfilename}}) | \
+ grep -E '(Test\s*#.*\*\*\*|\[FAIL\])|.*tests passed,.*tests failed out of' | \
+ tee $WORKDIR/short.log
+ - name: Test history upload results
+ if: always() && inputs.testman_token
+ shell: bash
+ run: |
+ testmo automation:run:submit-thread \
+ --instance "$TESTMO_URL" --run-id ${{steps.th.outputs.runid}} \
+ --results $TESTREPDIR/unittests/*.xml
+ testmo automation:run:submit-thread \
+ --instance "$TESTMO_URL" --run-id ${{steps.th.outputs.runid}} \
+ --results $TESTREPDIR/suites/*.xml \
+ -- cat $WORKDIR/short.log
+ testmo automation:run:complete --instance "$TESTMO_URL" --run-id ${{steps.th.outputs.runid}}
+ - name: Upload S3
+ uses: shallwefootball/s3-upload-action@master
+ if: always()
+ with:
+ aws_key_id: ${{inputs.AWS_KEY_ID }}
+ aws_secret_access_key: ${{inputs.AWS_KEY_VALUE}}
+ aws_bucket: ${{inputs.aws_bucket}}
+ source_dir: artifacts
+ destination_dir: '${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}'
+ endpoint: ${{inputs.aws_endpoint}}