Skip to content

Commit eaa8eab

Browse files
authored
chore: fix kb test send message error (#619)
1 parent 97e90f2 commit eaa8eab

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

.github/archive/workflows/smoke-test-k8s.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ jobs:
300300
301301
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
302302
--github-repo "${{ github.repository }}" \
303+
--github-token "${{ env.GITHUB_TOKEN }}" \
303304
--test-result "${TEST_RESULT}" \
304305
--run-id "$GITHUB_RUN_ID" )
305306

.github/utils/utils.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ EOF
8787
GITHUB_API="https://api.github.com"
8888
DEFAULT_GITHUB_REPO=apecloud/kubeblocks
8989

90+
is_number() {
91+
if [[ "$1" =~ ^-?[0-9]+$ ]]; then
92+
echo "true"
93+
else
94+
echo "false"
95+
fi
96+
}
97+
9098
gh_curl() {
9199
if [[ -z "$GITHUB_TOKEN" ]]; then
92100
curl -H "Accept: application/vnd.github.v3.raw" \
@@ -348,6 +356,10 @@ get_test_result() {
348356
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=$i"
349357
jobs_list=$( gh_curl -s $jobs_url )
350358
total_count=$( echo "$jobs_list" | jq '.total_count' )
359+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
360+
echo "total_count:${total_count}"
361+
break
362+
fi
351363
for i in $(seq 0 $total_count); do
352364
if [[ "$i" == "$total_count" ]]; then
353365
break
@@ -376,6 +388,10 @@ get_e2e_test_result() {
376388
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=$i"
377389
jobs_list=$( gh_curl -s $jobs_url )
378390
total_count=$( echo "$jobs_list" | jq '.total_count' )
391+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
392+
echo "total_count:${total_count}"
393+
break
394+
fi
379395
for i in $(seq 0 $total_count); do
380396
if [[ "$i" == "$total_count" ]]; then
381397
break
@@ -414,6 +430,10 @@ get_ginkgo_test_result() {
414430
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=$i"
415431
jobs_list=$( gh_curl -s $jobs_url )
416432
total_count=$( echo "$jobs_list" | jq '.total_count' )
433+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
434+
echo "total_count:${total_count}"
435+
break
436+
fi
417437
for i in $(seq 0 $total_count); do
418438
if [[ "$i" == "$total_count" ]]; then
419439
break
@@ -443,6 +463,10 @@ get_cloud_test_result() {
443463
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=$i"
444464
jobs_list=$( gh_curl -s $jobs_url )
445465
total_count=$( echo "$jobs_list" | jq '.total_count' )
466+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
467+
echo "total_count:${total_count}"
468+
break
469+
fi
446470
for i in $(seq 0 $total_count); do
447471
if [[ "$i" == "$total_count" ]]; then
448472
break
@@ -460,6 +484,10 @@ get_job_url() {
460484
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=1"
461485
jobs_list=$( gh_curl -s $jobs_url )
462486
total_count=$( echo "$jobs_list" | jq '.total_count' )
487+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
488+
echo "total_count:${total_count}"
489+
return
490+
fi
463491
for i in $(seq 0 $total_count); do
464492
job_name=$( echo "$jobs_list" | jq ".jobs[$i].name" --raw-output )
465493
if [[ "$job_name" == *"$JOB_NAME" ]]; then
@@ -1096,6 +1124,10 @@ get_gh_job_url() {
10961124
jobs_url="$GITHUB_API/repos/$GITHUB_REPO/actions/runs/$RUN_ID/jobs?per_page=200&page=$i"
10971125
jobs_list=$( gh_curl -s $jobs_url )
10981126
total_count=$( echo "$jobs_list" | jq '.total_count' )
1127+
if [[ "$total_count" == "null" || $(is_number "$total_count") == "false" ]]; then
1128+
echo "total_count:${total_count}"
1129+
break
1130+
fi
10991131
for i in $(seq 0 $total_count); do
11001132
if [[ "$i" == "$total_count" ]]; then
11011133
break

.github/workflows/fault-test-k8s.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ jobs:
226226
227227
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
228228
--github-repo "${{ github.repository }}" \
229+
--github-token "${{ env.GITHUB_TOKEN }}" \
229230
--test-result "${TEST_RESULT}" \
230231
--run-id "$GITHUB_RUN_ID" )
231232

.github/workflows/kbcli-pre-test-k8s.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,7 @@ jobs:
13611361
13621362
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
13631363
--github-repo "${{ github.repository }}" \
1364+
--github-token "${{ env.GITHUB_TOKEN }}" \
13641365
--test-result "${TEST_RESULT}" \
13651366
--run-id "$GITHUB_RUN_ID" )
13661367

.github/workflows/kbcli-test-k3s.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ jobs:
916916
917917
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
918918
--github-repo "${{ github.repository }}" \
919+
--github-token "${{ env.GITHUB_TOKEN }}" \
919920
--test-result "${TEST_RESULT}" \
920921
--run-id "$GITHUB_RUN_ID" )
921922
@@ -1119,6 +1120,7 @@ jobs:
11191120
11201121
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
11211122
--github-repo "${{ github.repository }}" \
1123+
--github-token "${{ env.GITHUB_TOKEN }}" \
11221124
--test-result "${TEST_RESULT}" \
11231125
--run-id "$GITHUB_RUN_ID" )
11241126

.github/workflows/kbcli-test-k8s.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ jobs:
15611561
15621562
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
15631563
--github-repo "${{ github.repository }}" \
1564+
--github-token "${{ env.GITHUB_TOKEN }}" \
15641565
--test-result "${TEST_RESULT}" \
15651566
--run-id "$GITHUB_RUN_ID" )
15661567

0 commit comments

Comments
 (0)