Skip to content

Commit 9263052

Browse files
run build workflow on changes to workflow file in PR (#307)
1 parent 36211bb commit 9263052

File tree

1 file changed

+50
-40
lines changed

1 file changed

+50
-40
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: build
22

33
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/build.yml
47
workflow_call:
58
inputs:
69
version:
@@ -73,6 +76,25 @@ jobs:
7376
echo "OS=${os:-'unknown'}" >> $GITHUB_ENV
7477
echo "ARCH=${arch:-'unknown'}" >> $GITHUB_ENV
7578
79+
- name: Cache rustup toolchain
80+
uses: actions/cache@v4
81+
with:
82+
path: |
83+
~/.rustup
84+
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
85+
restore-keys: |
86+
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
87+
88+
- name: Cache Homebrew packages (macOS)
89+
if: ${{ runner.os == 'macOS' }}
90+
uses: actions/cache@v4
91+
with:
92+
path: |
93+
~/Library/Caches/Homebrew
94+
key: ${{ runner.os }}-${{ matrix.platform.target }}-homebrew-${{ hashFiles('.github/workflows/build.yml') }}
95+
restore-keys: |
96+
${{ runner.os }}-${{ matrix.platform.target }}-homebrew-
97+
7698
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
7799
with:
78100
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
@@ -193,19 +215,6 @@ jobs:
193215
with:
194216
python-version: 3.x
195217

196-
- uses: actions/cache@v4
197-
with:
198-
path: |
199-
~/.cargo/bin/
200-
~/.cargo/registry/index/
201-
~/.cargo/registry/cache/
202-
~/.cargo/git/db/
203-
target/
204-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo. lock') }}
205-
restore-keys: |
206-
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
207-
${{ runner.os }}-cargo-wheels-
208-
209218
- name: Build wheels
210219
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380
211220
with:
@@ -238,19 +247,6 @@ jobs:
238247
with:
239248
python-version: 3.x
240249

241-
- uses: actions/cache@v4
242-
with:
243-
path: |
244-
~/.cargo/bin/
245-
~/.cargo/registry/index/
246-
~/.cargo/registry/cache/
247-
~/.cargo/git/db/
248-
target/
249-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo. lock') }}
250-
restore-keys: |
251-
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
252-
${{ runner.os }}-cargo-wheels-
253-
254250
- name: Build wheels
255251
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380
256252
with:
@@ -282,15 +278,22 @@ jobs:
282278
architecture: ${{ matrix.platform.target }}
283279
python-version: 3.x
284280

285-
- uses: actions/cache@v4
281+
- name: Cache rustup toolchain
282+
uses: actions/cache@v4
286283
with:
287284
path: |
288-
~/.cargo/bin/
289-
~/.cargo/registry/index/
290-
~/.cargo/registry/cache/
291-
~/.cargo/git/db/
292-
target/
293-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo. lock') }}
285+
~/.rustup
286+
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
287+
restore-keys: |
288+
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
289+
290+
- name: Cache Cargo registry
291+
uses: actions/cache@v4
292+
with:
293+
path: |
294+
~/.cargo/git
295+
~/.cargo/registry
296+
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}
294297
restore-keys: |
295298
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
296299
${{ runner.os }}-cargo-wheels-
@@ -326,15 +329,22 @@ jobs:
326329
with:
327330
python-version: 3.x
328331

329-
- uses: actions/cache@v4
332+
- name: Cache rustup toolchain
333+
uses: actions/cache@v4
334+
with:
335+
path: |
336+
~/.rustup
337+
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
338+
restore-keys: |
339+
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
340+
341+
- name: Cache Cargo registry
342+
uses: actions/cache@v4
330343
with:
331344
path: |
332-
~/.cargo/bin/
333-
~/.cargo/registry/index/
334-
~/.cargo/registry/cache/
335-
~/.cargo/git/db/
336-
target/
337-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo. lock') }}
345+
~/.cargo/git
346+
~/.cargo/registry
347+
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}
338348
restore-keys: |
339349
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
340350
${{ runner.os }}-cargo-wheels-

0 commit comments

Comments
 (0)