Skip to content

Commit 47637e6

Browse files
committed
finish fast if both builds were made from a cache
1 parent a215876 commit 47637e6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/perf-test.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
name: current
3333
- commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3434
name: previous
35+
outputs:
36+
cached-previous: ${{ steps.is-cached-previous.outputs.is-cached }}
37+
cached-current: ${{ steps.is-cached-current.outputs.is-cached }}
3538
steps:
3639
- name: Checkout ${{ matrix.name }}
3740
uses: actions/checkout@v4
@@ -41,8 +44,16 @@ jobs:
4144
uses: actions/cache@v4
4245
id: cache
4346
with:
44-
key: bin-cache-${{ matrix.name }}-${{ matrix.commit }}
47+
key: bin-cache-${{ hashFiles('cpp-linter/src/**', 'Cargo.toml', 'Cargo.lock', 'cpp-linter/Cargo.toml') }}
4548
path: target/release/cpp-linter
49+
- name: Is previous cached?
50+
if: matrix.name == 'previous'
51+
id: is-cached-previous
52+
run: echo "is-cached=${{ steps.cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
53+
- name: Is current cached?
54+
if: matrix.name == 'current'
55+
id: is-cached-current
56+
run: echo "is-cached=${{ steps.cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
4657
- run: rustup update --no-self-update
4758
if: steps.cache.outputs.cache-hit != 'true'
4859
- run: cargo build --bin cpp-linter --release
@@ -56,6 +67,7 @@ jobs:
5667
benchmark:
5768
name: Measure Performance Difference
5869
needs: [build]
70+
if: ${{ needs.build.outputs.cached-current != 'true' || !needs.build.outputs.cached-previous != 'true' }}
5971
runs-on: ubuntu-latest
6072
steps:
6173
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)