Skip to content

Flag catch rebase

Flag catch rebase #8

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: CC-BY-4.0
# This is a basic workflow to help you get started with Actions
name: Test Asset Exchange Fabric
env:
NODEJS_VERSION: v18.18.2
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check_code_changed:
outputs:
status: ${{ steps.changes.outputs.weaver_code_changed }}
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**'
- '.github/workflows/test_weaver-asset-exchange-fabric.yaml'
asset-exchange-fabric:
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.20.2'
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODEJS_VERSION }}
# FABRIC NETWORK
- name: Start Fabric Network
run: make start-interop CHAINCODE_NAME=simpleasset PROFILE="2-nodes"
working-directory: weaver/tests/network-setups/fabric/dev
# FABRIC CLI
- name: Setup Fabric CLI .npmrc
run: |
cp .npmrc.template .npmrc
sed -i "s/<personal-access-token>/${{ secrets.GITHUB_TOKEN }}/g" .npmrc
cat .npmrc
working-directory: weaver/samples/fabric/fabric-cli
- name: Build Fabric CLI
run: npm install
working-directory: weaver/samples/fabric/fabric-cli
- name: Setup Fabric CLI Config
run: |
echo ${GITHUB_WORKSPACE}
cp config.template.json config.json
sed -i "s#<PATH-TO-WEAVER>#${GITHUB_WORKSPACE}/weaver#g" config.json
working-directory: weaver/samples/fabric/fabric-cli
- name: Setup Fabric CLI ENV
run: |
echo ${GITHUB_WORKSPACE}
cp .env.template .env
./bin/fabric-cli env set MEMBER_CREDENTIAL_FOLDER ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/src/data/credentials_docker
./bin/fabric-cli env set CONFIG_PATH ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/config.json
cat .env
working-directory: weaver/samples/fabric/fabric-cli
- name: Fabric CLI Init
run: ./scripts/initAsset.sh
working-directory: weaver/samples/fabric/fabric-cli
- name: Asset Exchange Fabric CLI Tests
run: |
COUNT=0
TOTAL=1
# FABRIC2 - FABRIC1
./bin/fabric-cli asset exchange-all --network1=network1 --network2=network2 --secret=secrettext --timeout-duration=100 bob:bond01:a04:alice:token1:100 &> tmp.out
tail -n 2 tmp.out | grep "Asset Exchange Complete." && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# RESULT
echo "Passed $COUNT/$TOTAL Tests."
if [ $COUNT == $TOTAL ]; then
exit 0
else
exit 1
fi
working-directory: weaver/samples/fabric/fabric-cli
asset-exchange-fabric-local:
needs: check_code_changed
if: needs.check_code_changed.outputs.status == 'true'
# if: ${{ false }}
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.20.2'
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODEJS_VERSION }}
- name: Use Protoc 3.15
run: |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip
unzip protoc-3.15.6-linux-x86_64.zip -d protoc
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# PROTOS
- name: Build JS Protos
run: |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin"
make build
working-directory: weaver/common/protos-js
# Build Dependencies
- name: Build Fabric Interop SDK
run: make build-local
working-directory: weaver/sdks/fabric/interoperation-node-sdk
- name: Build Fabric CLI
run: make build-local
working-directory: weaver/samples/fabric/fabric-cli
# FABRIC NETWORK
- name: Start Fabric Network
run: make start-interop-local CHAINCODE_NAME=simpleasset
working-directory: weaver/tests/network-setups/fabric/dev
# FABRIC CLI
- name: Setup Fabric CLI Config
run: |
echo ${GITHUB_WORKSPACE}
cp config.template.json config.json
sed -i "s#<PATH-TO-WEAVER>#${GITHUB_WORKSPACE}/weaver#g" config.json
working-directory: weaver/samples/fabric/fabric-cli
- name: Setup Fabric CLI ENV
run: |
echo ${GITHUB_WORKSPACE}
cp .env.template .env
./bin/fabric-cli env set MEMBER_CREDENTIAL_FOLDER ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/src/data/credentials_docker
./bin/fabric-cli env set CONFIG_PATH ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/config.json
cat .env
working-directory: weaver/samples/fabric/fabric-cli
- name: Fabric CLI Init
run: ./scripts/initAsset.sh
working-directory: weaver/samples/fabric/fabric-cli
- name: Asset Exchange Fabric CLI Tests
run: |
COUNT=0
TOTAL=1
# FABRIC2 - FABRIC1
./bin/fabric-cli asset exchange-all --network1=network1 --network2=network2 --secret=secrettext --timeout-duration=100 bob:bond01:a04:alice:token1:100 &> tmp.out
tail -n 2 tmp.out | grep "Asset Exchange Complete." && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# RESULT
echo "Passed $COUNT/$TOTAL Tests."
if [ $COUNT == $TOTAL ]; then
exit 0
else
exit 1
fi
working-directory: weaver/samples/fabric/fabric-cli