Skip to content

Commit

Permalink
test build script, python package
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Feb 18, 2021
1 parent e4f013d commit d54c94d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 47 deletions.
53 changes: 35 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: "Build Packages"

on: workflow_dispatch

defaults:
run:
shell: bash
"on": push

jobs:
build-manylinux:
Expand Down Expand Up @@ -37,7 +33,7 @@ jobs:
env:
BUILD_FEATURES: vendored
BUILD_TARGET: ${{ matrix.target }}
run: ./build.sh
run: sh ./build.sh

- name: Upload library artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -74,12 +70,24 @@ jobs:
- name: Cache cargo resources
uses: Swatinem/rust-cache@v1

# pre-build so that openssl dependency is cached, otherwise it will complain:
# "This perl implementation doesn't produce Windows like paths"
- if: "runner.os == 'Windows'"
name: Pre-build (Windows)
uses: actions-rs/cargo@v1
env:
OPENSSL_STATIC: 1
with:
command: build
args: --release --manifest-path indy-credx/Cargo.toml --features vendored

- name: Build library
env:
BUILD_FEATURES: vendored
BUILD_TARGET: ${{ matrix.target }}
BUILD_TOOLCHAIN: ${{ matrix.toolchain }}
run: ./build.sh
OPENSSL_STATIC: 1
run: sh ./build.sh

- name: Upload library artifacts
uses: actions/upload-artifact@v2
Expand All @@ -93,17 +101,17 @@ jobs:

strategy:
matrix:
plat: [Linux, macOS, Windows]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6]
include:
- plat: Linux
- os: ubuntu-latest
plat-name: manylinux2014_x86_64
- plat: macOS
- os: macos-latest
plat-name: macosx_10_9_x86_64 # macosx_10_9_universal2
- plat: Windows
plat-name: win32
- os: windows-latest
plat-name: win_amd64

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
Expand All @@ -122,19 +130,28 @@ jobs:
- name: Fetch library artifacts
uses: actions/download-artifact@v2
with:
name: library-${{ matrix.plat }}
name: library-${{ runner.os }}
path: wrappers/python/indy_credx/

- name: Build python packages
- name: Build python package
run: |
python setup.py bdist_wheel --python-tag=py3 --plat-name=${{ matrix.plat-name }}
working-directory: wrappers/python

- if: "matrix.plat == 'Linux'"
- name: Test python package
shell: sh
run: |
cd wrappers/python
pip install --upgrade pip
pip install dist/*
python -m demo.test
- if: "runner.os == 'Linux'"
name: Auditwheel
run: auditwheel show wrappers/python/dist/*

- name: Upload python artifacts
- name: Upload python package
uses: actions/upload-artifact@v2
with:
name: python-${{ matrix.plat }}
name: python-${{ runner.os }}
path: wrappers/python/dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
target
Cargo.lock
64 changes: 35 additions & 29 deletions wrappers/python/demo/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,41 @@
test_did = "55GkHamhTU1ZbTbV2ab9DE"

schema = Schema.create(test_did, "schema name", "schema version", ["attr"], seq_no=15)
print(schema.to_dict())
assert schema.to_dict() == {
"ver": "1.0",
"id": f"{test_did}:2:schema name:schema version",
"name": "schema name",
"version": "schema version",
"attrNames": ["attr"],
"seqNo": 15,
}


cred_def, cred_def_pvt, key_proof = CredentialDefinition.create(
test_did, schema, "CL", tag="tag", support_revocation=True
)
print(cred_def)
assert cred_def.id == f"{test_did}:3:CL:15:tag"

(
rev_reg_def,
rev_reg_def_private,
rev_reg,
rev_reg_init_delta,
) = RevocationRegistryDefinition.create(test_did, cred_def, "default", "CL_ACCUM", 100)
print("Tails file hash:", rev_reg_def.tails_hash)
# print("Tails file hash:", rev_reg_def.tails_hash)

master_secret = MasterSecret.create()
master_secret_id = "my id"

cred_offer = CredentialOffer.create(schema.id, cred_def, key_proof)
print("Credential offer:")
print(cred_offer.to_json())
# print("Credential offer:")
# print(cred_offer.to_json())

cred_req, cred_req_metadata = CredentialRequest.create(
test_did, cred_def, master_secret, master_secret_id, cred_offer
)
print("Credential request:")
print(cred_req.to_json())
# print("Credential request:")
# print(cred_req.to_json())

issuer_rev_index = 1

Expand All @@ -66,12 +74,12 @@
rev_reg_def.tails_location,
),
)
print("Issued credential:")
print(cred.to_json())
# print("Issued credential:")
# print(cred.to_json())

cred_received = cred.process(cred_req_metadata, master_secret, cred_def, rev_reg_def)
print("Processed credential:")
print(cred_received.to_json())
# print("Processed credential:")
# print(cred_received.to_json())

timestamp = int(time())

Expand Down Expand Up @@ -111,16 +119,14 @@
)
# print(presentation.to_json())

print(
"Verified:",
presentation.verify(
pres_req,
[schema],
[cred_def],
[rev_reg_def],
{rev_reg_def.id: {timestamp: rev_reg}},
),
verified = presentation.verify(
pres_req,
[schema],
[cred_def],
[rev_reg_def],
{rev_reg_def.id: {timestamp: rev_reg}},
)
assert verified


# rev_delta_2 = rev_reg.revoke_credential(
Expand All @@ -142,13 +148,13 @@
pres_req, present_creds, {}, master_secret, [schema], [cred_def]
)

print(
"Verified:",
presentation.verify(
pres_req,
[schema],
[cred_def],
[rev_reg_def],
{rev_reg_def.id: {timestamp: rev_reg}},
),
verified = presentation.verify(
pres_req,
[schema],
[cred_def],
[rev_reg_def],
{rev_reg_def.id: {timestamp: rev_reg}},
)
assert not verified

print("ok")

0 comments on commit d54c94d

Please sign in to comment.