test #41
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: Pull Request | |
on: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
go-bench: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v3.5.2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version-file: './go.mod' | |
cache-dependency-path: './go.sum' | |
check-latest: true | |
- name: Run benchmark on PR | |
run: | | |
set -o pipefail | |
make bench | tee ${{ github.sha }}_bench_output.txt | |
- name: Get CPU information | |
uses: kenchan0130/actions-system-info@master | |
id: system-info | |
- name: Get Main branch SHA | |
id: get-main-branch-sha | |
run: | | |
SHA=$(git rev-parse origin/main) | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
- name: Download benchmark from Main | |
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | |
id: cache | |
with: | |
path: ./cache/benchmark-data.json | |
key: ${{ steps.get-main-branch-sha.outputs.sha }}-${{ runner.os }}-${{ steps.system-info.outputs.cpu-model }}-go-benchmark | |
- name: Compare benchmarks with Main | |
uses: benchmark-action/github-action-benchmark@v1 | |
if: steps.cache.outputs.cache-hit == 'true' | |
with: | |
alert-threshold: "200%" | |
# What benchmark tool the output.txt came from | |
tool: 'go' | |
# Where the output from the benchmark tool is stored | |
output-file-path: ${{ github.sha }}_bench_output.txt | |
# Where the benchmarks in master are (to compare) | |
external-data-json-path: ./cache/benchmark-data.json | |
# Do not save the data | |
save-data-file: false | |
# Workflow will fail when an alert happens | |
fail-on-alert: true | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
# Enable Job Summary for PRs | |
summary-always: true | |
- name: Run benchmarks but don't compare to Main branch | |
uses: benchmark-action/github-action-benchmark@v1 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
# What benchmark tool the output.txt came from | |
tool: 'go' | |
# Where the output from the benchmark tool is stored | |
output-file-path: ${{ github.sha }}_bench_output.txt | |
# Write benchmarks to this file, do not publish to GitHub Pages | |
save-data-file: false | |
external-data-json-path: ./cache/benchmark-data.json | |
# Enable Job Summary for PRs | |
summary-always: true |