Make pecos.xmr importable and add unit test (#301) #1014
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
name: Pypi Build and Release | |
on: [push, pull_request] | |
jobs: | |
Pypi-Wheel-Build: | |
name: Build PyPI Wheel | |
strategy: | |
max-parallel: 4 | |
fail-fast: false | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
build_platform: ["manylinux2014_x86_64", "manylinux2014_aarch64"] | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Build Wheel | |
env: | |
DOCKER_IMG: quay.io/pypa/${{ matrix.build_platform }} | |
DOCKER_MNT: pypi_build | |
WHEEL_DIR: wheel # wheel location | |
run: | | |
echo "Build wheel for PECOS using Python version ${{ matrix.python-version }}..." | |
docker run --rm -v $(pwd):/$DOCKER_MNT \ | |
--env PLAT=${{ matrix.build_platform }} --env PIP_VER=${{ matrix.python-version }} \ | |
--env DOCKER_MNT=$DOCKER_MNT --env WHEEL_DIR=$WHEEL_DIR \ | |
$DOCKER_IMG /bin/bash /$DOCKER_MNT/.github/build_pypi_wheel.sh | |
- name: Test Wheel | |
if: matrix.build_platform == 'manylinux2014_x86_64' # Only test for x86, aarch64 simulation too slow | |
env: | |
WHEEL_DIR: wheel # wheel location | |
run: | | |
python3 -m pip install $WHEEL_DIR/$(ls $WHEEL_DIR) | |
mkdir wheel_test | |
cp -r test/ wheel_test/ | |
cd wheel_test | |
python3 -m pip install pytest pytest-coverage | |
python3 -m pytest | |
- name: Check Version Tag | |
id: check-ver-tag | |
run: | | |
if [[ "${{ github.event_name }}" == "push" ]] && \ | |
[[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "match=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload to PyPI | |
if: steps.check-ver-tag.outputs.match == 'true' # Only upload for tags v*.*.* | |
env: | |
TWINE_USERNAME: ${{ secrets. PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets. PYPI_PASSWORD }} | |
WHEEL_DIR: wheel # same as Build-Wheel/WHEEL_DIR | |
run: | | |
WHEEL=$(ls $(pwd)/$WHEEL_DIR) | |
if [ -z $WHEEL ]; then | |
echo "Wheel build not successful, exit" | |
exit 1 | |
fi | |
echo "Will upload $WHEEL to PyPI..." | |
pip install twine --upgrade | |
python3 -m twine upload $(pwd)/$WHEEL_DIR/$WHEEL --verbose |