Skip to content

Commit

Permalink
Add CI including wheels and pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Dec 8, 2023
1 parent 8c8f9ef commit 44c8df9
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 6 deletions.
140 changes: 140 additions & 0 deletions .github/workflows/sdk-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# This file is autogenerated by maturin v1.3.1
# To update, run
#
# maturin generate-ci --platform linux --platform macos --platform windows --manifest-path ./sdk/Cargo.toml --output .github/workflows/sdk-wheels.yml github
#
name: SDK Wheels

on:
push:
paths:
- 'sdk/**'
branches:
- main
- master
tags:
- '*'
pull_request:
paths:
- 'sdk/**'
workflow_dispatch:

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/sdk.yml
linux:
needs: [tests]
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./sdk/Cargo.toml --features openssl/vendored
manylinux: auto
before-script-linux: |
# If we're running on rhel centos, install needed packages.
if command -v yum &> /dev/null; then
yum update -y && yum install -y perl-core libatomic
# If we're running on i686 we need to symlink libatomic
# in order to build openssl with -latomic flag.
if [[ ! -d "/usr/lib64" ]]; then
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
fi
fi
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

windows:
needs: [tests]
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./sdk/Cargo.toml --features openssl/vendored
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

macos:
needs: [tests]
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path ./sdk/Cargo.toml --features openssl/vendored
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

sdist:
needs: [tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path ./sdk/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
48 changes: 48 additions & 0 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: SDK

on:
workflow_call:

jobs:
sdk_check:
name: Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: fmt
run: cargo fmt --check
- name: clippy
run: cargo clippy -- -D warnings
- uses: jordemort/action-pyright@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workdir: ./sdk
fail_on_error: true
sdk_test:
name: Build & Test
needs: [sdk_check]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build
uses: PyO3/maturin-action@v1
with:
args: --release --features openssl/vendored
working-directory: ./sdk
- name: Test
run: |
python -m venv .env
source .env/bin/activate
maturin develop --release --features openssl/vendored
python test.py
1 change: 1 addition & 0 deletions sdk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ description = "A Python sdk for zero-knowledge cryptography based on Aleo"
edition = "2021"
license = "GPL-3.0-or-later"

[lib]
crate-type = ["cdylib"]

[dependencies]
anyhow = "1"
openssl = "0.10"
pyo3 = { version = "0.20.0", features = ["extension-module", "abi3-py37", "anyhow"] }
rand = { version = "^0.8" }
pyo3 = { version = "0.20.0", features = ["extension-module", "anyhow"] }
serde = "1"
serde_json = "1"

Expand Down
6 changes: 5 additions & 1 deletion sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ version = "0.2.0"
description = "A Python SDK for zero-knowledge cryptography based on Aleo"
repository = "https://github.com/AleoHQ/python-sdk/tree/master/sdk"
license = "GPL-3.0-or-later"
authors = ["Konstantin Pandl", "Mike Turner", "Roman Proskuryakov"]
authors = ["Konstantin Pandl", "Mike Turner", "Roman Proskuryakov"]

[tool.pyright]
reportMissingModuleSource = false # don't report missing aleo.so for CI purposes
strict = ['./']
7 changes: 3 additions & 4 deletions sdk/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ def test_coinbase(self):
self.assertEqual(str(challenge), challenge_json)
self.assertEqual(str(solution), solution_json)

# Skip it because it takes too much time to load the puzzle
# puzzle = aleo.CoinbasePuzzle.load()
# verifying_key = puzzle.verifying_key()
# assert solution.verify(verifying_key, challenge, 100)
puzzle = aleo.CoinbasePuzzle.load()
verifying_key = puzzle.verifying_key()
assert solution.verify(verifying_key, challenge, 100)

def test_transfer(self):
private_key = aleo.PrivateKey.from_string(
Expand Down

0 comments on commit 44c8df9

Please sign in to comment.