diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 6fa0cc7f..d8b6baa1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -31,22 +31,26 @@ jobs: with: fetch-depth: 0 + - name: Set up rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: actions/setup-python@v4 name: Install Python ${{ matrix.python }} with: python-version: ${{ matrix.python }} - - name: Update pip - run: | - python -m pip install --upgrade pip + - uses: chia-network/actions/create-venv@main + id: create-venv - - name: Set up rust - uses: actions-rs/toolchain@v1 + - uses: chia-network/actions/activate-venv@main with: - toolchain: stable + directories: ${{ steps.create-venv.outputs.activate-venv-directories }} - name: Install dependencies run: | + python -m pip install --upgrade pip python -m pip install maturin==1.1.0 - name: Build MacOs with maturin on Python ${{ matrix.python }} @@ -54,35 +58,11 @@ jobs: env: MACOSX_DEPLOYMENT_TARGET: '11.0' run: | - python -m venv venv - ln -s venv/bin/activate - . ./activate maturin build -i python --release --strip - name: Build Linux in manylinux2010 with maturin on Python ${{ matrix.python }} if: startsWith(matrix.os, 'ubuntu') run: | - docker run --rm \ - -v ${{ github.workspace }}:/ws --workdir=/ws \ - ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 \ - bash -exc '\ - yum -y install libc6 openssl-devel && \ - source $HOME/.cargo/env && \ - rustup target add x86_64-unknown-linux-musl && \ - rm -rf venv && \ - 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 && \ - if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \ - . ./activate && \ - pip install --upgrade pip - ' docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin:v1.1.0 build --release --strip --manylinux 2014 # Refresh in case any ownerships changed. mv target target.docker && cp -r target.docker target @@ -92,9 +72,6 @@ jobs: - name: Build Windows with maturin on Python ${{ matrix.python }} if: startsWith(matrix.os, 'windows') run: | - python -m venv venv - echo ". .\venv\Scripts\Activate.ps1" > activate.ps1 - . ./activate maturin build -i python --release --strip # Find and install the newly built wheel pip install --no-index --find-links target/wheels/ clvm_tools_rs @@ -102,7 +79,6 @@ jobs: - name: Install clvm_tools_rs wheel if: ${{ !startsWith(matrix.os, 'windows') }} run: | - . ./activate ls 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 @@ -112,13 +88,11 @@ jobs: - name: Install other wheels run: | - . ./activate python -m pip install pytest python -m pip install blspy - 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 @@ -133,7 +107,6 @@ jobs: - name: Ensure clvm, clvm_rs, clvm_tools_rs are installed run: | - . ./activate python -c 'import clvm' python -c 'import clvm; print(clvm.__file__)' python -c 'import clvm_rs; print(clvm_rs.__file__)' @@ -143,7 +116,6 @@ jobs: # Test cldb output both run from python and via its command line tool. - name: "Run step run tests" run: | - . ./activate cargo build # This finds and installs a compatible wheel from the target directory on linux. # We do it here as a hedge against changes in the python environment that might @@ -156,7 +128,6 @@ jobs: - name: "Test step run with mandelbrot, setting print only" run: | - . ./activate python ./resources/tests/lib/steprun.py ./resources/tests/mandelbrot/mandelbrot.clvm.hex resources/tests/mandelbrot/mand_args.txt ./resources/tests/mandelbrot/mandelbrot.sym > mand_output.txt # git diff invoked this way returns 0 (as /bin/true) if there is no difference or 1 if there is. git diff --no-index -s --quiet -- mand_output.txt ./resources/tests/mandelbrot/mand_test.txt @@ -169,7 +140,6 @@ jobs: if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | set -x - . ./activate # Build cmd line tools PYO3_PYTHON=`which python` cargo build --release @@ -200,7 +170,6 @@ jobs: - name: Verify recompilation of cl21 sources if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8') run: | - . ./activate # We need chia-rs for the following. pip install chia-rs # Ensure we're using the sources we have. This is a hedge against @@ -217,18 +186,15 @@ jobs: - name: Install pytest run: | - . ./activate pip install pytest pytest-asyncio - name: Run tests from clvm run: | - . ./activate cd clvm pytest tests - name: Run tests from clvm_tools run: | - . ./activate cd clvm_tools pytest tests