|
15 | 15 | # Make sure 1. this is a PR, not an issue 2. it contains "/run performance test" anywhere in the body
|
16 | 16 | if: github.event.issue.pull_request && contains(github.event.comment.body, '/run performance test')
|
17 | 17 | 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 }} |
18 | 26 | steps:
|
19 | 27 | - name: Set up WireGuard
|
20 | 28 | uses: egor-tensin/[email protected]
|
@@ -69,20 +77,78 @@ jobs:
|
69 | 77 | touch output_failures.csv && chmod 666 output_failures.csv
|
70 | 78 | touch output_exceptions.csv && chmod 666 output_exceptions.csv
|
71 | 79 | 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 | +
|
72 | 104 | - name: Archive results as artifacts
|
73 | 105 | uses: actions/upload-artifact@v3
|
74 | 106 | with:
|
75 | 107 | name: locust-output
|
76 | 108 | path: |
|
77 | 109 | delphi-admin/load-testing/locust/output_*.csv
|
78 | 110 |
|
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: |
80 | 147 | runs-on: ubuntu-latest
|
81 |
| - if: success() || failure() # but not if skipped |
| 148 | + if: failure() |
82 | 149 | needs: run-perftests
|
83 | 150 | steps:
|
84 | 151 | - name: Comment run results
|
85 |
| - # URL that links to run results |
86 | 152 | env:
|
87 | 153 | GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
88 | 154 | uses: actions/github-script@v5
|
|
93 | 159 | issue_number: context.issue.number,
|
94 | 160 | owner: context.repo.owner,
|
95 | 161 | 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 }}.` |
97 | 163 | })
|
0 commit comments