Skip to content

Commit 3ae1808

Browse files
committed
CI: Refactor build type check
1 parent 6503b1e commit 3ae1808

1 file changed

Lines changed: 41 additions & 30 deletions

File tree

.github/workflows/build_wheels.yml

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,19 @@ jobs:
3737
name: pr_number
3838
path: pr_number.txt
3939

40-
41-
# Build wheels for multiple platforms, and test them, uploading results for reporting.
42-
build_wheels:
43-
name: Build wheels on ${{ matrix.os }}
44-
runs-on: ${{ matrix.os }}
45-
env:
46-
CI_MATRIX_OS: ${{ matrix.os }} # Unique identifier for test reporting
47-
strategy:
48-
fail-fast: false # Continue building other platforms if one fails
49-
matrix:
50-
include:
51-
- os: ubuntu-latest
52-
cibw_archs: "x86_64 aarch64"
53-
54-
- os: macos-13 # Intel Mac for x86_64 - could not build without specifying 13.0
55-
cibw_archs: "x86_64"
56-
deployment_target: "13.0"
57-
58-
- os: macos-14 # Apple Silicon - could not build without specifying 14.0
59-
cibw_archs: "arm64"
60-
deployment_target: "14.0"
61-
40+
# Explicitly checks branch names and event types
41+
# to correctly determine if a full or quick build is needed.
42+
determine_build_type:
43+
name: Determine Build Strategy
44+
runs-on: ubuntu-latest
45+
outputs:
46+
full_build: ${{ steps.check.outputs.full_build }}
6247
steps:
6348
- name: Checkout repository
6449
uses: actions/checkout@v4
6550
with:
66-
fetch-depth: 0 # full history with tags for setuptools_scm
51+
fetch-depth: 0
6752

68-
# Explicitly checks branch names and event types
69-
# to correctly determine if a full or quick build is needed.
7053
- name: Check if full build needed
7154
id: check
7255
run: |
@@ -79,7 +62,6 @@ jobs:
7962
full_build=true
8063
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
8164
echo "Pull request detected. Checking for C++ file changes."
82-
# safer diff for forked PRs
8365
git fetch origin ${{ github.base_ref }} --depth=1
8466
if git diff --name-only FETCH_HEAD...HEAD | grep -qE '^(third_party/|epigeec/cc/)'; then
8567
echo "C++ files were modified. Forcing full build."
@@ -92,16 +74,44 @@ jobs:
9274
fi
9375
echo "full_build=$full_build" >> $GITHUB_OUTPUT
9476
77+
# Build wheels for multiple platforms, and test them, uploading results for reporting.
78+
build_wheels:
79+
name: Build wheels on ${{ matrix.os }}
80+
runs-on: ${{ matrix.os }}
81+
needs: determine_build_type
82+
env:
83+
CI_MATRIX_OS: ${{ matrix.os }} # Unique identifier for test reporting
84+
strategy:
85+
fail-fast: false # Continue building other platforms if one fails
86+
matrix:
87+
include:
88+
- os: ubuntu-latest
89+
cibw_archs: "x86_64 aarch64"
90+
91+
- os: macos-13 # Intel Mac for x86_64 - could not build without specifying 13.0
92+
cibw_archs: "x86_64"
93+
deployment_target: "13.0"
94+
95+
- os: macos-14 # Apple Silicon - could not build without specifying 14.0
96+
cibw_archs: "arm64"
97+
deployment_target: "14.0"
98+
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
with:
103+
fetch-depth: 0 # full history with tags for setuptools_scm
104+
95105
- name: Set up QEMU (for ARM on Linux)
96106
if: |
97107
runner.os == 'Linux' &&
98-
steps.check.outputs.full_build == 'true' &&
108+
needs.determine_build_type.outputs.full_build == 'true' &&
99109
contains(matrix.cibw_archs, 'aarch64')
100110
uses: docker/setup-qemu-action@v3
101111

102112
# Do not set CIBW_BUILD here, let pyproject.toml handle it
103113
- name: Build wheels (full build)
104-
if: steps.check.outputs.full_build == 'true'
114+
if: needs.determine_build_type.outputs.full_build == 'true'
105115
uses: pypa/cibuildwheel@v3.2.1
106116
with:
107117
output-dir: dist
@@ -113,7 +123,7 @@ jobs:
113123
# Set CIBW_BUILD for quick builds (Python 3.11 only)
114124
- name: Build wheels (quick build)
115125
if: |
116-
steps.check.outputs.full_build == 'false' &&
126+
needs.determine_build_type.outputs.full_build == 'false' &&
117127
(matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14')
118128
uses: pypa/cibuildwheel@v3.2.1
119129
with:
@@ -160,7 +170,8 @@ jobs:
160170
build_sdist:
161171
name: Build source distribution
162172
runs-on: ubuntu-latest
163-
if: steps.check.outputs.full_build == 'true'
173+
needs: determine_build_type
174+
if: needs.determine_build_type.outputs.full_build == 'true'
164175
steps:
165176
- uses: actions/checkout@v4
166177
with:

0 commit comments

Comments
 (0)