diff --git a/Jenkinsfile b/Jenkinsfile index c11fd2e0ef..21965e5413 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,155 +1,157 @@ +#!groovy // Copyright IBM Corp All Rights Reserved // // SPDX-License-Identifier: Apache-2.0 // -// Pipeline script for fabric-samples +// Jenkinfile will get triggered on verify and merge jobs and run byfn, eyfn and fabcar +// tests. -node ('hyp-x') { // trigger build on x86_64 node - timestamps { - try { - def ROOTDIR = pwd() // workspace dir (/w/workspace/ - def nodeHome = tool 'nodejs-8.11.3' - env.ARCH = "amd64" - env.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile && cat Makefile | grep "BASE_VERSION =" | cut -d "=" -f2').trim() - env.VERSION = "$VERSION" // BASE_VERSION from fabric Makefile - env.BASE_IMAGE_VER = sh(returnStdout: true, script: 'cat Makefile | grep "BASEIMAGE_RELEASE =" | cut -d "=" -f2').trim() // BASEIMAGE Version from fabric Makefile - env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus - env.PROJECT_VERSION = "${VERSION}-stable" - env.BASE_IMAGE_TAG = "${ARCH}-${BASE_IMAGE_VER}" //fabric baseimage version - env.PROJECT_DIR = "gopath/src/github.com/hyperledger" - env.GOPATH = "$WORKSPACE/gopath" - env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH" - def jobname = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep -q "verify" && echo patchset || echo merge').trim() - def failure_stage = "none" - // delete working directory - deleteDir() - stage("Fetch Patchset") { // fetch gerrit refspec on latest commit - try { - if (jobname == "patchset") { - println "$GERRIT_REFSPEC" - println "$GERRIT_BRANCH" - checkout([ - $class: 'GitSCM', - branches: [[name: '$GERRIT_REFSPEC']], - extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT'], [$class: 'CheckoutOption', timeout: 10]], - userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '$GERRIT_REFSPEC:$GERRIT_REFSPEC', url: '$GIT_BASE']]]) - } else { - // Clone fabric-samples on merge - println "Clone $PROJECT repository" - checkout([ - $class: 'GitSCM', - branches: [[name: 'refs/heads/$GERRIT_BRANCH']], - extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT']], - userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '+refs/heads/$GERRIT_BRANCH:refs/remotes/origin/$GERRIT_BRANCH', url: '$GIT_BASE']]]) - } - dir("${ROOTDIR}/$PROJECT_DIR/$PROJECT") { - sh ''' - # Print last two commit details - echo - git log -n2 --pretty=oneline --abbrev-commit - echo - ''' - } - } - catch (err) { - failure_stage = "Fetch patchset" - currentBuild.result = 'FAILURE' - throw err - } -} - // clean environment and get env data - stage("Clean Environment - Get Env Info") { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --clean_Environment --env_Info' - } - } - catch (err) { - failure_stage = "Clean Environment - Get Env Info" - currentBuild.result = 'FAILURE' - throw err - } - } - - // Pull Third_party Images - stage("Pull third_party Images") { - // making the output color coded - wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --pull_Thirdparty_Images' - } - } - catch (err) { - failure_stage = "Pull third_party docker images" - currentBuild.result = 'FAILURE' - throw err - } - } +// global shared library from ci-management repository +// https://github.com/hyperledger/ci-management/tree/master/vars (Global Shared scripts) +@Library("fabric-ci-lib") _ + pipeline { + agent { + // Execute tests on x86_64 build nodes + // Set this value from Jenkins Job Configuration + label env.NODE_ARCH + } + options { + // Using the Timestamper plugin we can add timestamps to the console log + timestamps() + // Set build timeout for 60 mins + timeout(time: 60, unit: 'MINUTES') } - - // Pull Fabric, fabric-ca Images - stage("Pull Docker Images") { - // making the output color coded - wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --pull_Docker_Images' - } - } - catch (err) { - failure_stage = "Pull fabric, fabric-ca docker images" - currentBuild.result = 'FAILURE' - throw err - } - } + environment { + ROOTDIR = pwd() + // Applicable only on x86_64 nodes + // LF team has to install the newer version in Jenkins global config + // Send an email to helpdesk@hyperledger.org to add newer version + nodeHome = tool 'nodejs-8.11.3' + MARCH = sh(returnStdout: true, script: "uname -m | sed 's/x86_64/amd64/g'").trim() + OS_NAME = sh(returnStdout: true, script: "uname -s|tr '[:upper:]' '[:lower:]'").trim() + props = "null" } - - // Run byfn, eyfn tests (default, custom channel, couchdb, nodejs chaincode) - stage("Run byfn_eyfn Tests") { - // making the output color coded - wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --byfn_eyfn_Tests' - } - } - catch (err) { - failure_stage = "byfn_eyfn_Tests" - currentBuild.result = 'FAILURE' - throw err - } - } - } - - // Run fabcar tests - stage("Run FabCar Tests") { - // making the output color coded - wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { - try { - dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") { - sh './CI_Script.sh --fabcar_Tests' - } - } - catch (err) { - failure_stage = "fabcar_Tests" - currentBuild.result = 'FAILURE' - throw err - } - } - } - } finally { - // Archive the artifacts - archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log' - // Sends notification to Rocket.Chat jenkins-robot channel - if (env.JOB_NAME == "fabric-samples-merge-job") { - if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE - rocketSend message: "Build Notification - STATUS: *${currentBuild.result}* - BRANCH: *${env.GERRIT_BRANCH}* - PROJECT: *${env.PROJECT}* - (<${env.BUILD_URL}|Open>)" + stages { + stage('Clean Environment') { + steps { + script { + // delete working directory + deleteDir() + // Clean build env before start the build + fabBuildLibrary.cleanupEnv() + // Display jenkins environment details + fabBuildLibrary.envOutput() + } + } + } + stage('Checkout SCM') { + steps { + script { + // Get changes from gerrit + fabBuildLibrary.cloneRefSpec('fabric-samples') + // Load properties from ci.properties file + props = fabBuildLibrary.loadProperties() + } + } + } + // Pull build artifacts + stage('Pull Build Artifacts') { + steps { + script { + if(props["IMAGE_SOURCE"] == "build") { + println "BUILD ARTIFACTS" + // Set PATH + env.GOPATH = "$WORKSPACE/gopath" + env.GOROOT = "/opt/go/go" + props["GO_VER"] + ".linux." + "$MARCH" + env.PATH = "$GOPATH/bin:$GOROOT/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH" + // Clone fabric repo + fabBuildLibrary.cloneScm('fabric', '$GERRIT_BRANCH') + // Build fabric docker images and binaries + fabBuildLibrary.fabBuildImages('fabric', 'docker dist') + // Clone fabric-ca repo + fabBuildLibrary.cloneScm('fabric-ca', '$GERRIT_BRANCH') + // Build fabric docker images and binaries + fabBuildLibrary.fabBuildImages('fabric-ca', 'docker dist') + // Copy binaries to fabric-samples dir + sh 'cp -r $ROOTDIR/gopath/src/github.com/hyperledger/fabric/release/$OS_NAME-$MARCH/bin $ROOTDIR/$BASE_DIR/' + // Pull Thirdparty Docker Images from hyperledger DockerHub + fabBuildLibrary.pullThirdPartyImages(props["FAB_BASEIMAGE_VERSION"], props["FAB_THIRDPARTY_IMAGES_LIST"]) + } else { + dir("$ROOTDIR/$BASE_DIR") { + // Set PATH + env.GOPATH = "$WORKSPACE/gopath" + env.GOROOT = "/opt/go/go" + props["GO_VER"] + ".linux." + "$MARCH" + env.PATH = "$GOPATH/bin:$GOROOT/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH" + // Pull Binaries with latest version from nexus2 + fabBuildLibrary.pullBinaries(props["FAB_BINARY_VER"], props["FAB_BINARY_REPO"]) + // Pull Docker Images from nexus3 + fabBuildLibrary.pullDockerImages(props["FAB_BASE_VERSION"], props["FAB_IMAGES_LIST"]) + // Pull Thirdparty Docker Images from hyperledger DockerHub + fabBuildLibrary.pullThirdPartyImages(props["FAB_BASEIMAGE_VERSION"], props["FAB_THIRDPARTY_IMAGES_LIST"]) + } + } + } + } + } + // Run byfn, eyfn tests (default, custom channel, couchdb, nodejs, java chaincode) + stage('Run byfn_eyfn Tests') { + steps { + script { + // making the output color coded + wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { + try { + dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") { + // Run BYFN, EYFN tests + sh './ciScript.sh --byfn_eyfn_Tests' + } + } + catch (err) { + failure_stage = "byfn_eyfn_Tests" + currentBuild.result = 'FAILURE' + throw err + } } - } + } + } + } + // Run fabcar tests + stage('Run Fab Car Tests') { + steps { + script { + // making the output color coded + wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) { + try { + dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") { + // Run fabcar tests + sh './ciScript.sh --fabcar_Tests' + } + } + catch (err) { + failure_stage = "fabcar_Tests" + currentBuild.result = 'FAILURE' + throw err + } + } + } + } + } + } // stages + post { + always { + // Archiving the .log files and ignore if empty + archiveArtifacts artifacts: '**/*.log', allowEmptyArchive: true + } + failure { + script { + if (env.JOB_TYPE == 'merge') { + // Send rocketChat notification to channel + // Send merge build failure email notifications to the submitter + sendNotifications(currentBuild.result, props["CHANNEL_NAME"]) + // Delete workspace when build is done + cleanWs notFailBuild: true + } + } } -// End Timestamps block - } -// End Node block -} + } // post + } // pipeline diff --git a/README.md b/README.md index 3946e594a3..71164f7ed4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ are 1.4.0, 1.4.0 and 0.4.14 respectively. ./scripts/bootstrap.sh [version] [ca version] [thirdparty_version] ``` +### Continuous Integration + +Please have a look at [Continuous Integration Process](docs/fabric-samples-ci.md) + ## License Hyperledger Project source code files are made available under the Apache diff --git a/basic-network/start.sh b/basic-network/start.sh index 246605bdbc..43e08a9acc 100755 --- a/basic-network/start.sh +++ b/basic-network/start.sh @@ -13,6 +13,7 @@ export MSYS_NO_PATHCONV=1 docker-compose -f docker-compose.yml down docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb +docker ps -a # wait for Hyperledger Fabric to start # incase of errors when running later commands, issue export FABRIC_START_TIMEOUT= diff --git a/ci.properties b/ci.properties new file mode 100644 index 0000000000..2738a7ceb7 --- /dev/null +++ b/ci.properties @@ -0,0 +1,21 @@ +# Set "nexus" if you would like to pull images from nexus3 +# Set "build" if you would like build fabric, fabric-ca on latest commits +IMAGE_SORUCE=nexus +# set only "javaenv" image if you set IMAGE_SOURCE to "build" +# Pull below list of images from nexus3 if IMAGE_SOURCE is set to "nexus" or "build" +FAB_IMAGES_LIST=ca peer orderer ccenv tools baseos nodeenv javaenv +# Set fabric if you would like pull only fabric binaries +FAB_BINARY_REPO=fabric fabric-ca +# Pull below list of images from Hyperledger DockerHub +FAB_THIRDPARTY_IMAGES_LIST=kafka zookeeper couchdb +# Pull latest binaries of latest commit of release-1.4 from nexus snapshots +# Applicable only when set IMAGE_SOURCE to "nexus" +FAB_BINARY_VER=latest +# Set base version from fabric branch +FAB_BASE_VERSION=2.0.0 +# Set base image version from fabric branch +FAB_BASEIMAGE_VERSION=0.4.15 +# Set related rocketChat channel name. Default: jenkins-robot +CHANNEL_NAME=jenkins-robot +# Set compaitable go version +GO_VER=1.11.5 diff --git a/docs/fabric-samples-ci.md b/docs/fabric-samples-ci.md new file mode 100644 index 0000000000..19d80e01e9 --- /dev/null +++ b/docs/fabric-samples-ci.md @@ -0,0 +1,109 @@ +# Continuous Integration Process + +This document explains the fabric-samples Jenkins pipeline flow and FAQ's on the build +process to help developer to get more familiarize with the process flow. + +We use Jenkins as a CI tool and to manage jobs, we use [JJB](https://docs.openstack.org/infra/jenkins-job-builder). +Please see the pipeline job configuration template here https://ci-docs.readthedocs.io/en/latest/source/pipeline_jobs.html#job-templates. + +## CI Pipeline flow + +- Every Gerrit patchset triggers a verify job with the Gerrit Refspec on the parent commit + of the patchset and runs the below tests from the `Jenkinsfile`. Note: when you are ready + to merge the patchset, it's always a best practice to rebase the patchset on the latest commit. + +All the below tests runs on the Hyperledger infarstructure x86_64 build nodes. All these nodes +uses the packer with pre-configured software packages. This helps us to run the tests in much +faster than installing required packages everytime. + +Below steps shows what each stage does in the Jenkins pipeline verify and merge flow. +Before execute the below tests, it clean the environment (Deletes the left over build artifiacts) +and clone the repository with the Gerrit Refspec. + +![](pipeline_flow.png) + +Based on the value provided to **IMAGE_SOURCE** in ci.properties file, Jenkinsfile execute the +steps. If the IMAGE_SOURCE is set to "build", Jenkins clones the latest commits of fabric +and fabric-ca and builds the docker images and binaries. If you specify IMAGE_SOURCE as "nexus", +it always pulls the latest fabric and fabric-ca images published from nightly job which triggers +everyday at 8:00 PM EST. + +Also, it pulls the "javaenv" and "nodeenv" images from the latest published images from nexus3. +NOTE: nodeenv image is available only in master branch. + +Once the artifacts stage is ready, Jenkins executes the below tests + +- byfn & eyfn tests + - on default channel + - Custom channel with couchdb + - on node chanincode + +- fabcar tests + - go + - javascript + - typescript + +Above pipeline flow works the same on both `fabric-samples-verify-x86_64` and `fabric-samples-merge-x86_64` pipeline jobs. + +See below **FAQ's** for more information on the pipeline process. + +## FAQ's + +#### How to re-trigger failed tests? + +You can post comments `reverify` or `reverify-x` on the gerrit patchset to trigger the `fabric-samples-verify-x86_64` +job which triggers the pipeline flow as mentioned above. Also, we provided `remerge` or `remerge-x` +comment phrases to re-trigger the failed merge job. + +#### Where should I see the output of the stages? + +Piepline supports two views (stages and blueocean). **Staged views** shows on the Jenkins job +main page and it shows each stage in order and the status. For better view, we suggest you +to access BlueOcean plugin. Click on the build number and click on the **Open Blue Ocean** +link that shows the build stages in pipeline view. + +#### How to add more stages to this pipeline flow? + +We use scripted pipeline syntax with groovy and shell scripts. Also, we use global shared +library scripts which are placed in https://github.com/hyperledger/ci-management/tree/master/vars. +Try to leverage these common functions in your code. All you have to do is, undestand the pipeline +flow of the tests and conditions, add more stages as mentioned in the existing Jenkinsfile. + +#### How will I get build failure notifications? + +On every merge failure, we send build failure email notications to the submitter of the +patchset and sends the build details to the Rocket Chat **jenkins-robot** channel. Check the +result here https://chat.hyperledger.org/channel/jenkins-robot + +#### What steps I have to modify when I create a new branch from master? + +As the Jenkinsfile is completely parametrzed, you no need to modify anything in the +Jenkinsfile but you may endup modifying **ci.properties** file with the appropirate +Base Versions, Baseimage versions etc... in the new branch. We suggest you to modify this +file immediately after you create a new branch to avoid running tests on older versions. + +#### On what platforms these tests triggers? + +- x86_64 (Run the above mentioned tests on verify and merge jobs) +- s390x (Run the above mentioned tests in daily jobs) + +#### Where can I see the Build Scripts. + +We use global shared library scripts and Jenkinsfile along with the build file. + +Global Shared Library - https://github.com/hyperledger/ci-management/tree/master/vars + +Jenkinsfile - https://github.com/hyperledger/fabric-samples/tree/master/Jenkinsfile + +ci.properties - https://github.com/hyperledger/fabric-samples/tree/master/ci.properties +(ci.properties is the only file you have to modify with the values requried for the specific branch.) + +Packer Scripts - https://github.com/hyperledger/ci-management/blob/master/packer/provision/docker.sh +(Packer is a tool for automatically creating VM and container images, configuring them and +post-processing them into standard output formats. We build Hyperledger's CI images via Packer +and attach them to x86_64 build nodes. On s390x, we install manually. See the packages we +install as a pre-requisite in the CI x86 build nodes.) + +#### How to reach out to CI team? + +Post your questions or feedback in https://chat.hyperledger.org/channel/ci-pipeline or https://chat.hyperledger.org/channel/fabric-ci Rocket Chat channels. Also, you can create JIRA tasks or bugs in FABCI project. https://jira.hyperledger.org/projects/FABCI \ No newline at end of file diff --git a/docs/pipeline_flow.png b/docs/pipeline_flow.png new file mode 100644 index 0000000000..b1d98011fd Binary files /dev/null and b/docs/pipeline_flow.png differ diff --git a/fabcar/startFabric.sh b/fabcar/startFabric.sh index e3ee04689b..f9bc509de9 100755 --- a/fabcar/startFabric.sh +++ b/fabcar/startFabric.sh @@ -44,6 +44,7 @@ cd ../basic-network # Now launch the CLI container in order to install, instantiate chaincode # and prime the ledger with our 10 cars docker-compose -f ./docker-compose.yml up -d cli +docker ps -a docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli \ peer lifecycle chaincode package fabcar.tar.gz --path "$CC_SRC_PATH" --lang "$CC_RUNTIME_LANGUAGE" --label fabcarv1 diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 965e4db07b..cb893bb4f5 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -159,18 +159,24 @@ function networkUp() { if [ "${IF_COUCHDB}" == "couchdb" ]; then if [ "$CONSENSUS_TYPE" == "kafka" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH up -d 2>&1 + docker ps -a elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH up -d 2>&1 + docker ps -a else IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 + docker ps -a fi else if [ "$CONSENSUS_TYPE" == "kafka" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA up -d 2>&1 + docker ps -a elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 up -d 2>&1 + docker ps -a else IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1 + docker ps -a fi fi if [ $? -ne 0 ]; then diff --git a/scripts/ci_scripts/byfn_eyfn.sh b/scripts/ci_scripts/byfn_eyfn.sh new file mode 100755 index 0000000000..635b07bc27 --- /dev/null +++ b/scripts/ci_scripts/byfn_eyfn.sh @@ -0,0 +1,75 @@ +#!/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 NODE CHAINCODE\033[0m" +echo " # ################################## " +set -x +echo y | ./byfn.sh -m up -l node -t 60 +copy_logs $? default-channel-node +echo y | ./eyfn.sh -m up -l node -t 60 +copy_logs $? default-channel-node +echo y | ./eyfn.sh -m down +set +x diff --git a/scripts/ci_scripts/ciScript.sh b/scripts/ci_scripts/ciScript.sh new file mode 100755 index 0000000000..f2edebf10a --- /dev/null +++ b/scripts/ci_scripts/ciScript.sh @@ -0,0 +1,54 @@ +#!/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/Jenkins_Scripts/fabcar.sh b/scripts/ci_scripts/fabcar.sh similarity index 95% rename from scripts/Jenkins_Scripts/fabcar.sh rename to scripts/ci_scripts/fabcar.sh index d47d46827c..7a70f74d0f 100755 --- a/scripts/Jenkins_Scripts/fabcar.sh +++ b/scripts/ci_scripts/fabcar.sh @@ -28,11 +28,12 @@ if [ $1 != 0 ]; then fi } -cd $BASE_FOLDER/fabric-samples/fabcar || exit +cd $WORKSPACE/$BASE_DIR/fabcar || exit export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH LANGUAGES="go 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}