forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (172 loc) · 7 KB
/
test_weaver-asset-exchange-fabric.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# 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:
# Allows you to run this workflow manually from the Actions tab
workflow_call:
inputs:
run_all:
required: true
type: string
concurrency:
group: asset-exchange-fabric-${{ 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: ${{ inputs.run_all == 'true' || 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/[email protected]
# 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