diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index fced87ef..412d4b15 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -65,29 +65,29 @@ jobs: set -o pipefail make bench | tee ${{ github.sha }}_bench_output.txt - - name: Get Main branch SHA + - name: Get Master branch SHA id: get-master-branch-sha run: | SHA=$(git rev-parse origin/master) echo "sha=$SHA" >> $GITHUB_OUTPUT - - name: Get benchmark JSON from main branch + - name: Get benchmark JSON from Master branch + id: cache uses: actions/cache/restore@v3 with: path: ./cache/benchmark-data.json key: ${{ steps.get-master-branch-sha.outputs.sha }}-${{ runner.os }}-go-benchmark - fail-on-cache-miss: true - - name: Compare benchmarks + - name: Compare benchmarks with master uses: benchmark-action/github-action-benchmark@v1 - if: success() + 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 main are (to compare) + # 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 @@ -97,3 +97,16 @@ jobs: # Enable Job Summary for PRs summary-always: true + - name: Run benchmarks but don't compare to master 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