-
Notifications
You must be signed in to change notification settings - Fork 13
182 lines (154 loc) · 5.06 KB
/
build-m1-wheel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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, 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.1.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"