Build once, test many #299
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 ARM64 wheels on ubuntu-latest | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
release: | |
types: [published] | |
pull_request: | |
branches: | |
- "**" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build_wheels: | |
name: Build ARM64 Python Wheels | |
runs-on: [ARM64, Linux] | |
container: | |
image: ghcr.io/chia-network/build-images/centos-pypa-rust-aarch64:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Set up | |
run: | | |
echo "${PATH}" | |
source /root/.cargo/env | |
rustup default stable | |
rustup target add aarch64-unknown-linux-musl | |
rm -rf venv | |
- name: Build Python wheels | |
run: | | |
/opt/python/cp38-cp38/bin/python -m venv venv | |
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi | |
. ./activate | |
pip install --upgrade pip | |
pip install maturin==1.1.0 | |
CC=gcc maturin build --release --strip --manylinux 2014 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/wheels/ | |
- name: Clean up ARM64 | |
run: | | |
rm -rf venv | |
rm -rf dist | |
cargo_test: | |
name: Run cargo test on ARM64 Linux | |
runs-on: [ARM64, Linux] | |
container: | |
image: ghcr.io/chia-network/build-images/centos-pypa-rust-aarch64:latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: cargo test | |
run: cargo test | |
publish_wheels: | |
name: Publish ARM64 Python Wheels | |
runs-on: ubuntu-latest | |
needs: build_wheels | |
steps: | |
- name: Fetch wheels from previous job | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
path: target/wheels/ | |
- name: Install job deps | |
run: | | |
if [ ! -f "venv" ]; then rm -rf venv; fi | |
sudo apt install python3 python3-pip -y | |
python3 -m venv venv | |
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi | |
. ./activate | |
pip3 install setuptools_rust | |
- 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: Set Env | |
uses: Chia-Network/actions/setjobenv@main | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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: 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' | |
run: | | |
FILES=$(find ${{ github.workspace }}/target/wheels -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" |