Skip to content

Commit

Permalink
fix(go-sdk): use protos v1 api for fabric-protos-go unmarshal
Browse files Browse the repository at this point in the history
    ci(release-go-sdk): use make build to test build of go-sdk
    chore: fix update-weaver-version script typo with quotes
    chore: bug fix in release script go-gen-checksum
    test(go-sdk): change test package names to _test, add membership test

Signed-off-by: Sandeep Nishad <[email protected]>
  • Loading branch information
sandeepnRES committed Jun 28, 2024
1 parent 199c1f0 commit 8896518
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 149 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/test_weaver-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,33 @@ jobs:
- name: Test
run: go test -v ./...
working-directory: weaver/samples/fabric/simpleassettransfer

unit_test_sdk_membership:
needs: check_code_changed
if: ${{ needs.check_code_changed.outputs.interopcc_changed == 'true' || needs.check_code_changed.outputs.gosdk_changed == 'true' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]

- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.20.2'

# FABRIC NETWORK
- name: Start Fabric Network
run: make start-interop-local
working-directory: weaver/tests/network-setups/fabric/dev

- name: Vendor
run: make run-vendor
working-directory: weaver/sdks/fabric/go-sdk

- name: Build
run: make build
working-directory: weaver/sdks/fabric/go-sdk

# Test the MembershipManager
- name: Test
run: GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn CACTI_ROOT=$GITHUB_WORKSPACE go test -v .
working-directory: weaver/sdks/fabric/go-sdk/membershipmanager
2 changes: 1 addition & 1 deletion .github/workflows/weaver_deploy_go-pkgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ jobs:
working-directory: weaver/sdks/fabric/go-sdk

- name: Build test
run: go build -v ./...
run: make build
working-directory: weaver/sdks/fabric/go-sdk

- name: Check if release already exists
Expand Down
20 changes: 12 additions & 8 deletions tools/go-gen-checksum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ ROOT_DIR=${2:-'..'}
REPO='github.com/hyperledger/cacti'

# install go-checksum
echo "Installing go-checksum..."
go install github.com/vikyd/go-checksum@latest
echo "Installed."

GOMODULE_PATHS=("weaver/core/network/fabric-interop-cc/libs/utils"
"weaver/core/network/fabric-interop-cc/libs/assetexchange"
Expand Down Expand Up @@ -63,6 +65,8 @@ for GOMODULE in ${GOMODULE_PATHS[@]}; do
echo "------------ END --------------"
continue
fi

(cat VERSION | grep "$VERSION") || echo $VERSION > VERSION
GOMOD_VERSION=v$(cat VERSION)
GOMOD_SUM=$(go-checksum . $GOMOD_NAME@$GOMOD_VERSION | grep "GoCheckSum" | cut -d ' ' -f 2 | cut -d '"' -f 2)
GOMOD_DOTMOD_SUM=$(go-checksum go.mod | grep "GoCheckSum" | cut -d ' ' -f 2 | cut -d '"' -f 2)
Expand All @@ -74,17 +78,17 @@ for GOMODULE in ${GOMODULE_PATHS[@]}; do
rm $ROOT_DIR/$GOMOD_PATH/LICENSE

pushd $ROOT_DIR/$GOMODULE > /dev/null
UPDATE=false
(cat go.mod | grep -q "$GOMOD_NAME $GOMOD_VERSION") || UPDATE=True
if $UPDATE; then
UPDATE="false"
(cat go.mod | grep -q "$GOMOD_NAME $GOMOD_VERSION") || UPDATE="true"
if [ "$UPDATE" = "true" ]; then
go mod edit -require $GOMOD_NAME@$GOMOD_VERSION
else
echo "ERROR: Version $GOMOD_VERSION already there in go.mod, skipping $GOMOD_PATH in $GOMODULE"
fi
UPDATE=false
(cat go.sum | grep -q "$GOMOD_SUM_ENTRY") || UPDATE=True
(cat go.sum | grep -q "$GOMOD_DOTMOD_SUM_ENTRY") || UPDATE=True
if $UPDATE; then
UPDATE="false"
(cat go.sum | grep -q "$GOMOD_SUM_ENTRY") || UPDATE="true"
(cat go.sum | grep -q "$GOMOD_DOTMOD_SUM_ENTRY") || UPDATE="true"
if [ "$UPDATE" = "true" ]; then
# mv go.sum go.sum.old
# grep -v "$GOMOD_NAME $GOMOD_VERSION" go.sum.old > go.sum
echo $GOMOD_SUM_ENTRY >> go.sum
Expand All @@ -96,4 +100,4 @@ for GOMODULE in ${GOMODULE_PATHS[@]}; do
echo "------------ END --------------"
done
echo "############# END $GOMODULE ################\n"
done
done
4 changes: 2 additions & 2 deletions tools/weaver-update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ echo "VERSION: $VERSION"
## Node - Lerna handles it

## GO and Docker
VERSION_FILES=("weaver/common/protos-go
weaver/core/network/fabric-interop-cc/libs/utils"
VERSION_FILES=("weaver/common/protos-go"
"weaver/core/network/fabric-interop-cc/libs/utils"
"weaver/core/network/fabric-interop-cc/libs/assetexchange"
"weaver/core/network/fabric-interop-cc/interfaces/asset-mgmt"
"weaver/core/network/fabric-interop-cc/contracts/interop"
Expand Down
4 changes: 1 addition & 3 deletions weaver/sdks/fabric/go-sdk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ undo-vendor:
build-local: run-vendor build undo-vendor

build:
cd helpers && go build -v .
cd asset-manager && go build -v .
cd interoperablehelper && go build -v .
go build -v ./...

test-local: run-vendor test undo-vendor

Expand Down
Loading

0 comments on commit 8896518

Please sign in to comment.