Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

20230326 better print #1500

20230326 better print

20230326 better print #1500

Workflow file for this run

# Thanks: clvm_rs' github actions.
name: Build Mac, Linux, and Windows wheels
on:
push:
branches:
- base
- dev
tags:
- '**'
pull_request:
branches:
- '**'
jobs:
build_wheels:
name: Wheel on ${{ matrix.os }} py-${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python: [3.8, 3.9, '3.10', 3.11]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- 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
- name: Set up rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install dependencies
run: |
python -m pip install maturin==1.1.0
- name: Set up feature flags to use
shell: bash
run: |
python -m pip install tomlkit
USE_FEATURES=$(./support/feature-fishing.py)
echo "USE_FEATURES=${USE_FEATURES}" >> "$GITHUB_ENV"
- name: Build MacOs with maturin on Python ${{ matrix.python }}
if: startsWith(matrix.os, 'macos')
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
# Ensure an empty .cargo-lock file exists.
touch target/release/.cargo-lock
- name: Build alpine wheel via docker
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: |
cd resources/alpine && docker build -t clvm-tools-rs-alpine .
docker run -v ${GITHUB_WORKSPACE}:/root/clvm_tools_rs -t clvm-tools-rs-alpine sh /root/build-alpine.sh
- name: Build Windows with maturin on Python ${{ matrix.python }}
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
python -m venv venv
cp venv/Scripts/activate .
. ./activate
maturin build -i python --release --strip
# Find and install the newly built wheel
python support/wheelname.py
- 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
export WHEEL_PATH=$(echo ${{ matrix.python }} | python -c 'DOTLESS=input().replace(".", ""); import glob; print(" ".join(filter(lambda x: "musl" not in x, glob.glob("target/wheels/clvm_tools_rs-*-cp*-*.whl"))))' )
echo ${WHEEL_PATH}
pip install ${WHEEL_PATH}
- 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
echo "installing clvm_rs via pip"
pip install clvm_rs
echo "installing clvm_tools for clvm tests"
# Ensure clvm_tools is installed from its own repo.
git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch
python -m pip install ./clvm_tools
- 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__)'
python -c 'import clvm_tools_rs; print(clvm_tools_rs.__file__)'
# Test cldb output both run from python and via its command line tool.
# Thanks: https://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error
- name: "Run step run tests"
shell: bash
run: |
. ./activate
cargo build --no-default-features --features="${USE_FEATURES}"
cd resources/tests && \
python test_clvm_step.py && \
python mandelbrot-cldb.py
- name: Verify recompilation of old sources match
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: |
. ./activate
# Build cmd line tools
PYO3_PYTHON=`which python` cargo build --no-default-features --features="${USE_FEATURES}" --release
# Grab chia-blockchain
rm -rf chia-blockchain
git clone https://github.com/Chia-Network/chia-blockchain
# Check recompiles
cp support/recompile_check.py chia-blockchain
(cd chia-blockchain && python recompile_check.py)
- name: Test Classic command line tools with pytest
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: |
python -m pip install pytest
# This script installs the wheel built during this workflow.
python support/wheelname.py
# TODO: bring in the other tests in resources/tests/cmdline/tests besides cmds_test.py
(cd resources/tests/cmdline/tests && py.test cmds_test.py )
- 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
# changes made by any other step doing operations on pip.
# This script installs the wheel built during this workflow.
python support/wheelname.py
(cd resources/tests && python check-recompiles.py)
- name: Verify recompilation follows date and modification rules
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: |
python support/wheelname.py
python resources/tests/test-clvm-recompile-behavior.py
- 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
- name: Run tests
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: cargo test --features="${USE_FEATURES}"
- name: Check coverage
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.8')
run: |
cargo install grcov
rustup component add llvm-tools-preview
python ./resources/coverage/run_coverage.py --require-percent 60
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./target/wheels/
- name: Install Twine
run: pip install twine
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SECRET
unset HAS_AWS_SECRET
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT
if [ -n "$AWS_SECRET" ]; then HAS_AWS_SECRET='true' ; fi
echo HAS_AWS_SECRET=${HAS_AWS_SECRET} >>$GITHUB_OUTPUT
env:
SECRET: "${{ secrets.test_pypi_password }}"
AWS_SECRET: "${{ secrets.INSTALLER_UPLOAD_KEY }}"
- 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 'target/wheels/*'
- name: publish (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: twine upload --non-interactive --skip-existing --verbose 'target/wheels/*'
- name: Publish Dev
if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/dev'
shell: bash
working-directory: ./target/wheels
env:
AWS_ACCESS_KEY_ID: "${{ secrets.INSTALLER_UPLOAD_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.INSTALLER_UPLOAD_SECRET }}"
AWS_REGION: us-west-2
run: |
FILES=$(find . -type f -name '*.whl')
while IFS= read -r file; do
filename=$(basename $file)
aws --no-progress s3 cp "$file" "s3://download.chia.net/simple-dev/clvm-tools-rs/$filename"
done <<< "$FILES"
fmt:
runs-on: ubuntu-20.04
name: cargo fmt
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: fmt
run: cargo fmt -- --files-with-diff --check
clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- name: clippy
run: cargo clippy --all -- -D warnings
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
unit_tests:
runs-on: ubuntu-20.04
name: Unit tests
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: cargo test
run: cargo test
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: Install tarpaulin
run: cargo +nightly install cargo-tarpaulin
- name: Run tarpaulin
run: cargo tarpaulin --no-dead-code --engine llvm --workspace --all-features --ignore-panics --out Lcov
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
if: always()
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
path-to-lcov: './lcov.info'