31
31
uses : actions/setup-go@v3
32
32
with :
33
33
go-version : ${{ env.GO_VERSION }}
34
+
34
35
- name : Install Go tip
35
36
if : env.GO_VERSION == 'tip'
36
37
run : |
@@ -40,10 +41,12 @@ jobs:
40
41
tar -C ~/sdk/gotip -xzf gotip.tar.gz
41
42
~/sdk/gotip/bin/go version
42
43
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
44
+
43
45
- name : Checkout code
44
46
uses : actions/checkout@v2
45
47
with :
46
48
ref : ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
49
+
47
50
- name : Go cache
48
51
uses : actions/cache@v2
49
52
with :
@@ -56,47 +59,57 @@ jobs:
56
59
key : ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
57
60
restore-keys : |
58
61
${{ runner.os }}-go-cache
62
+
59
63
- name : Restore benchstat
60
64
uses : actions/cache@v2
61
65
with :
62
66
path : ~/go/bin/benchstat
63
- key : ${{ runner.os }}-benchstat
67
+ key : ${{ runner.os }}-benchstat-legacy
68
+
64
69
- name : Restore base benchmark result
70
+ id : base-benchmark
65
71
if : env.CACHE_BENCHMARK == 'on'
66
- id : benchmark-base
67
72
uses : actions/cache@v2
68
73
with :
69
74
path : |
70
75
bench-master.txt
71
76
bench-main.txt
72
77
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
73
78
key : ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
74
- - name : Checkout base code
75
- if : env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
76
- uses : actions/checkout@v2
77
- with :
78
- ref : ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }}
79
- path : __base
80
- - name : Run base benchmark
81
- if : env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
79
+
80
+ - name : Run benchmark
82
81
run : |
82
+ export REF_NAME=new
83
+ make bench
84
+ OUTPUT=$(make bench-stat-diff)
85
+ echo "${OUTPUT}"
86
+ echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
87
+ OUTPUT=$(make bench-stat)
88
+ echo "${OUTPUT}"
89
+ echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
90
+
91
+ - name : Run benchmark for base code
92
+ if : env.RUN_BASE_BENCHMARK == 'on' && steps.base-benchmark.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
93
+ run : |
94
+ git fetch origin master ${{ github.event.pull_request.base.sha }}
95
+ HEAD=$(git rev-parse HEAD)
96
+ git reset --hard ${{ github.event.pull_request.base.sha }}
83
97
export REF_NAME=master
84
- cd __base
85
- make | grep bench-run && (BENCH_COUNT=5 make bench-run bench-stat && cp bench-master.txt ../bench-master.txt) || echo "No benchmarks in base"
86
- - name : Benchmark
98
+ make bench-run bench-stat
99
+ git reset --hard $HEAD
100
+
101
+ - name : Benchmark stats
87
102
id : bench
88
103
run : |
89
104
export REF_NAME=new
90
- BENCH_COUNT=5 make bench
91
105
OUTPUT=$(make bench-stat-diff)
92
106
echo "${OUTPUT}"
93
- OUTPUT="${OUTPUT//$'\n'/%0A}"
94
- echo "::set-output name=diff::$OUTPUT"
107
+ echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
95
108
OUTPUT=$(make bench-stat)
96
109
echo "${OUTPUT}"
97
- OUTPUT="${ OUTPUT//$'\n'/%0A}"
98
- echo "::set-output name=result::$OUTPUT"
99
- - name : Comment Benchmark Result
110
+ echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$ OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
111
+
112
+ - name : Comment benchmark result
100
113
continue-on-error : true
101
114
uses : marocchino/sticky-pull-request-comment@v2
102
115
with :
0 commit comments