-
Notifications
You must be signed in to change notification settings - Fork 0
/
orb.yml
157 lines (155 loc) · 6.75 KB
/
orb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
version: "2.1"
description: "enables convenient usage of gobenchdata via circleci"
display:
home_url: https://github.com/bobheadxi/gobenchdata/
source_url: https://github.com/bobheadxi/gobenchdata/blob/master/circleci/orb.yml
commands:
execute:
parameters:
count:
description: Number of benchmark iterations to run
type: string
default: "1000x"
match:
description: Name to match for determining benchmarks to run
type: string
default: "."
path:
description: Path to benchmarks to run
type: string
default: ""
options:
description: Options to pass into the `go test` command
type: string
default: "-benchmem"
output:
description: Path to output results to
type: string
default: "/tmp/bench.txt"
timeout:
description: Test timeout in time.Duration values
type: string
default: "600s"
steps:
- run:
name: "Run Benchmarks And Store Results"
command: go test -timeout="<< parameters.timeout >>" -bench="<< parameters.match >>" --benchtime "<< parameters.count >>" "<< parameters.path >>" "<< parameters.options >>" > "<< parameters.output >>"
parse:
parameters:
file:
description: File containing benchmark samples
type: string
default: "/tmp/bench.txt"
output:
description: File to store parsed data into
type: string
default: "/tmp/new_benchmarks.json"
steps:
- run:
name: "Parse Benchmark Results And Generate GoBenchData Output"
command: cat "<< parameters.file >>" | gobenchdata --json "<< parameters.output >>"
checks:
parameters:
input_benchmarks_out:
description: Previous benchmarks to compare against
type: string
default: "/tmp/benchmarks.json"
run_output:
description: New benchmarks to compare against
type: string
default: "/tmp/new_benchmarks.json"
checks_config:
description: Location for checks configuration file
type: string
default: "gobenchdata-checks.yml"
checks_output:
description: Location to store checks comparison in
type: string
default: "checks-results.json"
options:
description: Optional flags to pass into checks
type: string
default: "--flat"
publish_branch:
description: Branch data is published against
type: string
default: gh-pages
steps:
- run:
name: "Fetch Previous Data And Checkout Publish Branch"
command: |
git clone https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} /tmp/${CIRCLE_PROJECT_REPONAME}
cd /tmp/${CIRCLE_PROJECT_REPONAME}
git checkout "<< parameters.publish_branch >>"
if [[ ! -f benchmarks.json ]]; then
exit 0
fi
cp benchmarks.json /tmp
- run:
name: "Compare Benchmarks"
command: |
if [[ ! -f /tmp/benchmarks.json ]]; then
exit 0
fi
cd /tmp/${CIRCLE_PROJECT_REPONAME}
gobenchdata checks eval "<< parameters.input_benchmarks_out >>" "<< parameters.run_output >>" \
--checks.config "<< parameters.checks_config >>" \
--json "<< parameters.checks_output >>" \
"<< parameters.options >>"
publish:
parameters:
input_benchmarks_out:
description: Previous benchmarks to compare against
type: string
default: "/tmp/benchmarks.json"
run_output:
description: New benchmarks to compare against
type: string
default: "/tmp/new_benchmarks.json"
options:
description: Optional flags to pass into checks
type: string
default: "--flat"
publish_branch:
description: Branch data is published against
type: string
default: gh-pages
prune_count:
description: "Number of past runs to keep (0 = keep everything)"
type: integer
default: 0
input_commit_message:
description: Commit message to use for publish
type: string
default: "add benchmark run for ${CIRCLE_SHA1}"
steps:
- run:
# this will not run if publish is called after checks
name: "Clone And Checkout Publish Branch"
command: |
if [[ ! -d /tmp/${CIRCLE_PROJECT_REPONAME} ]]; then
git clone https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} /tmp/${CIRCLE_PROJECT_REPONAME}
cd /tmp/${CIRCLE_PROJECT_REPONAME}
git checkout "<< parameters.publish_branch >>"
fi
- run:
name: "Merge Results"
command: |
if [[ -f "<< parameters.input_benchmarks_out >>" ]]; then
gobenchdata merge "<< parameters.run_output >>" "<< parameters.input_benchmarks_out >>" \
--prune "<< parameters.prune_count >>" \
--json "<< parameters.input_benchmarks_out >>" \
"<< parameters.options >>"
else
cp "<< parameters.run_output >>" "<< parameters.input_benchmarks_out >>"
fi
- run:
name: "Publish results"
command: |
cd /tmp/${CIRCLE_PROJECT_REPONAME}
git config --global user.email "[email protected]"
git config --global user.name ${CIRCLE_USERNAME}
cp "<< parameters.input_benchmarks_out >>" .
git add .
git commit -m "<< parameters.input_commit_message >>"
git push -f origin "<< parameters.publish_branch >>"