update actions, add 3.12, numpy pinning, cleanup #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# GitHub actions for building the distribution and wheels of the sgp4 package | |
# linting and testing the source. | |
# | |
# Contributed by @mworion | |
# | |
# Strategy: | |
# The action is called with each commit, pull request master (and) release | |
# branch. If commit is to release branch, the PyPI upload will follow | |
# successful tests automatically. | |
# | |
# Run lint on python source, build step by step the python distro and | |
# run all package tests for all OS and python versions | |
# | |
# If this job succeeds, build step by step all wheels for all OS and python | |
# versions and run the tests in accelerated mode. | |
# | |
# If the first two jobs succeed, upload the distro and wheels to PyPI | |
# | |
name: test_package | |
on: | |
# the trigger event for running the action is either a push on master or | |
# release branch | |
push: | |
branches: | |
- master | |
- release | |
# or a pull request to master branch | |
pull_request: | |
branches: | |
- master | |
jobs: | |
# This action is split into three jobs: | |
# - Building the distribution linting and testing without acceleration | |
# - Building the wheels for the distribution and testing with acceleration | |
# - Uploading the artifacts to PyPI package if branch is release | |
# The uploading job needs all tests to be finished without error. | |
build_test_dist: | |
# Build the distribution in a matrix. Jobs are done in parallel. | |
# The formal distro which is uploaded to PyPI will be built on | |
# ubuntu-latest for python 3.12. | |
# As in dist build no compilation takes place, we run all tests | |
# in not accelerated mode. | |
runs-on: ${{ matrix.os }} | |
strategy: | |
max-parallel: 15 | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Setup_Python_${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# The build test needs numpy and pyflakes. Adding twine enables for | |
# testing and checking the metadata. Adding wheels for package | |
# installation before running the tests | |
- name: install_deps | |
run: pip install numpy pyflakes setuptools twine | |
- name: build_sdist | |
run: python setup.py sdist | |
- name: check_metadata | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' | |
run: twine check dist/* | |
- name: upload_sdist | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/*.tar.gz | |
- name: copy_file | |
run: mv dist/sgp4*.* dist/sgp4.tar.gz | |
- name: install_dist | |
run: | | |
pip install dist/sgp4.tar.gz | |
python -c "from sgp4.api import accelerated; print(accelerated)" | |
- name: run_tests | |
run: python -m sgp4.tests | |
build_test_wheels: | |
# Building wheels for different OS, python and platform versions. This is | |
# done with the help of 'cibuildwheel' package. It will run on all | |
# necessary supported OS (native or emulated), each running cibuildwheel on | |
# python 3.12. | |
# Reference: https://cibuildwheel.readthedocs.io/en/stable/ | |
# OS: Windows, Linux, macOS (x64 and M1), ARM64 | |
# Python: versions 3.7 - 3.12 in testing | |
# Python: versions 3.7 - 3.12 in build wheels | |
# As all build wheels are installed after build, the tests run in | |
# accelerated mode only. | |
runs-on: ${{ matrix.os }} | |
needs: [build_test_dist] | |
strategy: | |
max-parallel: 4 | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
python-version: ['3.12'] | |
include: | |
- os: ubuntu-20.04 | |
cibw_archs: "aarch64" | |
python-version: '3.12' | |
steps: | |
# Using QEMU for aarch64 emulation | |
- name: setup QEMU | |
if: matrix.cibw_archs == 'aarch64' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Setup_Python_${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: install_deps | |
run: python -m pip install cibuildwheel | |
# unfortunately actions do not have an else statement | |
# and I have to split builds due to numpy pinning | |
- name: build_test_aarch64_until_p39 | |
if: matrix.cibw_archs == 'aarch64' | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_LINUX: "aarch64" | |
CIBW_SKIP: '*-musllinux_*' | |
CIBW_BUILD: "cp37-* cp38-* cp39-*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy==1.21.1 | |
CIBW_TEST_COMMAND: python -m sgp4.tests | |
- name: build_test_normal_until_p39 | |
if: matrix.cibw_archs != 'aarch64' | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" | |
CIBW_ARCHS_LINUX: "auto" | |
CIBW_SKIP: '*-musllinux_*' | |
CIBW_BUILD: "cp37-* cp38-* cp39-*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy==1.21.1 | |
CIBW_TEST_COMMAND: python -m sgp4.tests | |
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64" | |
- name: build_test_aarch64_from_p310 | |
if: matrix.cibw_archs == 'aarch64' | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_LINUX: "aarch64" | |
CIBW_SKIP: '*-musllinux_*' | |
CIBW_BUILD: "cp310-* cp311-* cp312-*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy==1.26.1 | |
CIBW_TEST_COMMAND: python -m sgp4.tests | |
- name: build_test_normal_from_p310 | |
if: matrix.cibw_archs != 'aarch64' | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_SKIP: '*-musllinux_*' | |
CIBW_BUILD: "cp310-* cp311-* cp312-*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy==1.26.1 | |
CIBW_TEST_COMMAND: python -m sgp4.tests | |
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64" | |
- name: upload_wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheelhouse | |
path: wheelhouse | |
upload_to_pypi: | |
# Finally, we collect all out data from the artifacts and put them back to | |
# dist directory for an upload. The final step waits for the other jobs to | |
# be finished and starts only if the trigger event of the action was a push | |
# on release branch | |
runs-on: [ubuntu-latest] | |
needs: [build_test_dist, build_test_wheels] | |
if: | | |
github.event_name == 'push' && | |
github.ref == 'refs/heads/release' | |
steps: | |
- uses: actions/setup-python@v4 | |
# download dist files | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
# download wheels | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheelhouse | |
path: dist | |
# For the activation of the PyPI index, please add a secret token from | |
# PyPI to the GitHub repo, give it a name and replace in the password | |
# reference the <pypi_password> with the name of the secret's name you have | |
# chosen for the PyPI token. | |
- name: upload_to_pypi | |
uses: pypa/gh-action-pypi-publish@v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
skip_existing: true |