Skip to content

Commit

Permalink
CI: Run run_tests.sh on Windows, test after install (#654)
Browse files Browse the repository at this point in the history
cibuildwheel tries to find tests automatically and run with pytest. This
bypasses some code for test verbosity, so better to run tests in the
dedicated test step. This will help us see exactly where tests fail

Also use the bash run_tests.sh script on Windows, which runs more tests
  • Loading branch information
cookpa authored May 23, 2024
1 parent e481830 commit 8cceaed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: build_wheels

on:
schedule:
Expand Down Expand Up @@ -140,6 +140,7 @@ jobs:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BUILD: cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}
CIBW_TEST_SKIP: "cp*" # We will test during install and test step

# Include latest Python beta
CIBW_PRERELEASE_PYTHONS: True
Expand Down Expand Up @@ -175,9 +176,10 @@ jobs:
- name: Install and test (Windows)
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python -m pip install --find-links=.\wheelhouse\cp${{ matrix.cibw_python }}-${{matrix.platform_id }} antspyx
tests\run_tests.ps1
python -m pip install --find-links=./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} antspyx
bash tests/run_tests.sh
- uses: actions/upload-artifact@v4
with:
Expand Down
57 changes: 32 additions & 25 deletions .github/workflows/wheels_faster.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cross-platform wheel test
name: wheels_faster

on:
workflow_dispatch:
Expand All @@ -16,27 +16,27 @@ jobs:

# Windows 64-bit
- os: windows-latest
python: '3.9'
cibw_python: 39
python: '3.11'
cibw_python: 311
platform_id: win_amd64

# Linux 64-bit
# Linux 64-bit
- os: ubuntu-latest
python: '3.9'
cibw_python: 39
python: '3.11'
cibw_python: 311
platform_id: manylinux_x86_64

# macOS on Intel 64-bit
- os: macos-12
python: '3.9'
cibw_python: 39
python: '3.11'
cibw_python: 311
arch: x86_64
platform_id: macosx_x86_64

# macOS on Apple M1 64-bit, supported for Python 3.10 and later
- os: macos-14
python: '3.10'
cibw_python: 310
python: '3.11'
cibw_python: 311
arch: arm64
platform_id: macosx_arm64

Expand All @@ -56,28 +56,34 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2 setuptools
run: python -m pip install cibuildwheel==2.16.2 setuptools toml

- name: Get package name and version (Linux / Mac)
if: ${{ ! startsWith(matrix.os, 'windows-') }}
run: |
echo PACKAGE_NAME=$( python setup.py --name ) >> $GITHUB_ENV
echo PACKAGE_VERSION=$( python setup.py --version ) >> $GITHUB_ENV
echo "PACKAGE_NAME=$( python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])" )" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$( python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])" )" >> $GITHUB_ENV
# Some shells require "-Encoding utf8" to append to GITHUB_ENV
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions?tool=powershell#environment-files
- name: Get package name and version (Windows)
if: startsWith(matrix.os, 'windows-')
run: |
echo "PACKAGE_NAME=$( python setup.py --name )" | Out-File -FilePath $env:GITHUB_ENV `
-Append
echo "PACKAGE_VERSION=$( python setup.py --version )" | Out-File -FilePath $env:GITHUB_ENV `
-Append
echo "PACKAGE_NAME=$( python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])" )" | Out-File -FilePath $env:GITHUB_ENV ` -Append
echo "PACKAGE_VERSION=$( python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])" )" | Out-File -FilePath $env:GITHUB_ENV ` -Append
- name: Determine macOS version
if: startsWith(matrix.os, 'macos-')
run: |
macos_version=$(sw_vers -productVersion | awk -F '.' '{print $1".0"}')
echo "MACOSX_DEPLOYMENT_TARGET=${macos_version}" >> $GITHUB_ENV
- name: Build wheels
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BUILD: cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}
CIBW_TEST_SKIP: "cp*" # We will test during install and test step

# Include latest Python beta
CIBW_PRERELEASE_PYTHONS: True
Expand All @@ -92,16 +98,17 @@ jobs:
python -m pip install cmake ninja setuptools
CIBW_ARCHS_MACOS: ${{ matrix.arch }}

CIBW_ENVIRONMENT_MACOS: |
CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} CMAKE_PREFIX_PATH=/usr/local
CIBW_BEFORE_ALL_MACOS: |
python -m pip install cmake ninja setuptools
brew update
if ! brew list libpng &>/dev/null; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install libpng
fi
CIBW_ENVIRONMENT_MACOS: |
CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} CMAKE_PREFIX_PATH=/usr/local
run: python -m cibuildwheel --output-dir wheelhouse/cp${{ matrix.cibw_python }}-${{matrix.platform_id }}

- name: Install and test (Linux / Mac)
Expand All @@ -112,12 +119,12 @@ jobs:
- name: Install and test (Windows)
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python -m pip install --find-links=.\wheelhouse\cp${{ matrix.cibw_python }}-${{matrix.platform_id }} antspyx
tests\run_tests.ps1
python -m pip install --find-links=./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} antspyx
bash tests/run_tests.sh
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
retention-days: 3
name: ${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}
path: ./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}/*.whl
path: ./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}/*.whl

0 comments on commit 8cceaed

Please sign in to comment.