1
+ name : Performance testing
2
+
3
+ # Run when a PR comment is created (issues and PRs are considered the same entity in the GitHub API)
4
+ on :
5
+ issue_comment :
6
+ types : [created]
7
+
8
+ # Add some extra perms to comment on a PR
9
+ permissions :
10
+ pull-requests : write
11
+ contents : read
12
+
13
+ jobs :
14
+ run-perftests :
15
+ # Make sure 1. this is a PR, not an issue 2. it contains "/run performance test" anywhere in the body
16
+ if : github.event.issue.pull_request && contains(github.event.comment.body, '/run performance test')
17
+ runs-on : ubuntu-latest
18
+ steps :
19
+ - name : Set up WireGuard
20
+ uses :
egor-tensin/[email protected]
21
+ with :
22
+ endpoint : ' ${{ secrets.WG_PERF_ENDPOINT }}'
23
+ endpoint_public_key : ' ${{ secrets.WG_PERF_ENDPOINT_PUBLIC_KEY }}'
24
+ ips : ' ${{ secrets.WG_PERF_IPS }}'
25
+ allowed_ips : ' ${{ secrets.WG_PERF_ALLOWED_IPS }}'
26
+ private_key : ' ${{ secrets.WG_PERF_PRIVATE_KEY }}'
27
+ - name : Check out repository
28
+ uses : actions/checkout@v3
29
+ # Previous step checks out default branch, so we check out the pull request's branch
30
+ - name : Switch to PR branch
31
+ run : |
32
+ hub pr checkout ${{ github.event.issue.number }}
33
+ env :
34
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
35
+ - name : Set up repository # mimics install.sh in the README except that delphi is cloned from the PR rather than main
36
+ run : |
37
+ cd ..
38
+ mkdir -p driver/repos/delphi
39
+ cd driver/repos/delphi
40
+ git clone https://github.com/cmu-delphi/operations
41
+ git clone https://github.com/cmu-delphi/utils
42
+ git clone https://github.com/cmu-delphi/flu-contest
43
+ git clone https://github.com/cmu-delphi/nowcast
44
+ cd ../../
45
+
46
+ cd ..
47
+ cp -R delphi-epidata driver/repos/delphi/delphi-epidata
48
+ cd -
49
+
50
+ ln -s repos/delphi/delphi-epidata/dev/local/Makefile
51
+ - name : Build & run epidata
52
+ run : |
53
+ cd ../driver
54
+ sudo make web sql="${{ secrets.DB_CONN_STRING }}"
55
+ - name : Build & run Locust
56
+ run : |
57
+ cd ../driver/repos/delphi/delphi-epidata/tests/performance
58
+ docker build -t locust .
59
+ docker run --net=host -v $PWD:/mnt/locust -e CSV=/mnt/locust/v4-requests-smaller.csv locust -f /mnt/locust/v4.py --host http://127.0.0.1:8080/ --users 10 --spawn-rate 1 --headless -t 15m
60
+
61
+ comment-output :
62
+ runs-on : ubuntu-latest
63
+ if : success() || failure() # but not if skipped
64
+ needs : run-perftests
65
+ steps :
66
+ - name : Comment run results
67
+ # URL that links to run results
68
+ env :
69
+ GITHUB_WORKFLOW_URL : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
70
+ uses : actions/github-script@v5
71
+ with :
72
+ github-token : ${{secrets.GITHUB_TOKEN}}
73
+ script : |
74
+ github.rest.issues.createComment({
75
+ issue_number: context.issue.number,
76
+ owner: context.repo.owner,
77
+ repo: context.repo.repo,
78
+ body: '✅ Performance tests complete! Click here to view results: ${{ env.GITHUB_WORKFLOW_URL }}'
79
+ })
80
+
0 commit comments