Skip to content

Commit 2715d83

Browse files
committed
feat: Added review tests for exclude_list
1 parent 102fad2 commit 2715d83

File tree

2 files changed

+243
-0
lines changed

2 files changed

+243
-0
lines changed

.github/workflows/unit-tests.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,194 @@ jobs:
6868
6969
- name: Verify S3 wheels
7070
run: python verify_s3_wheels.py ${{ secrets.DL_BUCKET }} ${{ needs.get-supported-versions.outputs.oldest_supported_python }}
71+
72+
# Test building excluded packages on Linux
73+
test-exclude-linux:
74+
name: Test exclude builds - Linux (Python ${{ matrix.python-version }})
75+
needs: get-supported-versions
76+
runs-on: ubuntu-latest
77+
continue-on-error: true
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
82+
steps:
83+
- name: Checkout repository
84+
uses: actions/checkout@v4
85+
86+
- name: Setup Python ${{ matrix.python-version }}
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: ${{ matrix.python-version }}
90+
91+
- name: Install dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
pip install -r build_requirements.txt
95+
96+
- name: Install OS dependencies
97+
run: os_dependencies/ubuntu.sh
98+
99+
- name: Get packages to test
100+
id: packages
101+
run: |
102+
PACKAGES=$(python extract_exclude_packages.py --platform linux --python ${{ matrix.python-version }})
103+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
104+
echo "Packages to test: $PACKAGES"
105+
106+
- name: Test building excluded packages
107+
if: steps.packages.outputs.packages != ''
108+
run: python build_wheels_from_file.py --requirements ${{ steps.packages.outputs.packages }}
109+
110+
# Test building excluded packages on Windows
111+
test-exclude-windows:
112+
name: Test exclude builds - Windows (Python ${{ matrix.python-version }})
113+
needs: get-supported-versions
114+
runs-on: windows-latest
115+
continue-on-error: true
116+
strategy:
117+
fail-fast: false
118+
matrix:
119+
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
120+
steps:
121+
- name: Checkout repository
122+
uses: actions/checkout@v4
123+
124+
- name: Setup Python ${{ matrix.python-version }}
125+
uses: actions/setup-python@v5
126+
with:
127+
python-version: ${{ matrix.python-version }}
128+
129+
- name: Install dependencies
130+
run: |
131+
python -m pip install --upgrade pip
132+
pip install -r build_requirements.txt
133+
134+
- name: Get packages to test
135+
id: packages
136+
run: |
137+
$PACKAGES = python extract_exclude_packages.py --platform windows --python ${{ matrix.python-version }}
138+
echo "packages=$PACKAGES" >> $env:GITHUB_OUTPUT
139+
echo "Packages to test: $PACKAGES"
140+
141+
- name: Test building excluded packages
142+
if: steps.packages.outputs.packages != ''
143+
run: python build_wheels_from_file.py --requirements ${{ steps.packages.outputs.packages }}
144+
145+
# Test building excluded packages on macOS
146+
test-exclude-macos:
147+
name: Test exclude builds - macOS (Python ${{ matrix.python-version }})
148+
needs: get-supported-versions
149+
runs-on: macos-latest
150+
continue-on-error: true
151+
strategy:
152+
fail-fast: false
153+
matrix:
154+
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
155+
steps:
156+
- name: Checkout repository
157+
uses: actions/checkout@v4
158+
159+
- name: Setup Python ${{ matrix.python-version }}
160+
uses: actions/setup-python@v5
161+
with:
162+
python-version: ${{ matrix.python-version }}
163+
164+
- name: Install dependencies
165+
run: |
166+
python -m pip install --upgrade pip
167+
pip install -r build_requirements.txt
168+
169+
- name: Install OS dependencies
170+
run: os_dependencies/macos.sh
171+
172+
- name: Get packages to test
173+
id: packages
174+
run: |
175+
PACKAGES=$(python extract_exclude_packages.py --platform macos --python ${{ matrix.python-version }})
176+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
177+
echo "Packages to test: $PACKAGES"
178+
179+
- name: Test building excluded packages
180+
if: steps.packages.outputs.packages != ''
181+
run: python build_wheels_from_file.py --requirements ${{ steps.packages.outputs.packages }}
182+
183+
# Test building excluded packages on Linux ARM64
184+
test-exclude-linux-arm64:
185+
name: Test exclude builds - Linux ARM64 (Python ${{ matrix.python-version }})
186+
needs: get-supported-versions
187+
runs-on: ubuntu-24.04-arm
188+
container: python:${{ matrix.python-version }}-bookworm
189+
continue-on-error: true
190+
strategy:
191+
fail-fast: false
192+
matrix:
193+
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
194+
steps:
195+
- name: Checkout repository
196+
uses: actions/checkout@v4
197+
198+
- name: Install dependencies
199+
run: |
200+
python -m pip install --upgrade pip
201+
pip install -r build_requirements.txt
202+
203+
- name: Install OS dependencies
204+
run: os_dependencies/linux_arm.sh
205+
206+
- name: Get packages to test
207+
id: packages
208+
run: |
209+
PACKAGES=$(python extract_exclude_packages.py --platform linux --python ${{ matrix.python-version }})
210+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
211+
echo "Packages to test: $PACKAGES"
212+
213+
- name: Test building excluded packages
214+
if: steps.packages.outputs.packages != ''
215+
run: python build_wheels_from_file.py --requirements ${{ steps.packages.outputs.packages }}
216+
217+
# Test building excluded packages on Linux ARMv7
218+
test-exclude-linux-armv7:
219+
name: Test exclude builds - Linux ARMv7 (Python ${{ matrix.python-version }})
220+
needs: get-supported-versions
221+
runs-on: ubuntu-latest
222+
continue-on-error: true
223+
strategy:
224+
fail-fast: false
225+
matrix:
226+
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
227+
steps:
228+
- name: Set up QEMU for ARMv7
229+
uses: docker/setup-qemu-action@v3
230+
with:
231+
platforms: linux/arm/v7
232+
233+
- name: Checkout repository
234+
uses: actions/checkout@v4
235+
236+
- name: Get packages to test
237+
id: packages
238+
run: |
239+
pip install pyyaml
240+
PACKAGES=$(python extract_exclude_packages.py --platform linux --python ${{ matrix.python-version }})
241+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
242+
echo "Packages to test: $PACKAGES"
243+
244+
- name: Test building excluded packages (in Docker)
245+
if: steps.packages.outputs.packages != ''
246+
run: |
247+
docker run --rm --platform linux/arm/v7 \
248+
-v $(pwd):/work \
249+
-w /work \
250+
-e PIP_NO_CACHE_DIR=1 \
251+
-e LDFLAGS="-Wl,-z,max-page-size=0x1000" \
252+
python:${{ matrix.python-version }}-bookworm \
253+
bash -c "
254+
set -e
255+
python --version
256+
python -m pip install --no-cache-dir --upgrade pip
257+
python -m pip install --no-cache-dir -r build_requirements.txt
258+
bash os_dependencies/linux_arm.sh
259+
. \$HOME/.cargo/env 2>/dev/null || true
260+
python build_wheels_from_file.py --requirements ${{ steps.packages.outputs.packages }}
261+
"

extract_exclude_packages.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
#
3+
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
"""Extract excluded packages for a platform/python combination.
8+
9+
Usage: python extract_exclude_packages.py [platform] [python_version]
10+
"""
11+
12+
import sys
13+
14+
import yaml
15+
16+
from packaging.specifiers import SpecifierSet
17+
18+
PLATFORM_MAP = {"win32": "windows", "linux": "linux", "darwin": "macos"}
19+
ALL_PLATFORMS = ["linux", "windows", "macos"]
20+
21+
22+
def get_excluded_packages(platform=None, python_version=None):
23+
"""Get packages excluded for the given platform/python combination."""
24+
packages = set()
25+
26+
with open("exclude_list.yaml") as f:
27+
data = yaml.safe_load(f)
28+
29+
for entry in data:
30+
platforms = entry.get("platform", [])
31+
platforms = [platforms] if isinstance(platforms, str) else platforms
32+
platforms = [PLATFORM_MAP.get(p, p) for p in platforms] or ALL_PLATFORMS
33+
34+
if platform and platform not in platforms:
35+
continue
36+
37+
pythons = entry.get("python", [])
38+
pythons = [pythons] if isinstance(pythons, str) else pythons
39+
40+
if python_version and pythons:
41+
if not any(python_version in SpecifierSet(c) for c in pythons):
42+
continue
43+
44+
packages.add(entry["package_name"])
45+
46+
return sorted(packages)
47+
48+
49+
if __name__ == "__main__":
50+
platform = sys.argv[1] if len(sys.argv) > 1 else None
51+
python_ver = sys.argv[2] if len(sys.argv) > 2 else None
52+
print(" ".join(get_excluded_packages(platform, python_ver)))

0 commit comments

Comments
 (0)