From 1c8452f6b8e246524367abc4238aca59c470c7cb Mon Sep 17 00:00:00 2001 From: Rex Morgan Date: Tue, 4 Aug 2026 21:09:38 -0400 Subject: [PATCH] ci: skip benchmark run for PRs that don't touch benchmark-relevant paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Run Benchmark.Net" job is a required status check, so it can't just be trigger-filtered out for e.g. workflow-only PRs — GitHub would leave the check permanently pending and block the merge. Instead, keep the job always running but guard the expensive dotnet run/benchmark steps behind a dorny/paths-filter check against source/Handlebars, source/Handlebars.Benchmark, and their shared build props/sln, so the job still reports success quickly when none of those changed. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/pull_request.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f5ad1c86..c1a5a1d2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -97,15 +97,30 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Check for benchmark-relevant changes + uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 + id: filter + with: + filters: | + relevant: + - 'source/Handlebars/**' + - 'source/Handlebars.Benchmark/**' + - 'source/Directory.Build.props' + - 'source/Handlebars.sln' + - uses: actions/setup-dotnet@v4 + if: steps.filter.outputs.relevant == 'true' with: dotnet-version: | 6.0.x 10.0.x - name: Run benchmark + if: steps.filter.outputs.relevant == 'true' working-directory: ./source/Handlebars.Benchmark run: dotnet run -c Release -f net10.0 --exporters json --filter '*' --join - name: Get benchmark file name + if: steps.filter.outputs.relevant == 'true' working-directory: ./source/Handlebars.Benchmark/BenchmarkDotNet.Artifacts/results id: benchmarkfilename run: | @@ -113,6 +128,7 @@ jobs: echo $filePath echo "file=$filePath" >> $GITHUB_OUTPUT - name: Store benchmark result + if: steps.filter.outputs.relevant == 'true' uses: Happypig375/github-action-benchmark@e7cb068f90622402c0ae5b54e2c781052fcd9343 # v1.8.2 with: name: Benchmark.Net Benchmark @@ -125,7 +141,12 @@ jobs: fail-on-alert: false alert-comment-cc-users: '@zjklee' - name: Upload Artifacts + if: steps.filter.outputs.relevant == 'true' uses: actions/upload-artifact@v4 with: name: Benchmark path: source/Handlebars.Benchmark/BenchmarkDotNet.Artifacts/results/ + + - name: Skipped + if: steps.filter.outputs.relevant != 'true' + run: echo "No changes under source/Handlebars or source/Handlebars.Benchmark — skipping benchmark run."