Skip to content

Commit b877dbc

Browse files
authored
Enhanced output for performance testing rig (#1101)
1 parent 79cd6d6 commit b877dbc

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

.github/workflows/performance-tests.yml

Lines changed: 63 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,71 @@ 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+
uses: actions/github-script@v5
120+
with:
121+
github-token: ${{secrets.GITHUB_TOKEN}}
122+
script: |
123+
github.rest.issues.createComment({
124+
issue_number: context.issue.number,
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
body: `✅ Performance tests complete! Result summary:
128+
- Total requests: **${{ needs.run-perftests.outputs.request_count }}**
129+
- Total failures: **${{ needs.run-perftests.outputs.failure_count }}**
130+
- Min response time: **${{ needs.run-perftests.outputs.min_time }} ms**
131+
- Max response time: **${{ needs.run-perftests.outputs.max_time }} ms**
132+
- Average response time: **${{ needs.run-perftests.outputs.avg_time }} ms**
133+
- Median response time: **${{ needs.run-perftests.outputs.med_time }} ms**
134+
- Requests per second: **${{ needs.run-perftests.outputs.requests_per_sec }}**
135+
136+
Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
137+
})
138+
139+
comment-failure:
80140
runs-on: ubuntu-latest
81-
if: success() || failure() # but not if skipped
141+
if: failure()
82142
needs: run-perftests
83143
steps:
84144
- name: Comment run results
85-
# URL that links to run results
86145
env:
87146
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
88147
uses: actions/github-script@v5
@@ -93,5 +152,5 @@ jobs:
93152
issue_number: context.issue.number,
94153
owner: context.repo.owner,
95154
repo: context.repo.repo,
96-
body: '✅ Performance tests complete! Click here to view results: ${{ env.GITHUB_WORKFLOW_URL }}'
155+
body: `❌ Performance tests failed! Click here to view full results: ${{ env.GITHUB_WORKFLOW_URL }}.`
97156
})

0 commit comments

Comments
 (0)