From 6e9870aecd065772a4b1d99ee2199e458aef5b1d Mon Sep 17 00:00:00 2001 From: Maria Ines Parnisari Date: Thu, 19 Oct 2023 18:56:04 -0700 Subject: [PATCH] rollback to cache :( --- .github/workflows/main.yaml | 28 +++++++++++++++- .github/workflows/prs.yaml | 65 ++++++------------------------------- 2 files changed, 37 insertions(+), 56 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8337881..de30994 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,4 +18,30 @@ jobs: with: go-version-file: './go.mod' cache-dependency-path: './go.sum' - check-latest: true \ No newline at end of file + check-latest: true + + # Run benchmark with `go test -bench` and stores the output to a file + - name: Run benchmark + run: | + set -o pipefail + make bench | tee bench_output.txt + + - name: Get JSON for benchmark + uses: benchmark-action/github-action-benchmark@70405016b032d44f409e4b1b451c40215cbe2393 # v1.18.0 + with: + # What benchmark tool the output.txt came from + tool: 'go' + # Where the output from the benchmark tool is stored + output-file-path: bench_output.txt + # Updates the file content instead of generating a Git commit in GitHub Pages branch + external-data-json-path: ./cache/benchmark-data.json + # Workflow will fail when an alert happens + fail-on-alert: true + github-token: ${{ secrets.GITHUB_TOKEN }} + comment-on-alert: true + + - name: Save benchmark data + uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 + with: + path: ./cache/benchmark-data.json + key: ${{ runner.os }}-go-benchmark \ No newline at end of file diff --git a/.github/workflows/prs.yaml b/.github/workflows/prs.yaml index 494dc9d..a88ac91 100644 --- a/.github/workflows/prs.yaml +++ b/.github/workflows/prs.yaml @@ -4,48 +4,8 @@ on: branches: - main -permissions: - contents: write - pull-requests: write - jobs: - bench-main: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - name: Checkout main - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v3.5.2 - with: - ref: main - - - 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 of main - run: | - set -o pipefail - make bench | tee main_bench_output.txt - - - name: Store benchmark result of main - uses: benchmark-action/github-action-benchmark@70405016b032d44f409e4b1b451c40215cbe2393 # v1.18.0 - with: - # What benchmark tool the output.txt came from - tool: 'go' - # Where the output from the benchmark tool is stored - output-file-path: main_bench_output.txt - # Where the output from the benchmark will be stored - external-data-json-path: ./main_bench_output.json - save-data-file: true - fail-on-alert: false - - uses: actions/upload-artifact@v3 - with: - name: benchmarks - path: ./main_bench_output.json - - bench-PR: + go-bench: runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -57,24 +17,19 @@ jobs: cache-dependency-path: './go.sum' check-latest: true - - name: Run benchmark of PR + # Run benchmark with `go test -bench` and stores the output to a file + - name: Run benchmark run: | set -o pipefail make bench | tee ${{ github.sha }}_bench_output.txt - - uses: actions/upload-artifact@v3 - with: - name: benchmarks - path: ${{ github.sha }}_bench_output.txt - compare-pr: - runs-on: ubuntu-latest - needs: [bench-main, bench-pr] - timeout-minutes: 15 - steps: - - name: Downloads benchmarks - uses: actions/download-artifact@v3 + # Download previous benchmark result from cache + - name: Download previous benchmark data + uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: - name: benchmarks + fail-on-cache-miss: true + path: ./cache/benchmark-data.json + key: ${{ runner.os }}-go-benchmark - name: Compare benchmark result uses: benchmark-action/github-action-benchmark@70405016b032d44f409e4b1b451c40215cbe2393 # v1.18.0 @@ -84,7 +39,7 @@ jobs: # Where the output from the benchmark tool is stored output-file-path: ${{ github.sha }}_bench_output.txt # Where the previous data file is stored - external-data-json-path: ./main_bench_output.json + external-data-json-path: ./cache/benchmark-data.json # Do not save the data save-data-file: false # Workflow will fail when an alert happens