diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1d5c4d..626ae89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,6 @@ name: "Build Packages" -on: workflow_dispatch - -defaults: - run: - shell: bash +"on": push jobs: build-manylinux: @@ -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 @@ -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 @@ -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 @@ -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/* diff --git a/.gitignore b/.gitignore index a9d37c5..8094f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.vscode target Cargo.lock diff --git a/wrappers/python/demo/test.py b/wrappers/python/demo/test.py index 9ff2ff8..b0d4aae 100644 --- a/wrappers/python/demo/test.py +++ b/wrappers/python/demo/test.py @@ -20,12 +20,20 @@ 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, @@ -33,20 +41,20 @@ 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 @@ -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()) @@ -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( @@ -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")