Merge pull request #142 from Chia-Network/20241017-yaml-upgrade #592
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build M1 Wheels | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
release: | |
types: [published] | |
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 | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build_wheels: | |
name: Build wheel on Mac M1 | |
runs-on: macos-13-arm64 | |
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 https://static.rust-lang.org/rustup/dist/aarch64-apple-darwin/rustup-init.sha256 | awk '{print $1 " *rustup-init"}' > checksum.txt | |
curl -O https://static.rust-lang.org/rustup/dist/aarch64-apple-darwin/rustup-init | |
cat checksum.txt | |
shasum -a 256 -c checksum.txt | |
- name: Install rust | |
run: | | |
chmod +x rustup-init | |
./rustup-init -y || (echo "Rust is already installed. Exiting..." && exit 2) | |
rm rustup-init checksum.txt | |
- name: Build m1 wheels | |
run: | | |
python3 -m venv venv | |
. ./venv/bin/activate | |
export PATH=~/.cargo/bin:$PATH | |
pip install maturin==1.7.0 | |
maturin build -i python --release --strip | |
cargo test | |
- name: Install clvm_tools_rs wheel | |
run: | | |
. ./venv/bin/activate | |
ls target/wheels/ | |
pip install ./target/wheels/clvm_tools_rs*.whl | |
- name: Install other wheels | |
run: | | |
. ./venv/bin/activate | |
python -m pip install pytest | |
python -m pip install blspy | |
- name: install clvm & clvm_tools | |
run: | | |
. ./venv/bin/activate | |
git clone https://github.com/Chia-Network/clvm.git --branch=main --single-branch | |
python -m pip install ./clvm | |
python -m pip install clvm_rs | |
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 are installed | |
run: | | |
. ./venv/bin/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__)' | |
python -c 'import clvm_tools_rs; print(clvm_tools_rs.__file__)' | |
- name: Install pytest | |
run: | | |
. ./venv/bin/activate | |
pip install pytest pytest-asyncio | |
# Cost tests are currently failing. | |
# - name: Run tests from clvm | |
# run: | | |
# . ./venv/bin/activate | |
# cd clvm | |
# python -m py.test tests | |
- name: Run tests from clvm_tools | |
run: | | |
. ./venv/bin/activate | |
cd clvm_tools | |
pytest | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: ./target/wheels | |
upload: | |
name: Upload to PyPI | |
runs-on: ubuntu-latest | |
needs: build_wheels | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set Env | |
uses: Chia-Network/actions/setjobenv@main | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install python | |
uses: Chia-Network/actions/setup-python@main | |
with: | |
python-version: "3.10" | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
path: ./target/wheels/ | |
- name: publish (PyPi) | |
if: env.RELEASE == 'true' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: target/wheels/ | |
skip-existing: true | |
- name: publish (Test PyPi) | |
if: env.PRE_RELEASE == 'true' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
packages-dir: target/wheels/ | |
skip-existing: true | |
- name: Test for secrets access | |
id: check_secrets | |
shell: bash | |
run: | | |
unset HAS_AWS_SECRET | |
if [ -n "$AWS_SECRET" ]; then HAS_AWS_SECRET='true' ; fi | |
echo HAS_AWS_SECRET=${HAS_AWS_SECRET} >>$GITHUB_OUTPUT | |
env: | |
AWS_SECRET: "${{ secrets.CHIA_AWS_ACCOUNT_ID }}" | |
- name: Configure AWS credentials | |
if: steps.check_secrets.outputs.HAS_AWS_SECRET | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.CHIA_AWS_ACCOUNT_ID }}:role/installer-upload | |
aws-region: us-west-2 | |
- name: Publish Dev | |
if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/dev' | |
shell: bash | |
working-directory: ./target/wheels | |
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" |