Skip to content

Commit db4d930

Browse files
committed
Enhanced output for performance testing rig
1 parent 79cd6d6 commit db4d930

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed

.github/workflows/performance-tests.yml

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
# Make sure 1. this is a PR, not an issue 2. it contains "/run performance test" anywhere in the body
1616
if: github.event.issue.pull_request && contains(github.event.comment.body, '/run performance test')
1717
runs-on: ubuntu-latest
18+
outputs:
19+
request_count: ${{ steps.output.outputs.request_count }}
20+
failure_count: ${{ steps.output.outputs.failure_count }}
21+
med_time: ${{ steps.output.outputs.med_time }}
22+
avg_time: ${{ steps.output.outputs.avg_time }}
23+
min_time: ${{ steps.output.outputs.min_time }}
24+
max_time: ${{ steps.output.outputs.max_time }}
25+
requests_per_sec: ${{ steps.output.outputs.requests_per_sec }}
1826
steps:
1927
- name: Set up WireGuard
2028
uses: egor-tensin/[email protected]
@@ -69,20 +77,78 @@ jobs:
6977
touch output_failures.csv && chmod 666 output_failures.csv
7078
touch output_exceptions.csv && chmod 666 output_exceptions.csv
7179
docker run --net=host -v $PWD:/mnt/locust -e CSV="/mnt/locust/${CSV}" locust -f /mnt/locust/v4.py --host http://127.0.0.1:10080/ --users 10 --spawn-rate 1 --headless -i "$(cat ${CSV} | wc -l)" --csv=/mnt/locust/output
80+
- name: Produce output for summary
81+
id: output
82+
uses: jannekem/run-python-script-action@v1
83+
with:
84+
script: |
85+
import os
86+
87+
def write_string(name, value):
88+
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
89+
print(f'{name}={value}', file=fh)
90+
91+
def write_float(name, value):
92+
write_string(name, "{:.2f}".format(float(value)))
93+
94+
with open("delphi-admin/load-testing/locust/output_stats.csv", "r", encoding="utf-8", errors="ignore") as scraped:
95+
final_line = scraped.readlines()[-1].split(",")
96+
write_string('request_count', final_line[2])
97+
write_string('failure_count', final_line[3])
98+
write_float('med_time', final_line[4])
99+
write_float('avg_time', final_line[5])
100+
write_float('min_time', final_line[6])
101+
write_float('max_time', final_line[7])
102+
write_float('requests_per_sec', final_line[9])
103+
72104
- name: Archive results as artifacts
73105
uses: actions/upload-artifact@v3
74106
with:
75107
name: locust-output
76108
path: |
77109
delphi-admin/load-testing/locust/output_*.csv
78110
79-
comment-output:
111+
comment-success:
112+
runs-on: ubuntu-latest
113+
if: success()
114+
needs: run-perftests
115+
steps:
116+
- name: Comment run results
117+
env:
118+
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
119+
REQUEST_COUNT: ${{ needs.run-perftests.outputs.request_count }}
120+
FAILURE_COUNT: ${{ needs.run-perftests.outputs.failure_count }}
121+
MED_TIME: ${{ needs.run-perftests.outputs.med_time }}
122+
AVG_TIME: ${{ needs.run-perftests.outputs.avg_time }}
123+
MIN_TIME: ${{ needs.run-perftests.outputs.min_time }}
124+
MAX_TIME: ${{ needs.run-perftests.outputs.max_time }}
125+
REQUESTS_PER_SEC: ${{ needs.run-perftests.outputs.requests_per_sec }}
126+
uses: actions/github-script@v5
127+
with:
128+
github-token: ${{secrets.GITHUB_TOKEN}}
129+
script: |
130+
github.rest.issues.createComment({
131+
issue_number: context.issue.number,
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
body: `✅ Performance tests complete! Result summary:
135+
- Total requests: **${{ env.REQUEST_COUNT }}**
136+
- Total failures: **${{ env.FAILURE_COUNT }}**
137+
- Min response time: **${{ env.MIN_TIME }} ms**
138+
- Max response time: **${{ env.MAX_TIME }} ms**
139+
- Average response time: **${{ env.AVG_TIME }} ms**
140+
- Median response time: **${{ env.MED_TIME }} ms**
141+
- Requests per second: **${{ env.REQUESTS_PER_SEC }}**
142+
143+
Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
144+
})
145+
146+
comment-failure:
80147
runs-on: ubuntu-latest
81-
if: success() || failure() # but not if skipped
148+
if: failure()
82149
needs: run-perftests
83150
steps:
84151
- name: Comment run results
85-
# URL that links to run results
86152
env:
87153
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
88154
uses: actions/github-script@v5
@@ -93,5 +159,5 @@ jobs:
93159
issue_number: context.issue.number,
94160
owner: context.repo.owner,
95161
repo: context.repo.repo,
96-
body: '✅ Performance tests complete! Click here to view results: ${{ env.GITHUB_WORKFLOW_URL }}'
162+
body: `❌ Performance tests failed! Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
97163
})

0 commit comments

Comments
 (0)