Skip to content

Commit 744a0ef

Browse files
authored
Skip building pythonbuild when not needed (#440)
Only build the Rust `pythonbuild` crate if one of the following is true - We're on `main` - There are builds for the platform - There are changes to the `.rs` files
1 parent 08ef1e2 commit 744a0ef

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

.github/workflows/apple.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ env:
1414

1515
jobs:
1616
pythonbuild:
17+
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
18+
needs:
19+
- generate-matrix
1720
runs-on: depot-macos-latest
1821
steps:
1922
- uses: actions/checkout@v4
@@ -44,6 +47,8 @@ jobs:
4447
runs-on: ubuntu-latest
4548
outputs:
4649
matrix: ${{ steps.set-matrix.outputs.matrix }}
50+
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
51+
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
4752
steps:
4853
- uses: actions/checkout@v4
4954

@@ -64,6 +69,20 @@ jobs:
6469
# Display the matrix for debugging too
6570
cat matrix.json | jq
6671
72+
if jq -e '.include | length > 0' matrix.json > /dev/null; then
73+
# Build matrix has entries
74+
echo "any_builds=true" >> $GITHUB_OUTPUT
75+
else
76+
# Build matrix is empty
77+
echo "any_builds=false" >> $GITHUB_OUTPUT
78+
fi
79+
80+
- uses: tj-actions/changed-files@v45
81+
id: changed
82+
with:
83+
files_yaml: |
84+
pythonbuild:
85+
- "src/*.rs"
6786
build:
6887
needs:
6988
- generate-matrix

.github/workflows/linux.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ env:
1414

1515
jobs:
1616
pythonbuild:
17+
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
18+
needs:
19+
- generate-matrix
1720
runs-on: depot-ubuntu-22.04
1821
steps:
1922
- name: Install System Dependencies
@@ -46,9 +49,9 @@ jobs:
4649
path: target/release/pythonbuild
4750

4851
image:
52+
if: ${{ needs.generate-matrix.outputs.any_builds == 'true' }}
4953
needs:
5054
- generate-matrix
51-
if: ${{ needs.generate-matrix.outputs.any_builds == 'true' }}
5255
strategy:
5356
fail-fast: false
5457
matrix:
@@ -123,6 +126,7 @@ jobs:
123126
outputs:
124127
matrix: ${{ steps.set-matrix.outputs.matrix }}
125128
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
129+
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
126130
steps:
127131
- uses: actions/checkout@v4
128132

@@ -150,7 +154,14 @@ jobs:
150154
# Build matrix is empty
151155
echo "any_builds=false" >> $GITHUB_OUTPUT
152156
fi
153-
157+
158+
- uses: tj-actions/changed-files@v45
159+
id: changed
160+
with:
161+
files_yaml: |
162+
pythonbuild:
163+
- "src/*.rs"
164+
154165
build:
155166
needs:
156167
- generate-matrix

.github/workflows/windows.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ env:
1414

1515
jobs:
1616
pythonbuild:
17+
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
18+
needs:
19+
- generate-matrix
1720
runs-on: 'windows-2022'
1821
steps:
1922
- uses: actions/checkout@v4
@@ -44,6 +47,8 @@ jobs:
4447
runs-on: ubuntu-latest
4548
outputs:
4649
matrix: ${{ steps.set-matrix.outputs.matrix }}
50+
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
51+
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
4752
steps:
4853
- uses: actions/checkout@v4
4954

@@ -63,7 +68,22 @@ jobs:
6368
uv run ci-matrix.py --platform windows --labels '${{ steps.get-labels.outputs.labels }}' > matrix.json && echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
6469
# Display the matrix for debugging too
6570
cat matrix.json | jq
66-
71+
72+
if jq -e '.include | length > 0' matrix.json > /dev/null; then
73+
# Build matrix has entries
74+
echo "any_builds=true" >> $GITHUB_OUTPUT
75+
else
76+
# Build matrix is empty
77+
echo "any_builds=false" >> $GITHUB_OUTPUT
78+
fi
79+
80+
- uses: tj-actions/changed-files@v45
81+
id: changed
82+
with:
83+
files_yaml: |
84+
pythonbuild:
85+
- "src/*.rs"
86+
6787
build:
6888
needs:
6989
- generate-matrix

src/github.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use std::str::FromStr;
66

7-
use crate::release::{bootstrap_llvm, produce_install_only_stripped};
87
use {
9-
crate::release::{produce_install_only, RELEASE_TRIPLES},
8+
crate::release::{
9+
bootstrap_llvm, produce_install_only, produce_install_only_stripped, RELEASE_TRIPLES,
10+
},
1011
anyhow::{anyhow, Result},
1112
bytes::Bytes,
1213
clap::ArgMatches,

0 commit comments

Comments
 (0)