on: [push]
name: Benchmark
jobs:
  Compare:
    runs-on: ubuntu-latest
    steps:
    - name: Install Go
      uses: actions/setup-go@v1
      with:
        go-version: 1.15.x
    - name: Fetch Repository
      uses: actions/checkout@v2
    - name: Run Benchmark
      run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt
    - name: Get Previous Benchmark Results
      uses: actions/cache@v1
      with:
        path: ./cache
        key: ${{ runner.os }}-benchmark
    - name: Save Benchmark Results
      uses: rhysd/github-action-benchmark@v1
      with:
        tool: 'go'
        output-file-path: output.txt
        github-token: ${{ secrets.BENCHMARK_TOKEN }}
        fail-on-alert: true
        comment-on-alert: true
        auto-push: true
