Skip to content

updating various ci bits, codecov action may be broken due to change … #345

updating various ci bits, codecov action may be broken due to change …

updating various ci bits, codecov action may be broken due to change … #345

name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on:
pull_request:
push:
branches: [ main ]
tags: [ 'v*' ]
release:
types: [ published ]
jobs:
build_sdist:
name: Make SpiceyPy 🌶️ 🥧 Python 🐍 source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout 🌶️ 🥧
uses: actions/checkout@v4
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r test-requirements.txt
python -m pip install build coverage>=5.1.0 twine>=3.3.0
- name: Build 🛠️ sdist source and Install SpiceyPy 🌶️ 🥧
run: |
python -m build --sdist
echo "Running Pip install from sdist"
python -m pip install dist/*.tar.gz --user
- name: Test 🧪 with coverage 📈
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
- name: Check dists
run: |
twine check dist/*
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
build_wheels:
strategy:
matrix:
include:
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "x86_64"}
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "aarch64"}
- config: {"name": "macOS", "os": "macos-14", "arch": "x86_64"}
- config: {"name": "macOS", "os": "macos-14", "arch": "arm64"}
- config: {"name": "Windows", "os": "windows-latest", "arch": "AMD64"}
name: Build SpiceyPy 🌶️ 🥧 Python 🐍 wheels for ${{ matrix.config.os }} ${{ matrix.config.arch }}
env:
CSPICE_CACHE: 1
CIBW_ARCHS: ${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout 🌶️ 🥧
uses: actions/checkout@v4
- name: Setup 🔬🍦🏗️
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: set additional environment variables for macOS arm
if: runner.name == 'macOS' && matrix.config.arch == 'arm64'
run: |
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch arm64'" >> $GITHUB_ENV
- name: set additional environment variables for macOS x86
if: runner.name == 'macOS' && matrix.config.arch == 'x86_64'
run: |
echo "CIBW_ARCHS_MACOS=x86_64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch x86_64'" >> $GITHUB_ENV
- name: Set up QEMU for arm64 builds
if: matrix.config.arch == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Cache libcspice.so for aarch64 builds because they take an hour to build with qemu
if: matrix.config.arch == 'aarch64'
uses: actions/cache@v4
with:
path: ./src/spiceypy/utils/libcspice.so
key: ${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }}
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍 Version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r ci-requirements.txt
python -m pip install cibuildwheel==2.19.1
- name: See if libcspice.so is available from cache
if: matrix.config.arch == 'aarch64'
run: |
pwd
ls src/spiceypy/utils -lahtr
- name: Build wheels for SpiceyPy 🌶️ 🥧
timeout-minutes: 120
run: |
env | grep CIBW
env | grep ARCH
python -m cibuildwheel --output-dir wheelhouse
- name: Extract libcspice.so for aarch64 builds
if: matrix.config.arch == 'aarch64'
run: |
pwd
ls -lahtr
ls src/ -lahtr
ls src/spiceypy/ -lahtr
ls src/spiceypy/utils -lahtr
ls wheelhouse/*
unzip -o wheelhouse/spiceypy-\*.whl 'spiceypy/utils/libcspice.so' -d src/
- name: Check dists
run: |
twine check wheelhouse/*
- name: Upload wheels for SpiceyPy 🌶️ 🥧
uses: actions/upload-artifact@v4
with:
name: artifact-${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }}
path: ./wheelhouse/*.whl
publish_to_pypi:
name: Publish SpiceyPy 🌶️ 🥧 Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install twine
- name: Check dists
run: |
twine check dist/*
- name: Publish distribution 📦 to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
twine upload --non-interactive --skip-existing --repository testpypi dist/*
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --non-interactive --skip-existing dist/*