From 3473f8e942f96a4a90aac7d67d97ddb1cec08aaa Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 6 Oct 2023 17:48:41 +0200 Subject: [PATCH] Test a branch build --- .github/workflows/benchmarks.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 9b9d548672..dc53c85487 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,7 +1,5 @@ on: push: - branches: - - master workflow_dispatch: inputs: @@ -65,16 +63,24 @@ jobs: - name: Disable CPU boost run: echo "0" | sudo tee /sys/devices/system/cpu/cpufreq/boost - - name: Master; run bench - if: github.ref == 'ref/head/master' + - name: Extract branch name + if: "! github.event.inputs.pr_number" + shell: bash + run: | + BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + echo "NORMALIZED_BRANCH_NAME=${BRANCH_NAME//\//-}" >> $GITHUB_ENV + + - name: Branch; run bench + if: "! github.event.inputs.pr_number" working-directory: crates/bench/ run: | echo "Running benchmarks with sqlite" - cargo bench --bench generic --bench special -- --save-baseline master - cargo run --bin summarize pack master + cargo bench --bench generic --bench special -- --save-baseline $NORMALIZED_BRANCH_NAME + cargo run --bin summarize pack $NORMALIZED_BRANCH_NAME mkdir criterion-results - cp target/criterion/master.json criterion-results/ - cp target/criterion/master.json criterion-results/$GITHUB_SHA.json + cp target/criterion/NORMALIZED_BRANCH_NAME.json criterion-results/ + cp target/criterion/NORMALIZED_BRANCH_NAME.json criterion-results/$GITHUB_SHA.json # TODO: can we optionally download if it only might fail? #- name: PR; download bench results for compare @@ -106,8 +112,8 @@ jobs: if: github.event.inputs.pr_number working-directory: crates/bench/ run: | - if [ -e target/criterion/master.json ]; then - cargo run --bin summarize markdown-report branch.json master.json --report-name report + if [ -e target/criterion/$NORMALIZED_BRANCH_NAME.json ]; then + cargo run --bin summarize markdown-report branch.json $NORMALIZED_BRANCH_NAME.json --report-name report else cargo run --bin summarize markdown-report branch.json --report-name report fi