test: verify persistence benchmark CI workflow #2
This file contains hidden or 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: Ahnlich Test PRs for Persistence Performance Regression | |
| on: | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - ahnlich/** | |
| types: [labeled] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| run-persistence-benchmark-test: | |
| # Only run if the PR has the 'benchmark-persistence' label | |
| if: contains(github.event.pull_request.labels.*.name, 'benchmark-persistence') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Set up Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: ahnlich | |
| - name: Install protoc | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Cache Docker images. | |
| uses: ScribeMD/docker-cache@0.5.0 | |
| with: | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('ahnlich/Cargo.lock') }} | |
| - name: Install Cargo benchcmp | |
| working-directory: ./ahnlich | |
| run: cargo install critcmp | |
| - name: Check if persistence benchmark exists on main | |
| id: check_main | |
| working-directory: ./ahnlich | |
| run: | | |
| if cargo bench --bench persistence --no-run 2>/dev/null; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run persistence benchmarks on main branch (if exists) | |
| if: steps.check_main.outputs.exists == 'true' | |
| working-directory: ./ahnlich | |
| run: cargo bench --bench persistence -- --save-baseline main | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| clean: false | |
| - name: Run persistence benchmarks on PR branch | |
| working-directory: ./ahnlich | |
| run: cargo bench --bench persistence -- --save-baseline pr | |
| - name: Compare benchmarks (if baseline exists) | |
| if: steps.check_main.outputs.exists == 'true' | |
| working-directory: ./ahnlich | |
| run: | | |
| benchmark_output=$(critcmp main pr) | |
| echo $benchmark_output | |
| echo "## Persistence Benchmark Results" >> persistence_bench_results.md | |
| echo "\`\`\`" >> persistence_bench_results.md | |
| echo "$benchmark_output" >> persistence_bench_results.md | |
| echo "\`\`\`" >> persistence_bench_results.md | |
| - name: Report first-time benchmark (if no baseline) | |
| if: steps.check_main.outputs.exists == 'false' | |
| working-directory: ./ahnlich | |
| run: | | |
| echo "## Persistence Benchmark Results" >> persistence_bench_results.md | |
| echo "" >> persistence_bench_results.md | |
| echo "This is the first PR to add persistence benchmarks." >> persistence_bench_results.md | |
| echo "No baseline comparison available - these results establish the baseline." >> persistence_bench_results.md | |
| echo "" >> persistence_bench_results.md | |
| echo "Benchmarks executed successfully on PR branch." >> persistence_bench_results.md | |
| - name: Comment PR with results | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| filePath: ahnlich/persistence_bench_results.md | |
| comment_tag: persistence_benchmark |