forked from ballerina-platform/module-ballerina-udp
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (75 loc) · 3.25 KB
/
process-load-test-result.yml
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
name: Process load test results
on:
repository_dispatch:
types: [udp-load-test]
jobs:
process-results:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Process results
id: processResults
run: |
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git pull
git checkout -b "load-test-results"
echo '${{ toJson(github.event.client_payload.results) }}' | jq -c '.[]' |
while read -r result; do
status=$(echo "$result" | jq -r '.status')
test_scenario=$(echo "$result" | jq -r '.name')
if [[ $status == "success" ]]
then
echo $(echo "$result" | jq -r '.result') >> load-tests/$test_scenario/results/summary.csv
git add load-tests/$test_scenario/results/summary.csv
git commit -m "Update $test_scenario test results on $(date)"
printf "hasPassed=true" >> $GITHUB_OUTPUT
else
echo $test_scenario "test has failed with error rate" $(echo "$result" | jq -r '.errorRate')
printf "hasFailed=true" >> $GITHUB_OUTPUT
fi
done
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Push results
if: ${{ steps.processResults.outputs.hasPassed }}
run: git push origin "load-test-results"
- name: Create pull request for new summary
id: createPR
if: ${{ steps.processResults.outputs.hasPassed }}
run: printf "prUrl=%s" $(gh pr create --title "[Automated] Update summary csv files" --body "Update summary csv files") >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Approve PR
if: ${{ steps.processResults.outputs.hasPassed }}
run: |
sleep 5
gh pr review --approve ${{ steps.createPR.outputs.prUrl }}
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_REVIEWER_BOT_TOKEN }}
- name: Merge PR
if: ${{ steps.processResults.outputs.hasPassed }}
run: |
checkCount="0"
while [ "$checkCount" != "3" ]
do
sleep 20
checkCount=$(gh pr status --jq '[.currentBranch .statusCheckRollup[] | select((.conclusion=="SUCCESS") and ((.name=="Build on Ubuntu") or (.name=="Build on Windows") or (.name=="codecov/project")))] | length' --json statusCheckRollup)
failedCount=$(gh pr status --jq '[.currentBranch .statusCheckRollup[] | select((.conclusion=="FAILURE") and ((.name=="Build on Ubuntu") or (.name=="Build on Windows") or (.name=="codecov/project")))]|length' --json statusCheckRollup)
if [[ "$failedCount" != "0" ]]
then
echo "PR Build has failed"
exit 1
fi
done
sleep 20
gh pr merge --merge --delete-branch
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
- name: Fail workflow
if: ${{ steps.processResults.outputs.hasFailed }}
run: |
echo "One or more load tests have been failed"
echo '${{ toJson(github.event.client_payload.results) }}'
exit 1