Skip to content

Commit

Permalink
Skip building pythonbuild when not needed (#440)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zanieb authored Dec 20, 2024
1 parent 08ef1e2 commit 744a0ef
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:

jobs:
pythonbuild:
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
needs:
- generate-matrix
runs-on: depot-macos-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -44,6 +47,8 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
steps:
- uses: actions/checkout@v4

Expand All @@ -64,6 +69,20 @@ jobs:
# Display the matrix for debugging too
cat matrix.json | jq
if jq -e '.include | length > 0' matrix.json > /dev/null; then
# Build matrix has entries
echo "any_builds=true" >> $GITHUB_OUTPUT
else
# Build matrix is empty
echo "any_builds=false" >> $GITHUB_OUTPUT
fi
- uses: tj-actions/changed-files@v45
id: changed
with:
files_yaml: |
pythonbuild:
- "src/*.rs"
build:
needs:
- generate-matrix
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:

jobs:
pythonbuild:
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
needs:
- generate-matrix
runs-on: depot-ubuntu-22.04
steps:
- name: Install System Dependencies
Expand Down Expand Up @@ -46,9 +49,9 @@ jobs:
path: target/release/pythonbuild

image:
if: ${{ needs.generate-matrix.outputs.any_builds == 'true' }}
needs:
- generate-matrix
if: ${{ needs.generate-matrix.outputs.any_builds == 'true' }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -123,6 +126,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -150,7 +154,14 @@ jobs:
# Build matrix is empty
echo "any_builds=false" >> $GITHUB_OUTPUT
fi
- uses: tj-actions/changed-files@v45
id: changed
with:
files_yaml: |
pythonbuild:
- "src/*.rs"
build:
needs:
- generate-matrix
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:

jobs:
pythonbuild:
if: ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
needs:
- generate-matrix
runs-on: 'windows-2022'
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -44,6 +47,8 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
any_builds: ${{ steps.set-matrix.outputs.any_builds }}
pythonbuild_changed: ${{ steps.changed.outputs.pythonbuild_any_changed }}
steps:
- uses: actions/checkout@v4

Expand All @@ -63,7 +68,22 @@ jobs:
uv run ci-matrix.py --platform windows --labels '${{ steps.get-labels.outputs.labels }}' > matrix.json && echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
# Display the matrix for debugging too
cat matrix.json | jq
if jq -e '.include | length > 0' matrix.json > /dev/null; then
# Build matrix has entries
echo "any_builds=true" >> $GITHUB_OUTPUT
else
# Build matrix is empty
echo "any_builds=false" >> $GITHUB_OUTPUT
fi
- uses: tj-actions/changed-files@v45
id: changed
with:
files_yaml: |
pythonbuild:
- "src/*.rs"
build:
needs:
- generate-matrix
Expand Down
5 changes: 3 additions & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

use std::str::FromStr;

use crate::release::{bootstrap_llvm, produce_install_only_stripped};
use {
crate::release::{produce_install_only, RELEASE_TRIPLES},
crate::release::{
bootstrap_llvm, produce_install_only, produce_install_only_stripped, RELEASE_TRIPLES,
},
anyhow::{anyhow, Result},
bytes::Bytes,
clap::ArgMatches,
Expand Down

0 comments on commit 744a0ef

Please sign in to comment.