diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-aarch64.yml deleted file mode 100644 index 1dfaa0d..0000000 --- a/.github/workflows/build-aarch64.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Build ARM64 wheels - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheel on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [[ARM64, Linux]] - - steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Prepare cibuildwheel - run: | - if [ ! -f "venv" ]; then rm -rf venv; fi - sudo apt-get install python3-venv python3-pip -y - python3 -m venv venv - source venv/bin/activate - python -m pip install --upgrade pip - pip install wheel - pip install cibuildwheel==2.4.0 - - - name: Lint source with flake8 - run: | - source venv/bin/activate - pip install flake8 - flake8 tests setup.py - - - name: Build wheel and test - run: | - source venv/bin/activate - python -m cibuildwheel --output-dir dist - env: - # build python 3.7, 3.8, 3.9, 3.10 - CIBW_BUILD: cp37* cp38-* cp39-* cp310-* - CIBW_SKIP: '*-musllinux_*' - CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 - # we need boost - CIBW_BEFORE_ALL_LINUX: > - yum -y install boost-devel - && yum -y install epel-release - && yum -y install cmake3 gcc-c++ - && rm -rf /usr/local/bin/cmake - && ln -s /usr/bin/cmake3 /usr/local/bin/cmake - && cmake --version - && uname -a - CIBW_BEFORE_BUILD_LINUX: > - python -m pip install --upgrade pip - CIBW_BUILD_VERBOSITY_LINUX: 0 - CIBW_TEST_REQUIRES: pytest - CIBW_TEST_COMMAND: py.test -v {project}/tests - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: wheels - path: ./dist - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo ::set-output name=HAS_SECRET::${HAS_SECRET} - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: | - source venv/bin/activate - pip install twine - - - name: Publish distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: | - source venv/bin/activate - twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Publish distribution to Test PyPI - if: steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - run: | - source venv/bin/activate - twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Clean up - run: | - rm -rf venv - rm -rf dist diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml deleted file mode 100644 index c816c34..0000000 --- a/.github/workflows/build-m1-wheel.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Build M1 Wheels - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheel on Mac M1 - runs-on: [m1] - strategy: - fail-fast: false - - steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/main' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Ensure dependencies are present - run: | - arch -arm64 brew install boost - arch -arm64 brew install python@3.9 - arch -arm64 brew install python@3.10 - - - name: Build m1 wheels - run: | - rm -rf venv - arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip wheel -w dist --no-deps . - arch -arm64 pip install delocate - arch -arm64 delocate-wheel -v dist/*cp39*.whl - deactivate - rm -rf venv - arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip wheel -w dist --no-deps . - arch -arm64 pip install delocate - arch -arm64 delocate-wheel -v dist/*cp310*.whl - deactivate - rm -rf venv - - - name: Test wheel - run: | - rm -rf venv - arch -arm64 $(brew --prefix python@3.9)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip install ./dist/*cp39*.whl - arch -arm64 pip install pytest - arch -arm64 ./venv/bin/pytest -v ./tests - deactivate - rm -rf venv - arch -arm64 $(brew --prefix python@3.10)/libexec/bin/python -m venv venv - . venv/bin/activate - arch -arm64 pip install ./dist/*cp310*.whl - arch -arm64 pip install pytest - arch -arm64 ./venv/bin/pytest -v ./tests - deactivate - rm -rf venv - - - name: Create sha256 hash - run: | - mkdir hashes - cd ./dist - shasum -a 256 * - shasum -a 256 * > ../hashes/chiabip158-wheel-m1-sha256.txt - - - name: Upload hashes - uses: actions/upload-artifact@v2 - with: - name: blspy-hashes - path: ./hashes - - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: ./dist - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo ::set-output name=HAS_SECRET::${HAS_SECRET} - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: arch -arm64 pip install twine - - - name: Publish distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' - - - name: Publish distribution to Test PyPI - if: steps.check_secrets.outputs.HAS_SECRET - env: - TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - TWINE_USERNAME: __token__ - TWINE_NON_INTERACTIVE: 1 - TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'dist/*' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07ae414..fdd0fd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,81 +1,282 @@ -name: Build wheels +name: build - check - upload -on: [push, pull_request] +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} + cancel-in-progress: true jobs: - build_wheels: - name: Build wheel on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + build-wheels: + name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: + - name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + cibw-archs-macos: + arm: arm64 + intel: x86_64 + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + - name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + python: + - major-dot-minor: '3.7' + cibw-build: 'cp37-*' + matrix: '3.7' + - major-dot-minor: '3.8' + cibw-build: 'cp38-*' + matrix: '3.8' + - major-dot-minor: '3.9' + cibw-build: 'cp39-*' + matrix: '3.9' + - major-dot-minor: '3.10' + cibw-build: 'cp310-*' + matrix: '3.10' + arch: + - name: ARM + matrix: arm + - name: Intel + matrix: intel + exclude: + # Only partial entries are required here by GitHub Actions so generally I + # only specify the `matrix:` entry. The super linter complains so for now + # all entries are included to avoid that. Reported at + # https://github.com/github/super-linter/issues/3016 + - os: + name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + arch: + name: ARM + matrix: arm + - os: + name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + python: + major-dot-minor: '3.7' + cibw-build: 'cp37-*' + matrix: '3.7' + arch: + name: ARM + matrix: arm + - os: + name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + python: + major-dot-minor: '3.8' + cibw-build: 'cp38-*' + matrix: '3.8' + arch: + name: ARM + matrix: arm steps: - - name: Cancel previous runs on the same branch - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-python@v2 - name: Install Python + - uses: Chia-Network/actions/setup-python@main with: - python-version: '3.8' - - - name: Lint source with flake8 - run: | - python -m pip install --upgrade pip - pip install flake8 - flake8 tests setup.py + python-version: ${{ matrix.python.major-dot-minor }} - - name: Build source distribution with Ubuntu - if: startsWith(matrix.os, 'ubuntu') + - name: Install pipx run: | - pip install build - python -m build --sdist --outdir dist . + pip install pipx - - name: Build ${{ matrix.os }} wheels and test - uses: joerick/cibuildwheel@v2.3.1 + - name: Build and test + uses: pypa/cibuildwheel@v2.7.0 with: output-dir: dist env: - # build just python 3.7 - CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* - CIBW_SKIP: '*-musllinux_*' + CIBW_BUILD_VERBOSITY_MACOS: 0 + CIBW_BUILD_VERBOSITY_LINUX: 0 + CIBW_BUILD_VERBOSITY_WINDOWS: 0 + CIBW_BUILD: ${{ matrix.python.cibw-build }} + CIBW_SKIP: '*-manylinux_i686 *-win32 *-musllinux_*' + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010 - # we need boost - # we need pybind11 to be globally available for cibuildwheel CIBW_BEFORE_ALL_LINUX: > yum -y install boost-devel gcc-c++ + && uname -a CIBW_BEFORE_BUILD_LINUX: > python -m pip install --upgrade pip && pip install pybind11 - # CIBW_ARCHS_MACOS: x86_64 arm64 universal2 - CIBW_ARCHS_MACOS: x86_64 - CIBW_TEST_SKIP: '*_arm64 *_universal2:arm64' + CIBW_ARCHS_MACOS: ${{ matrix.os.cibw-archs-macos[matrix.arch.matrix] }} CIBW_BEFORE_ALL_MACOS: > brew install boost CIBW_BEFORE_BUILD_MACOS: > python -m pip install --upgrade pip && pip install pybind11 - CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.14 - CIBW_BUILD_VERBOSITY_MACOS: 0 - CIBW_BEFORE_BUILD_WINDOWS: > + CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14" + CIBW_BEFORE_ALL_WINDOWS: > python -m pip install --upgrade pip && pip install pybind11 CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: py.test -v {project}/tests - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./dist + + build-sdist: + name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Build source distribution + run: | + pip install build + python -m build --sdist --outdir dist . + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./dist + + check: + name: Check - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: flake8 + run: | + pip install flake8 + flake8 tests setup.py + + - name: mypy + run: | + pip install mypy + mypy --config-file mypi.ini setup.py tests + + upload: + name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + needs: + - build-wheels + - build-sdist + - check + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - major-dot-minor: '3.9' + matrix: '3.9' + arch: + - name: Intel + matrix: intel + + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Download artifacts + uses: actions/download-artifact@v3 with: - name: wheels + name: packages path: ./dist - name: Test for secrets access