From c572c51d3a66d03756267081340291e8678d4850 Mon Sep 17 00:00:00 2001 From: Brett Logan Date: Mon, 6 Apr 2020 16:20:43 -0400 Subject: [PATCH] Organize and Standardize `ci` Directory Content (#152) This change organizes the `ci` directory into common-sense subfolders and standardizes pipelines naming schemes. Also removes the dead Jenkins code in the `./scripts` directory Signed-off-by: Brett Logan --- ci/azure-pipelines.yml | 93 +++++++------------ ci/getDockerImages.sh | 41 -------- ci/install-deps.yml | 11 --- ci/install-fabric.yml | 15 --- ci/scripts/pullFabricImages.sh | 15 +++ .../commercial-paper/azure-pipelines-go.yml} | 40 +++----- .../azure-pipelines-java.yml} | 29 ++---- .../azure-pipelines-javascript.yml} | 24 ++--- .../fabcar/azure-pipelines-go.yml} | 2 +- .../fabcar/azure-pipelines-java.yml} | 6 +- .../fabcar/azure-pipelines-javascript.yml} | 6 +- .../fabcar/azure-pipelines-typescript.yml} | 6 +- ci/templates/install-deps.yml | 17 ++++ ci/templates/test-network/azure-pipelines.yml | 11 +++ ci/testnetwork.yml | 15 --- scripts/ci_scripts/byfn_eyfn.sh | 75 --------------- scripts/ci_scripts/ciScript.sh | 54 ----------- scripts/ci_scripts/fabcar.sh | 74 --------------- test-network/network.sh | 2 +- 19 files changed, 119 insertions(+), 417 deletions(-) delete mode 100755 ci/getDockerImages.sh delete mode 100644 ci/install-deps.yml delete mode 100644 ci/install-fabric.yml create mode 100755 ci/scripts/pullFabricImages.sh rename ci/{commercialpaper-go.yml => templates/commercial-paper/azure-pipelines-go.yml} (84%) rename ci/{commercialpaper-java.yml => templates/commercial-paper/azure-pipelines-java.yml} (85%) rename ci/{commercialpaper-javascript.yml => templates/commercial-paper/azure-pipelines-javascript.yml} (85%) rename ci/{fabcar-go.yml => templates/fabcar/azure-pipelines-go.yml} (75%) rename ci/{fabcar-java.yml => templates/fabcar/azure-pipelines-java.yml} (64%) rename ci/{fabcar-javascript.yml => templates/fabcar/azure-pipelines-javascript.yml} (71%) rename ci/{fabcar-typescript.yml => templates/fabcar/azure-pipelines-typescript.yml} (76%) create mode 100644 ci/templates/install-deps.yml create mode 100644 ci/templates/test-network/azure-pipelines.yml delete mode 100644 ci/testnetwork.yml delete mode 100755 scripts/ci_scripts/byfn_eyfn.sh delete mode 100755 scripts/ci_scripts/ciScript.sh delete mode 100755 scripts/ci_scripts/fabcar.sh diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 6f2db0262a..7b80977181 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -7,94 +7,71 @@ trigger: - release-1.4 variables: - NODE_VER: '12.x' - PATH: $(Agent.BuildDirectory)/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin + FABRIC_VERSION: 2.0 + NODE_VER: 12.x + PATH: $(Build.Repository.LocalPath)/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin jobs: - - job: fabcar_go - displayName: FabCar (Go) + - job: CommercialPaper_Go + displayName: Commercial Paper (Go) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: fabcar-go.yml + - template: templates/install-deps.yml + - template: templates/commercial-paper/azure-pipelines-go.yml - - job: test_network - displayName: Start the test network + - job: CommercialPaper_Java + displayName: Commercial Paper (Java) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: testnetwork.yml + - template: templates/install-deps.yml + - template: templates/commercial-paper/azure-pipelines-java.yml - - job: fabcar_java - displayName: FabCar (Java) + - job: CommercialPaper_JavaScript + displayName: Commercial Paper (JavaScript) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: fabcar-java.yml + - template: templates/install-deps.yml + - template: templates/commercial-paper/azure-pipelines-javascript.yml - - job: fabcar_javascript - displayName: FabCar (JavaScript) + - job: FabCar_Go + displayName: FabCar (Go) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: fabcar-javascript.yml + - template: templates/install-deps.yml + - template: templates/fabcar/azure-pipelines-go.yml - - job: fabcar_typescript - displayName: FabCar (TypeScript) + - job: FabCar_Java + displayName: FabCar (Java) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: fabcar-typescript.yml + - template: templates/install-deps.yml + - template: templates/fabcar/azure-pipelines-java.yml - - job: commercialpaper_javascript - displayName: CommercialPaper (JavaScript) + - job: FabCar_JavaScript + displayName: FabCar (JavaScript) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: commercialpaper-javascript.yml + - template: templates/install-deps.yml + - template: templates/fabcar/azure-pipelines-javascript.yml - - job: commercialpaper_java - displayName: CommercialPaper (Java) + - job: Fabcar_TypeScript + displayName: FabCar (TypeScript) pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: commercialpaper-java.yml + - template: templates/install-deps.yml + - template: templates/fabcar/azure-pipelines-typescript.yml - - job: commercialpaper_go - displayName: CommercialPaper (Go) + - job: TestNetwork + displayName: Test Network pool: vmImage: ubuntu-18.04 - dependsOn: [] - timeoutInMinutes: 60 steps: - - template: install-deps.yml - - template: install-fabric.yml - - template: commercialpaper-go.yml + - template: templates/install-deps.yml + - template: templates/test-network/azure-pipelines.yml diff --git a/ci/getDockerImages.sh b/ci/getDockerImages.sh deleted file mode 100755 index f2c22ea1a9..0000000000 --- a/ci/getDockerImages.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -e -set -o pipefail - -echo "======== PULL DOCKER IMAGES ========" -########################################################## -REPO_URL=hyperledger-fabric.jfrog.io -ORG_NAME="fabric" - -VERSION=2.1 -ARCH="amd64" -: ${STABLE_VERSION:=$VERSION-stable} -STABLE_TAG=$ARCH-$STABLE_VERSION -MASTER_TAG=$ARCH-stable - -echo "---------> STABLE_VERSION:" $STABLE_VERSION - -dockerTag() { - for IMAGES in baseos peer orderer ca tools orderer ccenv javaenv nodeenv; do - echo "Images: $IMAGES" - echo - docker pull $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG - if [ $? != 0 ]; then - echo "FAILED: Docker Pull Failed on $IMAGES" - exit 1 - fi - docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES - docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:latest - docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$ARCH-$VERSION-stable - docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$ARCH-stable - docker tag $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG hyperledger/$ORG_NAME-$IMAGES:$VERSION - - echo "Deleting docker images: $IMAGES" - docker rmi -f $REPO_URL/$ORG_NAME-$IMAGES:$STABLE_TAG - done -} - -dockerTag - -echo -docker images -echo \ No newline at end of file diff --git a/ci/install-deps.yml b/ci/install-deps.yml deleted file mode 100644 index 45e5fa5528..0000000000 --- a/ci/install-deps.yml +++ /dev/null @@ -1,11 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - script: sudo sh -c "curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o /usr/local/bin/retry && chmod +x /usr/local/bin/retry" - displayName: Install retry CLI - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: 'Install Node.js' diff --git a/ci/install-fabric.yml b/ci/install-fabric.yml deleted file mode 100644 index dc31c375b6..0000000000 --- a/ci/install-fabric.yml +++ /dev/null @@ -1,15 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - script: | - set -eo pipefail - curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-linux-amd64-latest.tar.gz | tar xz - displayName: Download Fabric CLI - - script: | - set -eo pipefail - curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-ca-linux-amd64-latest.tar.gz | tar xz - displayName: Download Fabric CA CLI - - script: bash ci/getDockerImages.sh - displayName: Pull Fabric Docker images diff --git a/ci/scripts/pullFabricImages.sh b/ci/scripts/pullFabricImages.sh new file mode 100755 index 0000000000..eb15f87db1 --- /dev/null +++ b/ci/scripts/pullFabricImages.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e +set -euo pipefail + +# FABRIC_VERSION is set in ci/azure-pipelines.yml +STABLE_TAG=amd64-${FABRIC_VERSION}-stable + +for image in baseos peer orderer ca tools orderer ccenv javaenv nodeenv; do + docker pull -q hyperledger-fabric.jfrog.io/fabric-${image}:${STABLE_TAG} + docker tag hyperledger-fabric.jfrog.io/fabric-${image}:${STABLE_TAG} hyperledger/fabric-${image} + docker tag hyperledger-fabric.jfrog.io/fabric-${image}:${STABLE_TAG} hyperledger/fabric-${image}:${FABRIC_VERSION} + docker rmi -f hyperledger-fabric.jfrog.io/fabric-${image}:${STABLE_TAG} +done + +docker pull -q hyperledger/fabric-couchdb +docker images | grep hyperledger diff --git a/ci/commercialpaper-go.yml b/ci/templates/commercial-paper/azure-pipelines-go.yml similarity index 84% rename from ci/commercialpaper-go.yml rename to ci/templates/commercial-paper/azure-pipelines-go.yml index 0396051ddc..9008cf4676 100644 --- a/ci/commercialpaper-go.yml +++ b/ci/templates/commercial-paper/azure-pipelines-go.yml @@ -5,32 +5,26 @@ steps: - script: go test ./... workingDirectory: commercial-paper/organization/magnetocorp/contract-go - displayName: Go unit test magnetocorp + displayName: Unit Test MagnetoCorp Chaincode - script: go test ./... workingDirectory: commercial-paper/organization/digibank/contract-go - displayName: Go unit test digibank + displayName: Unit Test DigiBank Chaincode - - script: | - go mod vendor + - script: go mod vendor workingDirectory: commercial-paper/organization/magnetocorp/contract-go - - script: | - go mod vendor - workingDirectory: commercial-paper/organization/digibank/contract-go + displayName: Vendor MagnetoCorp Dependencies + - script: go mod vendor + workingDirectory: commercial-paper/organization/digibank/contract-go + displayName: Vendor DigiBank Dependencies - script: | - echo $PATH - ls -l /usr/local/bin/peer - sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C .. - ./network.sh down - ./network.sh up createChannel -s couchdb -i 2.0.0 + ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" workingDirectory: test-network displayName: Start Fabric - env: - FABRIC_CFG_PATH: /usr/local/config - script: | source <(./magnetocorp.sh) peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0 @@ -50,9 +44,7 @@ steps: peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config + displayName: Setup Commercial Paper Contract - script: | source <(./digibank.sh) peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0 @@ -81,29 +73,25 @@ steps: --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config - - + displayName: Setup Commercial Paper Contract - script: retry -- npm install workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Install Magnetocorp application + displayName: Install Magnetocorp Application - script: | set -ex node addToWallet.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Magnetocorp issue paper + displayName: MagnetoCorp Issue Paper - script: retry -- npm install workingDirectory: commercial-paper/organization/digibank/application - displayName: Install Digibank application + displayName: Install DigiBank Application - script: | set -ex node addToWallet.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application - displayName: Digibank issue paper \ No newline at end of file + displayName: Digibank Issue Paper diff --git a/ci/commercialpaper-java.yml b/ci/templates/commercial-paper/azure-pipelines-java.yml similarity index 85% rename from ci/commercialpaper-java.yml rename to ci/templates/commercial-paper/azure-pipelines-java.yml index 8143aeae67..28d8e1d192 100644 --- a/ci/commercialpaper-java.yml +++ b/ci/templates/commercial-paper/azure-pipelines-java.yml @@ -6,26 +6,20 @@ steps: - script: | ./gradlew build workingDirectory: commercial-paper/organization/digibank/contract-java - displayName: Build Java Contract + displayName: Build DigiBank Java Contract - script: | ./gradlew build workingDirectory: commercial-paper/organization/magnetocorp/contract-java - displayName: Build Java Contract + displayName: Build MagnetoCorp Java Contract - script: | - echo $PATH - ls -l /usr/local/bin/peer - sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C .. - ./network.sh down - ./network.sh up createChannel -s couchdb -i 2.0.0 + ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" workingDirectory: test-network displayName: Start Fabric - env: - FABRIC_CFG_PATH: /usr/local/config - script: | source <(./magnetocorp.sh) peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0 @@ -45,9 +39,7 @@ steps: peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config + displayName: Setup Commercial Paper Contract - script: | source <(./digibank.sh) peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0 @@ -76,28 +68,25 @@ steps: --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config - + displayName: Setup Commercial Paper Contract - script: retry -- npm install workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Install Magnetocorp application + displayName: Install MagnetoCorp Application - script: | set -ex node addToWallet.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Magnetocorp issue paper + displayName: MagnetoCorp Issue Paper - script: retry -- npm install workingDirectory: commercial-paper/organization/digibank/application - displayName: Install Digibank application + displayName: Install DigiBank Application - script: | set -ex node addToWallet.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application - displayName: Digibank issue paper \ No newline at end of file + displayName: DigiBank Issue Paper diff --git a/ci/commercialpaper-javascript.yml b/ci/templates/commercial-paper/azure-pipelines-javascript.yml similarity index 85% rename from ci/commercialpaper-javascript.yml rename to ci/templates/commercial-paper/azure-pipelines-javascript.yml index 790beaef3d..b4f2df26df 100644 --- a/ci/commercialpaper-javascript.yml +++ b/ci/templates/commercial-paper/azure-pipelines-javascript.yml @@ -4,19 +4,13 @@ steps: - script: | - echo $PATH - ls -l /usr/local/bin/peer - sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C .. - ./network.sh down - ./network.sh up createChannel -s couchdb -i 2.0.0 + ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml # Copy the connection profiles so they are in the correct organizations. cp "./organizations/peerOrganizations/org1.example.com/connection-org1.yaml" "../commercial-paper/organization/digibank/gateway/" cp "./organizations/peerOrganizations/org2.example.com/connection-org2.yaml" "../commercial-paper/organization/magnetocorp/gateway/" workingDirectory: test-network displayName: Start Fabric - env: - FABRIC_CFG_PATH: /usr/local/config - script: | source <(./magnetocorp.sh) peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0 @@ -36,9 +30,7 @@ steps: peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 workingDirectory: commercial-paper/organization/magnetocorp - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config + displayName: Setup Commercial Paper Contract - script: | source <(./digibank.sh) peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0 @@ -67,26 +59,24 @@ steps: --tls --cafile $ORDERER_CA --waitForEvent workingDirectory: commercial-paper/organization/digibank - displayName: Setup Commercial Paper contract - env: - FABRIC_CFG_PATH: /usr/local/config + displayName: Setup Commercial Paper Contract - script: retry -- npm install workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Install Magnetocorp application + displayName: Install MagnetoCorp Application - script: | set -ex node addToWallet.js node issue.js workingDirectory: commercial-paper/organization/magnetocorp/application - displayName: Magnetocorp issue paper + displayName: MagnetoCorp Issue Paper - script: retry -- npm install workingDirectory: commercial-paper/organization/digibank/application - displayName: Install Digibank application + displayName: Install DigiBank Application - script: | set -ex node addToWallet.js node buy.js node redeem.js workingDirectory: commercial-paper/organization/digibank/application - displayName: Digibank issue paper \ No newline at end of file + displayName: DigiBank Issue Paper diff --git a/ci/fabcar-go.yml b/ci/templates/fabcar/azure-pipelines-go.yml similarity index 75% rename from ci/fabcar-go.yml rename to ci/templates/fabcar/azure-pipelines-go.yml index d8c472b9ed..8d53e69baf 100644 --- a/ci/fabcar-go.yml +++ b/ci/templates/fabcar/azure-pipelines-go.yml @@ -3,6 +3,6 @@ # steps: - - script: bash startFabric.sh go + - script: ./startFabric.sh go workingDirectory: fabcar displayName: Start Fabric diff --git a/ci/fabcar-java.yml b/ci/templates/fabcar/azure-pipelines-java.yml similarity index 64% rename from ci/fabcar-java.yml rename to ci/templates/fabcar/azure-pipelines-java.yml index 9597bd54d9..e166f74766 100644 --- a/ci/fabcar-java.yml +++ b/ci/templates/fabcar/azure-pipelines-java.yml @@ -3,12 +3,12 @@ # steps: - - script: bash startFabric.sh java + - script: ./startFabric.sh java workingDirectory: fabcar displayName: Start Fabric - script: retry -- mvn dependency:go-offline workingDirectory: fabcar/java - displayName: Install FabCar application dependencies + displayName: Install FabCar Application Dependencies - script: mvn test workingDirectory: fabcar/java - displayName: Run FabCar application + displayName: Run FabCar Application diff --git a/ci/fabcar-javascript.yml b/ci/templates/fabcar/azure-pipelines-javascript.yml similarity index 71% rename from ci/fabcar-javascript.yml rename to ci/templates/fabcar/azure-pipelines-javascript.yml index 200e0af929..dd4f474e8d 100644 --- a/ci/fabcar-javascript.yml +++ b/ci/templates/fabcar/azure-pipelines-javascript.yml @@ -3,14 +3,14 @@ # steps: - - script: bash startFabric.sh javascript + - script: ./startFabric.sh javascript workingDirectory: fabcar displayName: Start Fabric - script: | retry -- npm install npm ls workingDirectory: fabcar/javascript - displayName: Install FabCar application dependencies + displayName: Install FabCar Application Dependencies - script: | set -ex node enrollAdmin @@ -18,4 +18,4 @@ steps: node invoke node query workingDirectory: fabcar/javascript - displayName: Run FabCar application + displayName: Run FabCar Application diff --git a/ci/fabcar-typescript.yml b/ci/templates/fabcar/azure-pipelines-typescript.yml similarity index 76% rename from ci/fabcar-typescript.yml rename to ci/templates/fabcar/azure-pipelines-typescript.yml index 8bbe48bba4..4e566f5beb 100644 --- a/ci/fabcar-typescript.yml +++ b/ci/templates/fabcar/azure-pipelines-typescript.yml @@ -3,12 +3,12 @@ # steps: - - script: bash startFabric.sh typescript + - script: ./startFabric.sh typescript workingDirectory: fabcar displayName: Start Fabric - script: retry -- npm install workingDirectory: fabcar/typescript - displayName: Install FabCar application dependencies + displayName: Install FabCar Application Dependencies - script: npm run build workingDirectory: fabcar/typescript displayName: Build FabCar application @@ -19,4 +19,4 @@ steps: node dist/invoke node dist/query workingDirectory: fabcar/typescript - displayName: Run FabCar application + displayName: Run FabCar Application diff --git a/ci/templates/install-deps.yml b/ci/templates/install-deps.yml new file mode 100644 index 0000000000..957293789a --- /dev/null +++ b/ci/templates/install-deps.yml @@ -0,0 +1,17 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +steps: + - task: NodeTool@0 + inputs: + versionSpec: $(NODE_VER) + displayName: Install Node.js + - script: curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-linux-amd64-${FABRIC_VERSION}-stable.tar.gz | tar xz + displayName: Download Fabric CLI + - script: curl -L --retry 5 --retry-delay 3 https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-ca-linux-amd64-${FABRIC_VERSION}-stable.tar.gz | tar xz + displayName: Download Fabric CA CLI + - script: curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o ./bin/retry && chmod +x ./bin/retry + displayName: Install retry CLI + - script: ./ci/scripts/pullFabricImages.sh + displayName: Pull Fabric Docker Imagess \ No newline at end of file diff --git a/ci/templates/test-network/azure-pipelines.yml b/ci/templates/test-network/azure-pipelines.yml new file mode 100644 index 0000000000..f4a3edc2a3 --- /dev/null +++ b/ci/templates/test-network/azure-pipelines.yml @@ -0,0 +1,11 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +steps: + - script: | + ./network.sh up createChannel -s couchdb -i ${FABRIC_VERSION} # FABRIC_VERSION is set in ci/azure-pipelines.yml + ./network.sh deployCC -l javascript + ./network.sh down + workingDirectory: test-network + displayName: Start Test Network diff --git a/ci/testnetwork.yml b/ci/testnetwork.yml deleted file mode 100644 index 9cf27392ff..0000000000 --- a/ci/testnetwork.yml +++ /dev/null @@ -1,15 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -steps: - - script: | - sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C .. - ./network.sh down - ./network.sh up createChannel -s couchdb -i 2.0.0 - ./network.sh deployCC -l javascript - - workingDirectory: test-network - displayName: Start up test network - env: - FABRIC_CFG_PATH: /usr/local/config diff --git a/scripts/ci_scripts/byfn_eyfn.sh b/scripts/ci_scripts/byfn_eyfn.sh deleted file mode 100755 index fc9b8a0160..0000000000 --- a/scripts/ci_scripts/byfn_eyfn.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -# docker container list -CONTAINER_LIST=(peer0.org1 peer1.org1 peer0.org2 peer1.org2 peer0.org3 peer1.org3 orderer) -COUCHDB_CONTAINER_LIST=(couchdb0 couchdb1 couchdb2 couchdb3 couchdb4 couchdb5) - -cd $WORKSPACE/$BASE_DIR/first-network -# export path -export PATH=$WORKSPACE/$BASE_DIR/bin:$PATH - -logs() { - # Create Logs directory - mkdir -p $WORKSPACE/Docker_Container_Logs - for CONTAINER in ${CONTAINER_LIST[*]}; do - docker logs $CONTAINER.example.com >& $WORKSPACE/Docker_Container_Logs/$CONTAINER-$1.log - echo - done -} - -if [ ! -z $2 ]; then - for CONTAINER in ${COUCHDB_CONTAINER_LIST[*]}; do - docker logs $CONTAINER >& $WORKSPACE/Docker_Container_Logs/$CONTAINER-$1.log - echo - done -fi - -copy_logs() { - # Call logs function - logs $2 $3 - if [ $1 != 0 ]; then - echo -e "\033[31m $2 test case is FAILED" "\033[0m" - exit 1 - fi -} - -echo " ################ " -echo -e "\033[1m DEFAULT CHANNEL\033[0m" -echo " # ############## " -set -x -echo y | ./byfn.sh -m down -echo y | ./byfn.sh -m up -t 60 -copy_logs $? default-channel -echo y | ./eyfn.sh -m up -t 60 -copy_logs $? default-channel -echo y | ./eyfn.sh -m down -set +x -echo - -echo " ############################ " -echo -e "\033[1mCUSTOM CHANNEL - COUCHDB\033[0m" -echo " # ########################## " -set -x -echo y | ./byfn.sh -m up -c custom-channel-couchdb -s couchdb -t 75 -d 15 -copy_logs $? custom-channel-couch couchdb -echo y | ./eyfn.sh -m up -c custom-channel-couchdb -s couchdb -t 75 -d 15 -copy_logs $? custom-channel-couch -echo y | ./eyfn.sh -m down -set +x -echo - -echo " #################################### " -echo -e "\033[1m JAVASCRIPT CHAINCODE\033[0m" -echo " # ################################## " -set -x -echo y | ./byfn.sh -m up -l javascript -t 60 -copy_logs $? default-channel-javascript -echo y | ./eyfn.sh -m up -l javascript -t 60 -copy_logs $? default-channel-javascript -echo y | ./eyfn.sh -m down -set +x diff --git a/scripts/ci_scripts/ciScript.sh b/scripts/ci_scripts/ciScript.sh deleted file mode 100755 index f2edebf10a..0000000000 --- a/scripts/ci_scripts/ciScript.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -e -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -# exit on first error - -Parse_Arguments() { - while [ $# -gt 0 ]; do - case $1 in - --byfn_eyfn_Tests) - byfn_eyfn_Tests - ;; - --fabcar_Tests) - fabcar_Tests - ;; - esac - shift - done -} - -# run byfn,eyfn tests -byfn_eyfn_Tests() { - - echo - echo " ____ __ __ _____ _ _ _____ __ __ _____ _ _ " - echo " | __ ) \ \ / / | ___| | \ | | | ____| \ \ / / | ___| | \ | | " - echo " | _ \ \ V / | |_ | \| | _____ | _| \ V / | |_ | \| | " - echo " | |_) | | | | _| | |\ | |_____| | |___ | | | _| | |\ | " - echo " |____/ |_| |_| |_| \_| |_____| |_| |_| |_| \_| " - - ./byfn_eyfn.sh -} -# run fabcar tests -fabcar_Tests() { - - echo " #############################" - echo "npm version ------> $(npm -v)" - echo "node version ------> $(node -v)" - echo " #############################" - - echo - echo " _____ _ ____ ____ _ ____ " - echo " | ___| / \ | __ ) / ___| / \ | _ \ " - echo " | |_ / _ \ | _ \ | | / _ \ | |_) | " - echo " | _| / ___ \ | |_) | | |___ / ___ \ | _ < " - echo " |_| /_/ \_\ |____/ \____| /_/ \_\ |_| \_\ " - - ./fabcar.sh -} - -Parse_Arguments $@ diff --git a/scripts/ci_scripts/fabcar.sh b/scripts/ci_scripts/fabcar.sh deleted file mode 100755 index 9d1a5f0f4a..0000000000 --- a/scripts/ci_scripts/fabcar.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# SPDX-License-Identifier: Apache-2.0 -# - -logs() { - LOG_DIRECTORY=$WORKSPACE/fabcar/$1 - mkdir -p ${LOG_DIRECTORY} - CONTAINER_LIST=$(docker ps -a --format '{{.Names}}') - for CONTAINER in ${CONTAINER_LIST}; do - docker logs ${CONTAINER} > ${LOG_DIRECTORY}/${CONTAINER}.log 2>&1 - done -} - -copy_logs() { - -# Call logs function -logs $2 $3 - -if [ $1 != 0 ]; then - echo -e "\033[31m $2 test case is FAILED" "\033[0m" - exit 1 -fi -} - -cd $WORKSPACE/$BASE_DIR/fabcar || exit -export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH - -LANGUAGES="go java javascript typescript" -for LANGUAGE in ${LANGUAGES}; do - echo -e "\033[1m ${LANGUAGE} Test\033[0m" - echo -e "\033[32m starting fabcar test (${LANGUAGE})" "\033[0m" - # Start Fabric, and deploy the smart contract - ./startFabric.sh ${LANGUAGE} - copy_logs $? fabcar-${LANGUAGE} - # If an application exists for this language, test it - if [ -d ${LANGUAGE} ]; then - pushd ${LANGUAGE} - if [ ${LANGUAGE} = "javascript" -o ${LANGUAGE} = "typescript" ]; then - if [ ${LANGUAGE} = "javascript" ]; then - COMMAND=node - PREFIX= - SUFFIX=.js - npm install - elif [ ${LANGUAGE} = "typescript" ]; then - COMMAND=node - PREFIX=dist/ - SUFFIX=.js - npm install - npm run build - fi - ${COMMAND} ${PREFIX}enrollAdmin${SUFFIX} - copy_logs $? fabcar-${LANGUAGE}-enrollAdmin - ${COMMAND} ${PREFIX}registerUser${SUFFIX} - copy_logs $? fabcar-${LANGUAGE}-registerUser - ${COMMAND} ${PREFIX}query${SUFFIX} - copy_logs $? fabcar-${LANGUAGE}-query - ${COMMAND} ${PREFIX}invoke${SUFFIX} - copy_logs $? fabcar-${LANGUAGE}-invoke - elif [ ${LANGUAGE} = "java" ]; then - mvn test - copy_logs $? fabcar-${LANGUAGE} - else - echo -e "\033[31m do not know how to handle ${LANGUAGE}" "\033[0m" - exit 1 - fi - popd - fi - docker ps -aq | xargs docker rm -f - docker rmi -f $(docker images -aq dev-*) - docker volume prune -f - docker network prune -f - echo -e "\033[32m finished fabcar test (${LANGUAGE})" "\033[0m" -done diff --git a/test-network/network.sh b/test-network/network.sh index 8051be3252..886e52d8a8 100755 --- a/test-network/network.sh +++ b/test-network/network.sh @@ -497,7 +497,7 @@ while [[ $# -ge 1 ]] ; do shift ;; -i ) - IMAGETAG=$(go env GOARCH)"-""$2" + IMAGETAG="$2" shift ;; -verbose )