Infer default values from prepared schema #214
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bench-examples | |
on: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
old: | |
description: 'Old Ref' | |
required: false | |
default: 'master' | |
new: | |
description: 'New Ref' | |
required: true | |
env: | |
GO111MODULE: "on" | |
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results. | |
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing. | |
GO_VERSION: 1.20.x | |
jobs: | |
bench: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go stable | |
if: env.GO_VERSION != 'tip' | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install Go tip | |
if: env.GO_VERSION == 'tip' | |
run: | | |
curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz | |
ls -lah gotip.tar.gz | |
mkdir -p ~/sdk/gotip | |
tar -C ~/sdk/gotip -xzf gotip.tar.gz | |
~/sdk/gotip/bin/go version | |
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }} | |
- name: Go cache | |
uses: actions/cache@v2 | |
with: | |
# In order: | |
# * Module download cache | |
# * Build cache (Linux) | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-cache-examples-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-cache | |
- name: Restore benchstat | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/bin/benchstat | |
key: ${{ runner.os }}-benchstat | |
- name: Restore base benchmark result | |
if: env.CACHE_BENCHMARK == 'on' | |
id: benchmark-base | |
uses: actions/cache@v2 | |
with: | |
path: | | |
bench-master.txt | |
bench-main.txt | |
# Use base sha for PR or new commit hash for master/main push in benchmark result key. | |
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }} | |
- name: Checkout base code | |
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '') | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }} | |
path: __base | |
- name: Run base benchmark | |
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '') | |
run: | | |
export REF_NAME=master | |
cd __base | |
go mod tidy | |
BENCH_COUNT=5 make bench-run-examples | |
ls -lah | |
pwd | |
cat bench-examples-master.txt | |
cp bench-examples-master.txt ../bench-examples-master.txt | |
- name: Benchmark | |
id: bench | |
run: | | |
export REF_NAME=new | |
go mod tidy | |
BENCH_COUNT=5 make bench-run-examples bench-stat-examples | |
OUTPUT=$(make bench-stat-examples) | |
echo "${OUTPUT}" | |
OUTPUT="${OUTPUT//$'\n'/%0A}" | |
echo "::set-output name=result::$OUTPUT" | |
- name: Comment Benchmark Examples Result | |
continue-on-error: true | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: bench-examples | |
message: | | |
### Examples Benchmark Result | |
<details><summary>Benchmark diff with base branch</summary> | |
``` | |
${{ steps.bench.outputs.result }} | |
``` | |
</details> |