1
+ on :
2
+ workflow_dispatch :
3
+ issue_comment :
4
+ types : [ created ]
5
+
6
+ name : Benchmark
7
+
8
+ jobs :
9
+ bench :
10
+ runs-on : ubuntu-latest
11
+ if : github.event_name == 'workflow_dispatch' || (github.event.issue.pull_request && contains(github.event.comment.body, '!bench'))
12
+ steps :
13
+ - name : Set up Go
14
+ uses : actions/setup-go@v3
15
+ with :
16
+ go-version : 1.19
17
+ check-latest : true
18
+ cache : true
19
+
20
+ - name : Start Redis
21
+ uses : shogo82148/actions-setup-redis@v1
22
+ with :
23
+ auto-start : true
24
+ redis-port : 6379
25
+ redis-version : ' 6.2'
26
+ redis-conf : ' requirepass RedisPassw0rd'
27
+
28
+ - name : Start MySQL
29
+ run : sudo /etc/init.d/mysql start
30
+
31
+ - name : Install Hyperfine
32
+ run : |
33
+ wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
34
+ sudo dpkg -i hyperfine_1.11.0_amd64.deb
35
+
36
+ - name : Get PR SHA
37
+ if : github.event_name == 'issue_comment'
38
+ id : sha
39
+ uses : actions/github-script@v6
40
+ with :
41
+ result-encoding : string
42
+ script : |
43
+ const response = await github.request(context.payload.issue.pull_request.url);
44
+ return response.data.head.sha;
45
+
46
+ - name : Checkout PR
47
+ uses : actions/checkout@v2
48
+ with :
49
+ ref : ${{ steps.sha.outputs.result || github.sha }}
50
+
51
+ - name : Build PR
52
+ run : |
53
+ go build -o bench-pr ./bench
54
+
55
+ - name : Checkout main branch
56
+ uses : actions/checkout@v3
57
+ with :
58
+ clean : false
59
+ ref : main
60
+
61
+ - name : Build main
62
+ run : |
63
+ go build -o bench-main ./bench
64
+
65
+ - name : Run benchmarks - mysql
66
+ run : |
67
+ hyperfine --warmup 1 --export-markdown bench-mysql.md -n 'mysql-main' './bench-main -runs 2' -n 'mysql-pr' './bench-pr -runs 2'
68
+ hyperfine --warmup 1 --export-markdown bench-sqlite.md -n 'sqlite-main' './bench-main -runs 2' -n 'sqlite-pr' './bench-pr -runs 2'
69
+ hyperfine --warmup 1 --export-markdown bench-redis.md -n 'redis-main' './bench-main -runs 2' -n 'redis-pr' './bench-pr -runs 2'
70
+ cat bench-mysql.md > benchmark.md
71
+ echo $'\n' >> benchmark.md
72
+ cat bench-sqlite.md >> benchmark.md
73
+ echo $'\n' >> benchmark.md
74
+ cat bench-redis.md >> benchmark.md
75
+
76
+ - name : Write a new comment
77
+ uses : peter-evans/create-or-update-comment@v2
78
+ continue-on-error : true
79
+ with :
80
+ issue-number : ${{ github.event.issue.number }}
81
+ body-file : ./benchmark.md
0 commit comments