blob: 8fc026a80860b15e9d4d5c62d2d6f795b898ea1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
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
run_unit_tests:
required: true
type: string
run_functional_tests:
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 "PYTESTREPDIR=$(pwd)/ydb/tests/functional/test-results/xml" >> $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
echo "artifactsdir=$(pwd)/artifacts" >> $GITHUB_OUTPUT
echo "testfilterfile=$(pwd)/.github/config/muted_test.txt" >> $GITHUB_OUTPUT
echo "testshardfilterfile=$(pwd)/.github/config/muted_shard.txt" >> $GITHUB_OUTPUT
echo "logurlprefix=${{inputs.aws_endpoint}}/${{inputs.aws_bucket}}/${{ github.repository }}/${{github.workflow}}/${{github.run_id}}" >> $GITHUB_OUTPUT
echo "pytest-logfilename=${{inputs.log_suffix}}-pytest-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: Run unit tests
id: ctest
if: inputs.run_unit_tests == 'true'
shell: bash
run: |
cd $WORKDIR/../build/ydb
echo "[Stdout unittest/ctest log (gzip archive)](${{steps.init.outputs.logurlprefix}}/${{steps.init.outputs.logfilename}})" >> $GITHUB_STEP_SUMMARY
echo "[Testmo](${TESTMO_URL}/automation/runs/view/${{steps.th.outputs.runid}})" >> $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}}' -E "${CTEST_SKIP_SHARDS:-}" | \
sed -u -e 's/\x1b\[[0-9;]*m//g' | \
tee >(gzip --stdout > ${{steps.init.outputs.artifactsdir}}/${{steps.init.outputs.logfilename}}) | \
grep --line-buffered -E '(Test\s*#.*\*\*\*|\[FAIL\])|.*tests passed,.*tests failed out of' | \
tee $WORKDIR/short.log || (
RC=$?
if [ $RC == 8 ]; then
echo "ctest returned TEST_ERRORS, recovering.."
else
exit $RC
fi
)
- name: archive unitest reports (orig)
if: inputs.run_unit_tests == 'true'
shell: bash
run: |
tar -C $TESTREPDIR/ -czf ${{steps.init.outputs.artifactsdir}}/reports.tar.gz .
ls -la ${{steps.init.outputs.artifactsdir}}/reports.tar.gz
echo "[Unittest/CTest XML reports archive](${{steps.init.outputs.logurlprefix}}/reports.tar.gz)" >> $GITHUB_STEP_SUMMARY
- name: postprocess xml reports
if: inputs.run_unit_tests == 'true'
shell: bash
run: |
echo "::group::junit-postprocess"
.github/scripts/tests/junit-postprocess.py \
--filter-file ${{steps.init.outputs.testfilterfile}} \
$TESTREPDIR/unittests/
echo "::endgroup::"
echo "::group::ctest-postprocess"
.github/scripts/tests/ctest-postprocess.py \
--filter-file ${{steps.init.outputs.testshardfilterfile}} \
--decompress \
${{steps.init.outputs.artifactsdir}}/${{steps.init.outputs.logfilename}} \
$TESTREPDIR/suites/ctest_report.xml
echo "::endgroup::"
echo "::group::extract-logs"
mkdir ${{steps.init.outputs.artifactsdir}}/logs/
.github/scripts/tests/attach-logs.py \
--url-prefix ${{steps.init.outputs.logurlprefix}}/logs/ \
--filter-shard-file ${{steps.init.outputs.testshardfilterfile}} \
--filter-test-file ${{steps.init.outputs.testfilterfile}} \
--ctest-report $TESTREPDIR/suites/ctest_report.xml \
--junit-reports-path $TESTREPDIR/unittests/ \
--decompress \
${{steps.init.outputs.artifactsdir}}/${{steps.init.outputs.logfilename}} \
${{steps.init.outputs.artifactsdir}}/logs/
echo "::endgroup::"
- name: write unittests summary
if: inputs.run_unit_tests == 'true'
shell: bash
run: |
.github/scripts/tests/generate-summary.py -t "#### CTest run test shard failures" $TESTREPDIR/suites/ctest_report.xml
.github/scripts/tests/generate-summary.py -t "#### Unittest failures" $TESTREPDIR/unittests/
- name: Unit test history upload results
if: always() && inputs.run_unit_tests == 'true' && 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 \
--exec-suppress \
--instance "$TESTMO_URL" --run-id ${{steps.th.outputs.runid}} \
--results "$TESTREPDIR/suites/*.xml" \
-- cat $WORKDIR/short.log
- name: Run functional tests
if: inputs.run_functional_tests == 'true' && (success() || failure())
shell: bash
run: |
export source_root=$WORKDIR
export build_root=$WORKDIR/../build/
echo "[Stdout pytest log (gzip archive)](${{steps.init.outputs.logurlprefix}}/${{steps.init.outputs.pytest-logfilename}})" >> $GITHUB_STEP_SUMMARY
cd $WORKDIR/ydb/tests/functional/
bad_suites=$(grep -Eo 'ignore=[a-zA-Z_-]*' pytest.ini | sed -e 's/ignore=//g')
suites=""
for suite in $(echo */ | sed -e 's/\///g'); do
if [[ $(echo "$bad_suites" | grep -F -e $suite -) == '' ]]; then
suites+=$suite
suites+=$'\n'
fi
done
if [[ "${{inputs.test_label_regexp}}" != '' ]]; then
suites="${{inputs.test_label_regexp}}"
fi
source $WORKDIR/ydb/tests/oss/launch/prepare.sh
echo -n "$suites" | parallel -j28 "pytest -o junit_logging=log -o junit_log_passing_tests=False \
-v --junit-xml=$PYTESTREPDIR/{}.xml {}" | \
sed -e 's/\x1b\[[0-9;]*m//g' | \
tee >(gzip --stdout > ${{steps.init.outputs.artifactsdir}}/${{steps.init.outputs.pytest-logfilename}}) | \
grep -E '(FAILED|ERROR)\s*\[.*\]' | \
tee $WORKDIR/pytest-short.log
- name: write functional tests summary
if: always() && inputs.run_functional_tests == 'true'
shell: bash
run: |
.github/scripts/tests/generate-summary.py -t "#### Functional tests failures" $PYTESTREPDIR
- name: Functional tests history upload results
if: always() && inputs.run_functional_tests == 'true' && inputs.testman_token
shell: bash
run: |
testmo automation:run:submit-thread \
--instance "$TESTMO_URL" --run-id ${{steps.th.outputs.runid}} \
--results "$PYTESTREPDIR/*.xml" \
-- cat $WORKDIR/pytest-short.log
- 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: 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}}
# FIXME: must be constant here
source_dir: artifacts
destination_dir: '${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}'
endpoint: ${{inputs.aws_endpoint}}
- name: finish
shell: bash
run: |
.github/scripts/tests/fail-checker.py $TESTREPDIR/unittests/ $TESTREPDIR/suites/
|