From 0fe27c4dbcfa1203d4d8ed5d922340b870d8315e Mon Sep 17 00:00:00 2001 From: Jerome Kelleher Date: Tue, 29 Aug 2023 16:40:36 +0100 Subject: [PATCH] Simplify distribution infrastructure --- .github/workflows/docker/buildwheel.sh | 17 ------ .github/workflows/docker/shared.env | 6 -- .github/workflows/tests.yml | 45 ++++++++++++--- .github/workflows/wheels.yml | 64 +++++++++------------- requirements/CI-tests-pip/requirements.txt | 5 +- 5 files changed, 67 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/docker/buildwheel.sh delete mode 100644 .github/workflows/docker/shared.env diff --git a/.github/workflows/docker/buildwheel.sh b/.github/workflows/docker/buildwheel.sh deleted file mode 100644 index f29b6a0..0000000 --- a/.github/workflows/docker/buildwheel.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -DOCKER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$DOCKER_DIR/shared.env" - -set -e -x - -ARCH=`uname -p` -echo "arch=$ARCH" - - -for V in "${PYTHON_VERSIONS[@]}"; do - PYBIN=/opt/python/$V/bin - rm -rf build/ # Avoid lib build by narrow Python is used by wide python - $PYBIN/python setup.py bdist_wheel -done - -rm dist/*.tar.gz \ No newline at end of file diff --git a/.github/workflows/docker/shared.env b/.github/workflows/docker/shared.env deleted file mode 100644 index 3f29924..0000000 --- a/.github/workflows/docker/shared.env +++ /dev/null @@ -1,6 +0,0 @@ -PYTHON_VERSIONS=( - cp311-cp311 - cp310-cp310 - cp39-cp39 - cp38-cp38 -) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f8fdfb..b239b5d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,8 +19,9 @@ jobs: with: python-version: '3.10' - uses: pre-commit/action@v3.0.0 + test: - name: Python + name: Suite runs-on: ubuntu-latest strategy: matrix: @@ -39,17 +40,45 @@ jobs: - name: Install dependencies run: | python3 -m pip install --upgrade pip - pip install pytest - pip install pytest-cov - pip install pytest-xdist - pip install -r requirements/CI-tests-pip/requirements.txt + python3 -m pip install -r requirements/CI-tests-pip/requirements.txt - name: Test with pytest run: | - pytest --cov=tstrait --cov-report=xml --cov-branch -n 0 tests + python3 -m pytest --cov=tstrait --cov-report=xml --cov-branch -n 0 tests - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - env: + env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Delete coverage run: | - rm .coverage \ No newline at end of file + rm .coverage + + dist-tests: + name: Distribution + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install twine build + - name: Build sdist and wheel + run: | + python -m build + - name: Check distribution artefacts + run: | + python3 -m twine check dist/* + - name: Install wheel + run: | + python3 -m pip install dist/*.whl + - name: Import package + # Don't import from current dir + run: | + cd / + python3 -c "import tstrait" diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e9f1fde..6ec7f62 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -11,50 +11,39 @@ on: types: [published] jobs: - manylinux: + distbuild: + name: Build Distribution runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - submodules: true - - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Build sdist - shell: bash + python-version: '3.10' + - name: Install dependencies run: | - python setup.py sdist - - - name: Upload sdist - uses: actions/upload-artifact@v2 - with: - name: sdist - path: dist - - - name: Build wheels in docker - shell: bash + python3 -m pip install --upgrade pip + python3 -m pip install twine build + - name: Build sdist and wheel run: | - docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2010_x86_64 bash .github/workflows/docker/buildwheel.sh - - - name: Upload Wheels - uses: actions/upload-artifact@v2 + python -m build + - name: Check distribution artefacts + run: | + python3 -m twine check dist/* + - name: Upload wheel and sdist + uses: actions/upload-artifact@v3 with: name: wheels path: dist OSX-test: - needs: ['manylinux'] + needs: ['distbuild'] runs-on: macos-latest strategy: matrix: - python: [3.7, 3.8, 3.9] + python: [3.8, 3.9, "3.10", "3.11"] steps: - name: Download wheels - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: wheels - name: Set up Python ${{ matrix.python }} @@ -69,15 +58,15 @@ jobs: python -c "import tstrait" windows-test: - needs: ['manylinux'] + needs: ['distbuild'] runs-on: windows-latest strategy: matrix: - python: [3.7, 3.8, 3.9] + python: [3.8, 3.9, "3.10", "3.11"] wordsize: [64] steps: - name: Download wheels - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: wheels - name: Set up Python ${{ matrix.python }} @@ -92,15 +81,15 @@ jobs: pip install tstrait --only-binary tstrait -f . python -c "import tstrait" - manylinux-test: + linux-test: runs-on: ubuntu-latest - needs: ['manylinux'] + needs: ['distbuild'] strategy: matrix: python: [3.8, 3.9, "3.10", "3.11"] steps: - name: Download wheels - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: wheels - name: Set up Python @@ -114,13 +103,12 @@ jobs: pip install tstrait --only-binary tstrait -f . python -c "import tstrait" - PyPI_Upload: runs-on: ubuntu-latest - needs: ['windows-test', 'OSX-test', 'manylinux-test'] + needs: ['windows-test', 'OSX-test', 'linux-test'] steps: - name: Download all - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 - name: Move to dist run: | mkdir dist diff --git a/requirements/CI-tests-pip/requirements.txt b/requirements/CI-tests-pip/requirements.txt index 4660244..e5bd405 100644 --- a/requirements/CI-tests-pip/requirements.txt +++ b/requirements/CI-tests-pip/requirements.txt @@ -3,4 +3,7 @@ numba numpy pandas scipy -tskit>=0.5.5 \ No newline at end of file +tskit>=0.5.5 +pytest +pytest-cov +pytest-xdist