diff --git a/.github/workflows/build-arm64-wheels.yml b/.github/workflows/build-arm64-wheels.yml deleted file mode 100644 index ef1d47cc..00000000 --- a/.github/workflows/build-arm64-wheels.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Build ARM64 wheels on ubuntu-latest - -on: - push: - branches: - - main - - dev - tags: - - '**' - pull_request: - branches: - - '**' - -jobs: - build_wheels: - name: ARM64 Python Wheels on ubuntu-latest - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [[ARM64, Linux]] - - steps: - - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Set up QEMU on x86_64 - if: startsWith(matrix.os, 'ubuntu-latest') - id: qemu - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - - name: Build Python wheels - run: | - podman run --rm=true \ - -v ${{ github.workspace }}:/ws:rw --workdir=/ws \ - quay.io/pypa/manylinux2014_aarch64 \ - bash -exc '\ - echo $PATH && \ - curl -L https://sh.rustup.rs > rustup-init.sh && \ - sh rustup-init.sh -y && \ - yum -y install openssl-devel && \ - source $HOME/.cargo/env && \ - rustup target add aarch64-unknown-linux-musl && \ - rm -rf venv && \ - export PATH=/opt/python/cp310-cp310/bin/:$PATH && \ - export PATH=/opt/python/cp39-cp39/bin/:$PATH && \ - export PATH=/opt/python/cp38-cp38/bin/:$PATH && \ - export PATH=/opt/python/cp37-cp37m/bin/:$PATH && \ - /opt/python/cp38-cp38/bin/python -m venv venv && \ - if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \ - . ./activate && \ - pip install maturin && \ - CC=gcc maturin build -m wheel/Cargo.toml --release --strip --manylinux 2014 --features=openssl \ - ' - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: wheels - path: wheel/target/wheels/ - - - name: Install Twine - run: | - if [ ! -f "venv" ]; then rm -rf venv; fi - sudo apt-get install python3-venv python3-pip -y - python3 -m venv venv - if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi - . ./activate - pip install setuptools_rust - pip install twine - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: publish (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: | - . ./activate - twine upload --non-interactive --skip-existing --verbose 'wheel/target/wheels/*' - - - name: Clean up AMR64 - if: startsWith(matrix.os, 'ARM64') - 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 aa3d7778..00000000 --- a/.github/workflows/build-m1-wheel.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Build M1 Wheels - -on: - push: - branches: - - main - - dev - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - 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 Mac M1 - runs-on: [m1] - strategy: - fail-fast: false - - steps: - - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh - arch -arm64 sh rust.sh -y - - - name: Build m1 wheels - run: | - arch -arm64 python3 -m venv venv - . ./venv/bin/activate - export PATH=~/.cargo/bin:$PATH - arch -arm64 pip install maturin - arch -arm64 maturin build -m wheel/Cargo.toml -i python --release --strip --features=openssl - - - name: Install clvm_rs wheel - run: | - . ./venv/bin/activate - ls ./wheel/target/wheels/ - arch -arm64 pip install ./wheel/target/wheels/clvm_rs*.whl - - - name: Install other wheels - run: | - . ./venv/bin/activate - arch -arm64 python -m pip install pytest - arch -arm64 python -m pip install blspy - - - name: install clvm & clvm_tools - run: | - . ./venv/bin/activate - arch -arm64 git clone https://github.com/Chia-Network/clvm.git --branch=main --single-branch - arch -arm64 python -m pip install ./clvm - - arch -arm64 git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - arch -arm64 python -m pip install ./clvm_tools - - - name: Ensure clvm, clvm_rs, clvm_tools are installed - run: | - . ./venv/bin/activate - arch -arm64 python -c 'import clvm' - arch -arm64 python -c 'import clvm; print(clvm.__file__)' - arch -arm64 python -c 'import clvm_rs; print(clvm_rs.__file__)' - arch -arm64 python -c 'import clvm_tools; print(clvm_tools.__file__)' - - - name: Run tests from clvm - run: | - . ./venv/bin/activate - cd clvm - arch -arm64 pytest tests - - - name: Run tests from clvm_tools - continue-on-error: true - run: | - . ./venv/bin/activate - cd clvm_tools - arch -arm64 pytest tests - - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: ./wheel/target/wheels - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: Install twine - run: | - . ./venv/bin/activate - 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: | - . ./venv/bin/activate - arch -arm64 twine upload --non-interactive --skip-existing --verbose 'wheel/target/wheels/*' diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3a51e8c8..c1a50ef7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,35 +1,158 @@ -name: Build Mac, Linux, and Windows wheels +name: build - check - upload on: push: branches: - - main - - dev + - 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 + +defaults: + run: + shell: bash jobs: - build_wheels: - name: Wheel on ${{ matrix.os }} py-${{ matrix.python }} - 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] - python: [3.7] + os: + - name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + - 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-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.7' + - major-dot-minor: '3.8' + cibw-build: 'cp38-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.8' + - major-dot-minor: '3.9' + cibw-build: 'cp39-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.9' + - major-dot-minor: '3.10' + cibw-build: 'cp310-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.10' + - major-dot-minor: '3.11' + cibw-build: 'cp311-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.11' + 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 steps: - - uses: actions/checkout@v3 + - 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 - name: Install Python ${{ matrix.python }} + - uses: Chia-Network/actions/setup-python@main with: - python-version: ${{ matrix.python }} + python-version: ${{ matrix.python.major-dot-minor }} + + - uses: Chia-Network/actions/create-venv@main + id: create-venv + + - uses: Chia-Network/actions/activate-venv@main + with: + directories: ${{ steps.create-venv.outputs.activate-venv-directories }} - name: Update pip run: | @@ -45,132 +168,119 @@ jobs: python -m pip install maturin - name: Build MacOs with maturin on Python ${{ matrix.python }} - if: startsWith(matrix.os, 'macos') + if: matrix.os.matrix == 'macos' + env: + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.arch.matrix == 'intel' && '10.14' || '11.0' }} run: | - python -m venv venv - ln -s venv/bin/activate - . ./activate - maturin build -m wheel/Cargo.toml --sdist -i python --release --strip --features=openssl + maturin build -i python --release -m wheel/Cargo.toml + # TODO: add back these? --strip --features=openssl - - name: Build Linux in manylinux2014 with maturin on Python ${{ matrix.python }} - if: startsWith(matrix.os, 'ubuntu') + - name: Build Linux with maturin on Python ${{ matrix.python }} + if: matrix.os.matrix == 'ubuntu' run: | podman run --rm=true \ -v ${{ github.workspace }}:/ws:rw --workdir=/ws \ - quay.io/pypa/manylinux2014_x86_64 \ + ${{ matrix.python.by-arch[matrix.arch.matrix].docker-url }} \ bash -exc '\ curl -L https://sh.rustup.rs > rustup-init.sh && \ sh rustup-init.sh -y && \ yum -y install openssl-devel && \ source $HOME/.cargo/env && \ - rustup target add x86_64-unknown-linux-musl && \ - PY_VERSION=${{ matrix.python }} - PY_VERSION=${PY_VERSION/.} && \ - echo "Python version with dot removed is $PY_VERSION" && \ - if [ "$PY_VERSION" = "37" ]; \ - then export SCND_VERSION="${PY_VERSION}m"; \ - else export SCND_VERSION="$PY_VERSION"; fi && \ - echo "Exporting path /opt/python/cp$PY_VERSION-cp$SCND_VERSION/bin" && \ - export PATH=/opt/python/cp$PY_VERSION-cp$SCND_VERSION/bin/:$PATH && \ - /opt/python/cp38-cp38/bin/python -m venv /venv && \ + rustup target add ${{ matrix.python.by-arch[matrix.arch.matrix].rustup-target }} && \ + python${{ matrix.python.major-dot-minor }} -m venv /venv && \ . /venv/bin/activate && \ pip install --upgrade pip && \ pip install maturin && \ - CC=gcc maturin build -m wheel/Cargo.toml --release --strip --manylinux 2014 --features=openssl \ + CC=gcc maturin build --release --manylinux ${{ matrix.python.by-arch[matrix.arch.matrix].manylinux-version }} -m wheel/Cargo.toml \ ' - python -m venv venv - ln -s venv/bin/activate + # TODO: add back these? --strip --features=openssl - name: Build Windows with maturin on Python ${{ matrix.python }} - if: startsWith(matrix.os, 'windows') + if: matrix.os.matrix == 'windows' run: | - python -m venv venv - . .\venv\Scripts\Activate.ps1 - ln -s venv\Scripts\Activate.ps1 activate - maturin build -m wheel/Cargo.toml -i python --release --strip - # this will install into the venv - # it'd be better to use the wheel, but I can't figure out how to do that - # TODO: figure this out - # this does NOT work: pip install wheel/target/wheels/clvm_rs-*.whl - maturin develop --release -m wheel/Cargo.toml - # the line above also doesn't seem to work + maturin build -i python --release -m wheel/Cargo.toml + # TODO: add back these? --strip + # TODO: why no --feature=openssl here? + + - uses: Chia-Network/actions/create-venv@main + id: create-install-venv + + - uses: Chia-Network/actions/activate-venv@main + with: + directories: ${{ steps.create-install-venv.outputs.activate-venv-directories }} - name: Install clvm_rs wheel - if: ${{ !startsWith(matrix.os, 'windows') }} - run: | - . ./activate - ls wheel/target/wheels/ - # this mess puts the name of the `.whl` file into `$WHEEL_PATH` - # remove the dot, use the `glob` lib to grab the file from the directory - WHEEL_PATH=$(echo ${{ matrix.python }} | python -c 'DOTLESS=input().replace(".", ""); import glob; print(" ".join(glob.glob("wheel/target/wheels/clvm_rs-*-cp%s-abi3-*.whl" % DOTLESS)))' ) - echo ${WHEEL_PATH} - pip install ${WHEEL_PATH} - - - name: Install other wheels run: | - . ./activate - python -m pip install pytest - python -m pip install blspy + pip install --no-index --find-links wheel/target/wheels/ clvm_rs - - name: install clvm & clvm_tools - run: | - . ./activate - git clone https://github.com/Chia-Network/clvm.git --branch=main --single-branch - python -m pip install ./clvm + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./wheel/target/wheels/ - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - python -m pip install ./clvm_tools +# check-typestubs: +# name: Check clvm_rs.pyi +# runs-on: ubuntu-latest +# +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 +# with: +# fetch-depth: 0 +# +# - uses: Chia-Network/actions/setup-python@main +# +# - name: check generated clvm_rs.pyi +# run: | +# python wheel/generate_type_stubs.py +# git diff --exit-code - - name: Ensure clvm, clvm_rs, clvm_tools are installed - run: | - . ./activate - python -c 'import clvm' - python -c 'import clvm; print(clvm.__file__)' - python -c 'import clvm_rs; print(clvm_rs.__file__)' - python -c 'import clvm_tools; print(clvm_tools.__file__)' + 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.7' + matrix: '3.7' + arch: + - name: Intel + matrix: intel - - name: Run tests from clvm - run: | - . ./activate - cd clvm - pytest tests + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main - - name: Run tests from clvm_tools - continue-on-error: true + - 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: | - . ./activate - cd clvm_tools - pytest tests + pip install maturin + maturin sdist -m wheel/Cargo.toml - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: wheels + name: packages path: ./wheel/target/wheels/ - - name: Install Twine - run: pip install twine - - - name: Test for secrets access - id: check_secrets - shell: bash - run: | - unset HAS_SECRET - if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT - env: - SECRET: "${{ secrets.test_pypi_password }}" - - - name: publish (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: twine upload --non-interactive --skip-existing --verbose 'wheel/target/wheels/*' - fmt: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest name: cargo fmt steps: - uses: actions/checkout@v3 @@ -179,25 +289,29 @@ jobs: - name: Install rust uses: actions-rs/toolchain@v1 with: - toolchain: stable + # TODO: was stable before, should probably be consistent across projects + toolchain: nightly + components: rustfmt override: true - components: rustfmt, clippy - name: fmt - run: cargo fmt -- --files-with-diff --check + # TODO: didn't have --all before + run: cargo fmt --all -- --files-with-diff --check clippy: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: - toolchain: stable + # TODO: was stable before, should probably be consistent across projects + toolchain: nightly components: clippy override: true - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features + # TODO: didn't use --workspace before, what's that do? + args: --all-features --workspace # leaving out Windows fuzzing for now though it seems supported # https://llvm.org/docs/LibFuzzer.html#q-does-libfuzzer-support-windows @@ -208,18 +322,14 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - python: [3.7] steps: - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Install rust - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: toolchain: nightly - name: cargo-fuzz run: cargo +nightly install cargo-fuzz - - name: build + - name: cargo fuzz run: cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=30 || exit 255" unit_tests: @@ -229,25 +339,272 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python: [3.7] + release: + - name: release + options: --release + - name: not-release + options: '' + features: + - name: no features + options: '' + - name: counters + options: --features=counters + - name: pre-eval + options: --features=pre-eval + - name: pre-eval and counters + options: --features=pre-eval,counters steps: - uses: actions/checkout@v3 with: fetch-depth: 1 - - name: Install rust - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: toolchain: stable - components: rustfmt, clippy + - name: cargo test + run: cargo test ${{ matrix.features.options}} ${{ matrix.release.options }} + + clvm_tests: + name: ${{ matrix.package.name }} tests - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + needs: + - build-wheels + strategy: + fail-fast: false + matrix: + package: + - name: CLVM + directory: clvm + - name: CLVM tools + directory: clvm_tools + os: + - name: macOS + matrix: macos + runs-on: + arm: [macOS, ARM64] + intel: [macos-latest] + - 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-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.7' + - major-dot-minor: '3.8' + cibw-build: 'cp38-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.8' + - major-dot-minor: '3.9' + cibw-build: 'cp39-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.9' + - major-dot-minor: '3.10' + cibw-build: 'cp310-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.10' + - major-dot-minor: '3.11' + cibw-build: 'cp311-*' + by-arch: + arm: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_aarch64 + rustup-target: aarch64-unknown-linux-musl + intel: + manylinux-version: 2014 + docker-url: quay.io/pypa/manylinux2014_x86_64 + rustup-target: x86_64-unknown-linux-musl + matrix: '3.11' + 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 + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout CLVM + uses: actions/checkout@v3 + with: + # for the tags to identify the version + fetch-depth: 0 + path: clvm + repository: Chia-Network/clvm - - name: cargo test (default) - run: cargo test && cargo test --release + - name: Checkout CLVM tools + uses: actions/checkout@v3 + with: + # for the tags to identify the version + fetch-depth: 0 + path: clvm_tools + repository: Chia-Network/clvm_tools + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - uses: Chia-Network/actions/create-venv@main + id: create-venv - - name: cargo test (counters) - run: cargo test --features=counters && cargo test --features=counters --release + - uses: Chia-Network/actions/activate-venv@main + with: + directories: ${{ steps.create-venv.outputs.activate-venv-directories }} + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: packages + path: ./dist - - name: cargo test (pre-eval) - run: cargo test --features=pre-eval && cargo test --features=pre-eval --release + - name: Install packages + run: | + pip install --no-index --dry-run --find-links dist/ clvm_rs | tee .tmp.wheel_path + WHEEL_PATH=dist/$(cat .tmp.wheel_path | sed -n 's;^.*[/\\]dist[/\\]\(.*\)$;\1;p') + if [ "${WHEEL_PATH}" = "" ] + then + echo error: wheel not selected! + exit 1 + else + echo wheel selected: ${WHEEL_PATH} + fi + pip install "${WHEEL_PATH}" ./clvm ./clvm_tools blspy pytest + python -c 'import clvm; print(clvm.__file__)' + python -c 'import clvm_rs; print(clvm_rs.__file__)' + python -c 'import clvm_tools; print(clvm_tools.__file__)' - - name: cargo test (pre-eval and counters) - run: cargo test --features=pre-eval,counters && cargo test --features=pre-eval,counters --release + - name: Test + run: | + # the tests make assumptions about the working directory + cd ${{ matrix.package.directory }} + pytest 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 + - fmt + - clippy + - fuzz_targets + - unit_tests + - clvm_tests + 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: packages + 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 "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT + env: + SECRET: "${{ secrets.test_pypi_password }}" + + - name: Install twine + run: 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: twine upload --non-interactive --skip-existing --verbose 'dist/*'