diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5466c66..8d40db0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,5 +28,7 @@ jobs: go-version: ${{ env.GO_VER }} - name: Checkout Fabric-Lib-Go Code uses: actions/checkout@v3 + - name: Install SoftHSM + run: scripts/setup_hsm.sh - name: Run Checks and Unit Tests run: make checks unit-tests GOTOOLS_BINDIR=${{ env.GOPATH }}/bin diff --git a/scripts/run-unit-tests.sh b/scripts/run-unit-tests.sh index 91818e1..213333a 100755 --- a/scripts/run-unit-tests.sh +++ b/scripts/run-unit-tests.sh @@ -6,4 +6,8 @@ # SPDX-License-Identifier: Apache-2.0 # -time go test -race -cover ./... \ No newline at end of file +time { + go test -race -cover ./... + go test -race -cover -tags "pkcs11" github.com/hyperledger/fabric-lib-go/bccsp/factory + go test -race -cover -tags "pkcs11" github.com/hyperledger/fabric-lib-go/bccsp/pkcs11 +} \ No newline at end of file diff --git a/scripts/setup_hsm.sh b/scripts/setup_hsm.sh new file mode 100755 index 0000000..3fcf5b9 --- /dev/null +++ b/scripts/setup_hsm.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright the Hyperledger Fabric contributors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 +set -euo pipefail + +sudo apt-get install -y softhsm2 +sudo mkdir -p /var/lib/softhsm/tokens +sudo softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432 +sudo chmod -R 777 /var/lib/softhsm +mkdir -p ~/.config/softhsm2 +cp /usr/share/softhsm/softhsm2.conf ~/.config/softhsm2 \ No newline at end of file