3131 uses : actions/setup-go@v3
3232 with :
3333 go-version : ${{ env.GO_VERSION }}
34+
3435 - name : Install Go tip
3536 if : env.GO_VERSION == 'tip'
3637 run : |
@@ -40,10 +41,12 @@ jobs:
4041 tar -C ~/sdk/gotip -xzf gotip.tar.gz
4142 ~/sdk/gotip/bin/go version
4243 echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
44+
4345 - name : Checkout code
4446 uses : actions/checkout@v2
4547 with :
4648 ref : ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
49+
4750 - name : Go cache
4851 uses : actions/cache@v2
4952 with :
@@ -56,47 +59,57 @@ jobs:
5659 key : ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
5760 restore-keys : |
5861 ${{ runner.os }}-go-cache
62+
5963 - name : Restore benchstat
6064 uses : actions/cache@v2
6165 with :
6266 path : ~/go/bin/benchstat
63- key : ${{ runner.os }}-benchstat
67+ key : ${{ runner.os }}-benchstat-legacy
68+
6469 - name : Restore base benchmark result
70+ id : base-benchmark
6571 if : env.CACHE_BENCHMARK == 'on'
66- id : benchmark-base
6772 uses : actions/cache@v2
6873 with :
6974 path : |
7075 bench-master.txt
7176 bench-main.txt
7277 # Use base sha for PR or new commit hash for master/main push in benchmark result key.
7378 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
8281 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 }}
8397 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
87102 id : bench
88103 run : |
89104 export REF_NAME=new
90- BENCH_COUNT=5 make bench
91105 OUTPUT=$(make bench-stat-diff)
92106 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
95108 OUTPUT=$(make bench-stat)
96109 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
100113 continue-on-error : true
101114 uses : marocchino/sticky-pull-request-comment@v2
102115 with :
0 commit comments