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 : Install Hyperfine
14
+ run : |
15
+ wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
16
+ sudo dpkg -i hyperfine_1.11.0_amd64.deb
17
+
18
+ - name : Get PR SHA
19
+ if : github.event_name == 'issue_comment'
20
+ id : sha
21
+ uses : actions/github-script@v6
22
+ with :
23
+ result-encoding : string
24
+ script : |
25
+ const response = await github.request(context.payload.issue.pull_request.url);
26
+ return response.data.head.sha;
27
+
28
+ - name : Checkout PR
29
+ uses : actions/checkout@v2
30
+ with :
31
+ ref : ${{ steps.sha.outputs.result || github.sha }}
32
+
33
+ - name : Set up Go
34
+ uses : actions/setup-go@v3
35
+ with :
36
+ go-version : 1.19
37
+ check-latest : true
38
+ cache : true
39
+
40
+ - name : Build PR
41
+ run : |
42
+ go build -o bench-pr ./bench
43
+
44
+ - name : Checkout main branch
45
+ uses : actions/checkout@v3
46
+ with :
47
+ clean : false
48
+ ref : main
49
+
50
+ - name : Build main
51
+ run : |
52
+ go build -o bench-main ./bench
53
+
54
+ - name : Start Redis
55
+ uses : shogo82148/actions-setup-redis@v1
56
+ with :
57
+ auto-start : true
58
+ redis-port : 6379
59
+ redis-version : ' 6.2'
60
+ redis-conf : ' requirepass RedisPassw0rd'
61
+
62
+ - name : Start MySQL
63
+ run : sudo /etc/init.d/mysql start
64
+
65
+ - name : Run benchmarks - mysql
66
+ run : |
67
+ hyperfine --warmup 1 --export-markdown bench-mysql.md -n 'mysql-main' './bench-main -runs 2 -backend mysql' -n 'mysql-pr' './bench-pr -runs 2 -backend mysql'
68
+ hyperfine --warmup 1 --export-markdown bench-sqlite.md -n 'sqlite-main' './bench-main -runs 2 -backend sqlite' -n 'sqlite-pr' './bench-pr -runs 2 -backend sqlite'
69
+ hyperfine --warmup 1 --export-markdown bench-redis.md -n 'redis-main' './bench-main -runs 2 -backend redis' -n 'redis-pr' './bench-pr -runs 2 -backend redis'
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