Branch on which to repair GitHub Actions #80
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 | |
- fix-github-actions | |
# 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 build on | |
# ubuntu-latest for python 3.10, which is the recent one. | |
# 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'] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Setup_Python_${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
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 | |
- name: build_sdist | |
run: python setup.py sdist | |
- name: check_metadata | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' | |
run: | | |
pip install twine | |
twine check dist/* | |
- name: upload_sdist | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' | |
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 | |
# actual python (now 3.10). | |
# Reference: https://cibuildwheel.readthedocs.io/en/stable/ | |
# OS: Windows, Linux, macOS (x64 and M1), ARM64 | |
# Python: versions 3.7 - 3.10 in testing | |
# Python: versions 3.6 - 3.10 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.10'] | |
include: | |
- os: ubuntu-20.04 | |
cibw_archs: "aarch64" | |
steps: | |
# Using QEMU for aarch64 emulation | |
- name: setup QEMU | |
if: matrix.cibw_archs == 'aarch64' | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: arm64 | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Setup_Python_${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: install_deps | |
run: python -m pip install cibuildwheel | |
# unfortunately actions do not have an else statement | |
- name: build_test_aarch64 | |
if: matrix.cibw_archs == 'aarch64' | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_LINUX: "aarch64" | |
CIBW_SKIP: '*-musllinux_*' | |
CIBW_BUILD: "cp3*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy | |
CIBW_TEST_COMMAND: python -m sgp4.tests | |
# unfortunately actions do not have an else statement | |
- name: build_test_normal | |
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: "cp3*" | |
CIBW_BUILD_VERBOSITY: 0 | |
CIBW_TEST_REQUIRES: numpy | |
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@v3 | |
# 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.4.1 | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
skip_existing: true |