From d33abf8d50c9cc4b7654f77f65d52bb43f6b1985 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:36:23 +0000 Subject: [PATCH 01/18] scripts: use longer key for mpc server in tests (fixes sll error) --- scripts/test_mpc_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test_mpc_common.sh b/scripts/test_mpc_common.sh index 4f66f6d49..498d432e1 100644 --- a/scripts/test_mpc_common.sh +++ b/scripts/test_mpc_common.sh @@ -64,7 +64,7 @@ function prepare_server_common() { # TLS server certs if ! [ -e ${SERVER_KEY} ] || ! [ -e ${SERVER_CERT} ] ; then echo TLS certificate ... - KEY_BITS=1024 + KEY_BITS=4096 cp /etc/ssl/openssl.cnf openssl.tmp.cnf echo "[v3_req]" >> openssl.tmp.cnf echo "subjectAltName=DNS:localhost" >> openssl.tmp.cnf From c843074ec692f397d4e97f9c795b44eb77672ebe Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:37:04 +0000 Subject: [PATCH 02/18] scripts: timeout waiting for mpc server --- scripts/test_mpc_common.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/test_mpc_common.sh b/scripts/test_mpc_common.sh index 498d432e1..686869723 100644 --- a/scripts/test_mpc_common.sh +++ b/scripts/test_mpc_common.sh @@ -93,9 +93,19 @@ function start_server_common() { $2 > server.stdout & echo $! > server.pid + x=1 while ! $3 ; do + if [ $x == 10 ] ; then + echo "FAILED TO LAUNCH" + exit 1 + fi + echo "TEST: waiting for server to start ..." sleep 1 + + x=$(( $x + 1 )) + echo "TEST: retrying ($x)" + done echo "TEST: server up (pid: "`cat server.pid`")" popd From acad712f1791b500981e41618848c883da66e549 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:37:45 +0000 Subject: [PATCH 03/18] ci: add dependencies for building on ubuntu --- scripts/ci | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/ci b/scripts/ci index e64d0bacd..9143db255 100755 --- a/scripts/ci +++ b/scripts/ci @@ -60,6 +60,26 @@ function _stop_ganache() { popd } +function _build_setup() { + # Extra deps for native builds + if [ "${platform}" == "Linux" ] ; then + if (which apk) ; then + # Packages already available in Docker build + echo -n # null op required for syntax + else + sudo apt install \ + libboost-dev \ + libboost-system-dev \ + libboost-filesystem-dev \ + libboost-program-options-dev \ + libgmp-dev \ + libprocps-dev \ + libxslt1-dev \ + pkg-config + fi + fi +} + function check_format() { scripts/format git diff --no-ext-diff | head -n 20 > format_errors @@ -150,6 +170,9 @@ function mpc_tests() { } function build() { + + _build_setup + # Additional compilation flags cxx_flags="-Werror" From 738732c096e0bf7624ece561b4291c210c47d7ff Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:39:03 +0000 Subject: [PATCH 04/18] prover_server: clean up some grpc dependency handling --- prover_server/CMakeLists.txt | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/prover_server/CMakeLists.txt b/prover_server/CMakeLists.txt index 548ccbd83..e0304b04d 100644 --- a/prover_server/CMakeLists.txt +++ b/prover_server/CMakeLists.txt @@ -44,30 +44,20 @@ add_executable( ${PROVER_SERVER_SOURCE} ${GRPC_SRCS} ) -if ("${STATIC_BUILD}") + +if (NOT APPLE) find_package(PkgConfig REQUIRED) pkg_check_modules(GRPC REQUIRED IMPORTED_TARGET grpc++) +endif() - target_link_libraries( - prover_server - - zeth - ${Boost_SYSTEM_LIBRARY} - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${GRPC_LIBRARIES} - gRPC::grpc++_reflection - protobuf::libprotobuf - ) -else() - target_link_libraries( - prover_server +target_link_libraries( + prover_server - zeth - ${Boost_SYSTEM_LIBRARY} - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - gRPC::grpc++_reflection - protobuf::libprotobuf + zeth + ${Boost_SYSTEM_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${GRPC_LIBRARIES} + gRPC::grpc++_reflection + protobuf::libprotobuf ) -endif() From 588bbf29b364def31db4796ce95c94c18b0a2267 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:41:30 +0000 Subject: [PATCH 05/18] ci: cache submodule builds on mac, keyed by commit --- .github/workflows/onpush-build-macos.yml | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/onpush-build-macos.yml b/.github/workflows/onpush-build-macos.yml index 00ebae38c..3c4528944 100644 --- a/.github/workflows/onpush-build-macos.yml +++ b/.github/workflows/onpush-build-macos.yml @@ -9,17 +9,43 @@ env: jobs: + # Extract the commits of submodules for use by cache steps + submodules: + runs-on: ubuntu-20.04 + outputs: + libsodium: ${{ steps.get-commits.outputs.libsodium }} + libsnark: ${{ steps.get-commits.outputs.libsnark }} + steps: + - uses: actions/checkout@v2 + - name: Get Submodule Commits + id: get-commits + run: | + git submodule sync + echo "::set-output name=libsodium::"`git submodule status depends/libsodium | grep -oe '[0-9a-fA-F]\+' | head -c 8` + echo "::set-output name=libsnark::"`git submodule status depends/libsnark | grep -oe '[0-9a-fA-F]\+' | head -c 8` + + # Main build build-macos: runs-on: macos-10.15 + needs: submodules strategy: matrix: config: [ Debug, Release ] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive + - name: Cache libsodium + uses: actions/cache@v1 + with: + key: libsodium-${{ needs.submodules.outputs.libsodium }}-${{ runner.os }}-${{ matrix.config }} + path: build/depends/libsodium-prefix + - name: Cache libsnark + uses: actions/cache@v1 + with: + key: libsnark-${{ needs.submodules.outputs.libsnark }}-${{ runner.os }}-${{ matrix.config }} + path: build/depends/libsnark - name: Install Dependencies run: brew install ${MACOS_BREW_PACKAGES} - name: Execute run: CI_CONFIG=${{ matrix.config }} scripts/ci build - From 2c866c1246022fa16927450f366e8803c31088b2 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 14:54:53 +0000 Subject: [PATCH 06/18] ci: excute part of linux build on ci host, caching grpc build --- .github/workflows/onpush-build-ubuntu.yml | 30 ++++++++- scripts/install_grpc | 76 +++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 scripts/install_grpc diff --git a/.github/workflows/onpush-build-ubuntu.yml b/.github/workflows/onpush-build-ubuntu.yml index 830443563..084a536d5 100644 --- a/.github/workflows/onpush-build-ubuntu.yml +++ b/.github/workflows/onpush-build-ubuntu.yml @@ -6,17 +6,43 @@ on: jobs: + # Job to build the grpc libraries. The grpc build directory is populated and + # cached so that all other jobs can mark this job as a prerequisite and just + # run `make install`. + # + # NOTE: the version number here (in `key` and in script arguments) must be + # kept in sync with the key used by the jobs. + build-grpc: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Cache grpc + uses: actions/cache@v2 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Build grpc + run: if ! [ -d depends/grpc ] ; then scripts/install_grpc /usr v1.31.x depends/grpc ; fi + build-linux: runs-on: ubuntu-20.04 + needs: build-grpc strategy: matrix: config: [ Debug, Release ] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive + - name: Cache grpc + uses: actions/cache@v1 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Install grpc + run: scripts/install_grpc /usr v1.31.x depends/grpc - name: Execute - run: CI_CHECK_FORMAT=1 CI_USE_DOCKER=1 CI_CONFIG=${{ matrix.config }} scripts/ci build + run: CI_CHECK_FORMAT=1 CI_CONFIG=${{ matrix.config }} scripts/ci build build-linux-pghr13: runs-on: ubuntu-20.04 diff --git a/scripts/install_grpc b/scripts/install_grpc new file mode 100755 index 000000000..085ba1e75 --- /dev/null +++ b/scripts/install_grpc @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# This script is only intended to run on the CI machines. Not for local +# development. + +if [ "" == "$1" ] || [ "" == "$2" ] || [ "" == "$3" ] ; then + echo "error: invalid arguments" + echo "Usage: $0 " + echo "" + exit 1 +fi + +set -e +set -x + +INSTALL_DIR=$1 +VERSION=$2 +BUILD_DIR=$3 + +# This script executes in one of 2 modes on the CI: +# +# - No pre-existing build directory (DO_BUILD=1). +# +# - Pre-existing build directory, cached a previous successful build +# (DO_BUILD=0). In this case, installation can be performed directly. + +if [ -d "${BUILD_DIR}" ] ; then + DO_BUILD=0 +else + DO_BUILD=1 +fi + +mkdir -p ${BUILD_DIR} +pushd ${BUILD_DIR} + + # Clone repo and submodules (if DO_BUILD == 1) + if [ "1" == "${DO_BUILD}" ] ; then + git clone --depth 1 -b ${VERSION} https://github.com/grpc/grpc . + git submodule update --depth 1 --init --recursive + fi + + # Install protobuf + pushd third_party/protobuf + if [ "1" == "${DO_BUILD}" ] ; then + [ -e ./configure ] || ./autogen.sh + DIST_LANG=cpp ./configure --prefix ${INSTALL_DIR} + make -j $(($(nproc)+1)) + fi + sudo make install + popd # third_party/protobuf + + # Install grpc + mkdir -p build + pushd build + if [ "1" == "${DO_BUILD}" ] ; then + cmake \ + -DCMAKE_PREFIX_PATH=${INSTALL_DIR} \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ + -DCMAKE_BUILD_TYPE=Release \ + -DgRPC_INSTALL=ON \ + -DgRPC_BUILD_TESTS=OFF \ + -DBUILD_TESTING=OFF \ + -DgRPC_SSL_PROVIDER=package \ + -DgRPC_PROTOBUF_PROVIDER=package \ + -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \ + .. + make -j"$(($(nproc)+1))" + fi + sudo make install + popd # build + +popd # ${INSTALL_DEST} From f3cfdadccadc0746e3a68389c43d9faf0e35aaf4 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 16:42:08 +0000 Subject: [PATCH 07/18] ci: enable ccache where available --- depends/CMakeLists.txt | 3 ++- scripts/ci | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/depends/CMakeLists.txt b/depends/CMakeLists.txt index a805df286..f2c8836e7 100644 --- a/depends/CMakeLists.txt +++ b/depends/CMakeLists.txt @@ -23,11 +23,12 @@ endif() # libsodium set(LIBSODIUM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libsodium) +set(LIBSODIUM_CONFIGURE_CMD "CC=\"${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER}\" CXX=\"${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER}\" ./configure --prefix= --enable-minimal --disable-shared --enable-static") include(ExternalProject) ExternalProject_Add( libsodium SOURCE_DIR ${LIBSODIUM_SOURCE_DIR} - CONFIGURE_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh && ./configure --prefix= --enable-minimal --disable-shared --enable-static + CONFIGURE_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh && eval ${LIBSODIUM_CONFIGURE_CMD} BUILD_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && make ${MAKE_BUILD_FLAGS} INSTALL_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && make install) diff --git a/scripts/ci b/scripts/ci index 9143db255..b74910737 100755 --- a/scripts/ci +++ b/scripts/ci @@ -193,6 +193,9 @@ function build() { if ! [ "${full_build}" == "1" ] ; then cmake_flags="${cmake_flags} -DFAST_TESTS_ONLY=ON" fi + if (which ccache) ; then + cmake_flags="${cmake_flags} -DCMAKE_C_COMPILER_LAUNCHER=ccache" + fi # Build and run unit tests . setup_env.sh From 220231f445ee4a63dd6dcd963ac25ce9dda85379 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Wed, 20 Jan 2021 16:23:22 +0000 Subject: [PATCH 08/18] ci: use ccache to cache submodule builds on macos --- .github/workflows/onpush-build-macos.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/onpush-build-macos.yml b/.github/workflows/onpush-build-macos.yml index 3c4528944..cecc82a9c 100644 --- a/.github/workflows/onpush-build-macos.yml +++ b/.github/workflows/onpush-build-macos.yml @@ -5,7 +5,7 @@ on: push: env: - MACOS_BREW_PACKAGES: "pkg-config libomp" + MACOS_BREW_PACKAGES: "pkg-config libomp ccache" jobs: @@ -13,16 +13,14 @@ jobs: submodules: runs-on: ubuntu-20.04 outputs: - libsodium: ${{ steps.get-commits.outputs.libsodium }} - libsnark: ${{ steps.get-commits.outputs.libsnark }} + commits: ${{ steps.get-commits.outputs.commits }} steps: - uses: actions/checkout@v2 - name: Get Submodule Commits id: get-commits run: | git submodule sync - echo "::set-output name=libsodium::"`git submodule status depends/libsodium | grep -oe '[0-9a-fA-F]\+' | head -c 8` - echo "::set-output name=libsnark::"`git submodule status depends/libsnark | grep -oe '[0-9a-fA-F]\+' | head -c 8` + echo "::set-output name=commits::"`git submodule status depends/libsodium | grep -oe '[0-9a-fA-F]\+' | head -c 8`-`git submodule status depends/libsnark | grep -oe '[0-9a-fA-F]\+' | head -c 8` # Main build build-macos: @@ -35,16 +33,11 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive - - name: Cache libsodium + - name: Cache ccache uses: actions/cache@v1 with: - key: libsodium-${{ needs.submodules.outputs.libsodium }}-${{ runner.os }}-${{ matrix.config }} - path: build/depends/libsodium-prefix - - name: Cache libsnark - uses: actions/cache@v1 - with: - key: libsnark-${{ needs.submodules.outputs.libsnark }}-${{ runner.os }}-${{ matrix.config }} - path: build/depends/libsnark + key: submodules-${{ needs.submodules.outputs.commits }}-${{ runner.os }}-${{ matrix.config }} + path: ~/Library/Caches/ccache - name: Install Dependencies run: brew install ${MACOS_BREW_PACKAGES} - name: Execute From 46c95eea6fb4ba4fbb9b4fa1a01dec3c19bd5547 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 12:50:47 +0000 Subject: [PATCH 09/18] ci: run onpullrequest-build jobs natively using caches, and enable integration tests --- .../workflows/onpullrequest-build-ubuntu.yml | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/.github/workflows/onpullrequest-build-ubuntu.yml b/.github/workflows/onpullrequest-build-ubuntu.yml index 7a460e83c..383a1589c 100644 --- a/.github/workflows/onpullrequest-build-ubuntu.yml +++ b/.github/workflows/onpullrequest-build-ubuntu.yml @@ -1,13 +1,45 @@ # Actions for pull requests only -name: zeth-ci-pull-request +name: zeth-ci-onpullrequest-build-ubuntu on: pull_request: jobs: + # Job to build the grpc libraries. The grpc build directory is populated and + # cached so that all other jobs can mark this job as a prerequisite and just + # run `make install`. + # + # NOTE: the version number here (in `key` and in script arguments) must be + # kept in sync with the key used by the jobs. + onpr-build-grpc: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Cache grpc + uses: actions/cache@v2 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Build grpc + run: if ! [ -d depends/grpc ] ; then scripts/install_grpc /usr v1.31.x depends/grpc ; fi + + # Extract the commits of submodules for use by cache steps + onpr-submodules: + runs-on: ubuntu-20.04 + outputs: + commits: ${{ steps.get-commits.outputs.commits }} + steps: + - uses: actions/checkout@v2 + - name: Get Submodule Commits + id: get-commits + run: | + git submodule sync + echo "::set-output name=commits::"`git submodule status depends/libsodium | grep -oe '[0-9a-fA-F]\+' | head -c 8`-`git submodule status depends/libsnark | grep -oe '[0-9a-fA-F]\+' | head -c 8` + build-linux-full: runs-on: ubuntu-20.04 + needs: [onpr-build-grpc, onpr-submodules] strategy: matrix: curve: [ BLS12_377, ALT_BN128 ] @@ -15,5 +47,36 @@ jobs: - uses: actions/checkout@v1 with: submodules: recursive + - uses: actions/setup-node@v1 + with: + node-version: 10 + - name: Cache grpc + uses: actions/cache@v2 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + # - name: Cache ccache + # uses: actions/cache@v2 + # with: + # key: submodules-${{ needs.onpr-submodules.outputs.commits }}-${{ runner.os }}-${{ matrix.curve }} + # path: ~/.ccache + - name: Cache pip + uses: actions/cache@v2 + with: + path: | + ~/.cache/pip + ~/Library/Caches/pip + key: build-linux-full-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} + - name: Cache npm + uses: actions/cache@v2 + with: + path: | + ~/.npm + depends/ganache-cli/node_modules + key: build-linux-full-npm-${{ hashFiles('**/package-lock.json') }}-${{ runner.os }} + - name: Install dependencies + run: | + scripts/install_grpc /usr v1.31.x depends/grpc + sudo apt install -y ccache - name: Execute - run: CI_EVENT_NAME=pull_request CI_USE_DOCKER=1 CI_CONFIG=Release CI_CURVE=${{ matrix.curve }} scripts/ci build + run: CI_CONFIG=Release CI_CURVE=${{ matrix.curve }} CI_FULL_TESTS=1 CI_INTEGRATION_TESTS=1 scripts/ci build From 7333c68a5d5d286fd516b9c336541273ffec64d8 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 12:51:51 +0000 Subject: [PATCH 10/18] ci: support for integration tests in ci script --- scripts/ci | 112 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 14 deletions(-) diff --git a/scripts/ci b/scripts/ci index b74910737..a5e113e1b 100755 --- a/scripts/ci +++ b/scripts/ci @@ -19,6 +19,15 @@ function _setup_client() { popd } +function _setup_ganache() { + pushd zeth_contracts + npm config set python python2.7 + npm config set engine-strict true + npm config set unsafe-perm true + npm install --unsafe-perm + popd +} + function _ganache_is_active() { curl -sf \ -H "Content-Type: application/json" \ @@ -60,6 +69,48 @@ function _stop_ganache() { popd } +function _prover_server_is_active() { + # Assume the client env is active + zeth get-verification-key +} + +function _start_prover_server() { + # Requires the client env (for _prover_server_is_active) + . client/env/bin/activate + pushd build + + ./prover_server/prover_server > prover_server.stdout & + echo $! > prover_server.pid + + # Wait for prover_server to be active + while ! _prover_server_is_active ; do + echo "_start_prover_server: waiting for server ..." + sleep 1 + done + echo "_start_prover_server:: prover_server is active" + + popd # build + deactivate +} + +function _stop_prover_server() { + pushd build + + if ! [ -e prover_server.pid ] ; then + echo "_stop_prover_server: no PID file" + return 1 + fi + + pid=`cat prover_server.pid` + while (kill "${pid}") ; do + sleep 0.5 + done + rm prover_server.pid + echo "_stop_prover_server:: prover_server stopped" + + popd # build +} + function _build_setup() { # Extra deps for native builds if [ "${platform}" == "Linux" ] ; then @@ -95,11 +146,14 @@ function check_format() { } function check_contracts() { + + # Setup the zeth_contracts dir + _setup_ganache + + # Run checks in zeth_contracts pushd zeth_contracts - npm config set python python2.7 - npm install --unsafe-perm npm run check - popd + popd # zeth_contracts # Run contract tests (in python) _setup_client @@ -169,6 +223,30 @@ function mpc_tests() { scripts/test_mpc_server_phase2 } +function integration_tests() { + + # Native code is built. Setup client and ganache. + _setup_ganache + _setup_client + + # Start servers + _start_ganache + _start_prover_server + + # Enter client env and run client test script + . client/env/bin/activate + + ./scripts/test_zeth_cli + python -m test_commands.test_ether_mixing GROTH16 + python -m test_commands.test_erc_token_mixing GROTH16 + + deactivate + + # Stop servers + _stop_prover_server + _stop_ganache +} + function build() { _build_setup @@ -190,9 +268,11 @@ function build() { cmake_flags="-DCMAKE_BUILD_TYPE=${CI_CONFIG} -DZETH_SNARK=${CI_ZKSNARK}" cmake_flags="${cmake_flags} -DZETH_CURVE=${CI_CURVE}" - if ! [ "${full_build}" == "1" ] ; then + # Switch off slow tests unless CI_FULL_TESTS == 1 + if ! [ "${CI_FULL_TESTS}" == "1" ] ; then cmake_flags="${cmake_flags} -DFAST_TESTS_ONLY=ON" fi + # Use ccache if available if (which ccache) ; then cmake_flags="${cmake_flags} -DCMAKE_C_COMPILER_LAUNCHER=ccache" fi @@ -210,7 +290,13 @@ function build() { CTEST_OUTPUT_ON_FAILURE=1 make -j 2 check cd .. - mpc_tests + if [ "${CI_MPC_TESTS}" == "1" ] ; then + mpc_tests + fi + + if [ "${CI_INTEGRATION_TESTS}" == "1" ] ; then + integration_tests + fi } function ci_setup() { @@ -258,22 +344,17 @@ function ci_setup() { fi } - ci_task=$1 -full_build=$2 -if [ "${full_build}" == "" ] ; then - if [ "${CI_EVENT_NAME}" == "pull_request" ] ; then - full_build=1 - fi -fi echo ci_task = ${ci_task} -echo full_build=${full_build} echo CI_CONFIG=${CI_CONFIG} echo CI_ZKSNARK=${CI_ZKSNARK} echo CI_CURVE=${CI_CURVE} echo CI_CHECK_FORMAT=${CI_CHECK_FORMAT} echo CI_EVENT_NAME=${CI_EVENT_NAME} +echo CI_FULL_TEST=${CI_FULL_TESTS} +echo CI_MPC_TESTS=${CI_MPC_TESTS} +echo CI_INTEGRATION_TESTS=${CI_INTEGRATION_TESTS} if [ "${CI_CHECK_FORMAT}" == "1" ] ; then check_format @@ -299,7 +380,10 @@ if [ "${CI_USE_DOCKER}" == "1" ] ; then --env CI_CONFIG=${CI_CONFIG} \ --env CI_ZKSNARK=${CI_ZKSNARK} \ --env CI_CURVE=${CI_CURVE} \ - zeth-dev:latest $0 ${ci_task} ${full_build} + --env CI_FULL_TESTS=${CI_FULL_TESTS} \ + --env CI_MPC_TESTS=${CI_MPC_TESTS} \ + --env CI_INTEGRATION_TESTS=${CI_INTEGRATION_TESTS} \ + zeth-dev:latest $0 ${ci_task} else ci_setup ${ci_task} From c577144a4479028ec113b2dbf0d06137f5147dbb Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 12:55:13 +0000 Subject: [PATCH 11/18] ci: caching in onpush-checks jobs --- .github/workflows/onpush-checks.yml | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/onpush-checks.yml b/.github/workflows/onpush-checks.yml index 4955c285c..d0fb3b386 100644 --- a/.github/workflows/onpush-checks.yml +++ b/.github/workflows/onpush-checks.yml @@ -1,5 +1,5 @@ # Check actions (linters, analysis tools etc.) -name: zeth-ci-push-checks +name: zeth-ci-onpush-checks on: push: @@ -9,28 +9,26 @@ jobs: check-contracts: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive - - uses: actions/setup-node@v1 - with: - node-version: 10 - - name: Cache npm - uses: actions/cache@v1 + - uses: actions/setup-node@v2 with: - path: ~/.npm - key: check-contracts-npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} - # Cache ganache-cli/node_modules to avoid recompiling native code - - name: Cache depends/ganache-cli/node_modules - uses: actions/cache@v1 + node-version: '10' + - name: Cache npm (incl ganache-cli/node_modules) + uses: actions/cache@v2 with: - path: depends/ganache-cli/node_modules - key: check-contracts-ganache-node-modules-${{ runner.os }}-${{ hashFiles('depends/ganache-cli/package-lock.json') }} + path: | + ~/.npm + depends/ganache-cli/node_modules + key: check-contracts-npm-${{ hashFiles('**/package-lock.json') }}-${{ runner.os }} - name: Cache pip uses: actions/cache@v2 with: - path: ~/.cache/pip - key: check-contracts-pip-${{ runner.os }}-${{ hashFiles('client/setup.py') }} + path: | + ~/.cache/pip + ~/.solcx + key: check-contracts-pip-solcx-${{ hashFiles('**/setup.py') }}-${{ runner.os }} - name: Check Contracts run: scripts/ci check_contracts @@ -44,7 +42,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: check-client-pip-${{ runner.os }}-${{ hashFiles('client/setup.py') }} + key: check-client-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} - name: Check Client run: scripts/ci check_client From fb63fd81a44440bc4ad544d7d1dbe12c3844bfa2 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 12:58:27 +0000 Subject: [PATCH 12/18] ci: cache pip in code scanning job --- .github/workflows/code-scanning.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-scanning.yml b/.github/workflows/code-scanning.yml index 3583ed428..d13fb927e 100644 --- a/.github/workflows/code-scanning.yml +++ b/.github/workflows/code-scanning.yml @@ -46,6 +46,11 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.x' + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: codeql-py-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} - name: Custom dependencies installation run: | cd client @@ -63,4 +68,3 @@ jobs: setup-python-dependencies: false - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 - From ad4beee4ddc16bba5248254a482577606c75dcb8 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 13:04:14 +0000 Subject: [PATCH 13/18] ci: caching in onpush-build-ubuntu --- .github/workflows/onpush-build-ubuntu.yml | 48 +++++++++++++++++------ 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/onpush-build-ubuntu.yml b/.github/workflows/onpush-build-ubuntu.yml index 084a536d5..158971460 100644 --- a/.github/workflows/onpush-build-ubuntu.yml +++ b/.github/workflows/onpush-build-ubuntu.yml @@ -6,9 +6,9 @@ on: jobs: - # Job to build the grpc libraries. The grpc build directory is populated and - # cached so that all other jobs can mark this job as a prerequisite and just - # run `make install`. + # Job to build and cache the grpc libraries. The grpc build directory is + # populated and cached so that all other jobs can mark this job as a + # prerequisite and just run `make install`. # # NOTE: the version number here (in `key` and in script arguments) must be # kept in sync with the key used by the jobs. @@ -35,30 +35,56 @@ jobs: with: submodules: recursive - name: Cache grpc - uses: actions/cache@v1 + uses: actions/cache@v2 with: key: grpc-1.31.x-${{ runner.os }}-test path: depends/grpc - - name: Install grpc - run: scripts/install_grpc /usr v1.31.x depends/grpc + - name: Cache pip (for mpc tests) + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: build-linux-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} + - name: Install dependencies + run: | + scripts/install_grpc /usr v1.31.x depends/grpc + sudo apt install -y ccache - name: Execute - run: CI_CHECK_FORMAT=1 CI_CONFIG=${{ matrix.config }} scripts/ci build + run: CI_CHECK_FORMAT=1 CI_MPC_TESTS=1 CI_CONFIG=${{ matrix.config }} scripts/ci build build-linux-pghr13: runs-on: ubuntu-20.04 + needs: build-grpc steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: submodules: recursive + - name: Cache grpc + uses: actions/cache@v1 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Install dependencies + run: | + scripts/install_grpc /usr v1.31.x depends/grpc + sudo apt install -y ccache - name: Execute - run: CI_USE_DOCKER=1 CI_CONFIG=Release CI_ZKSNARK=PGHR13 scripts/ci build + run: CI_CONFIG=Release CI_ZKSNARK=PGHR13 scripts/ci build build-linux-bls12-377: runs-on: ubuntu-20.04 + needs: build-grpc steps: - uses: actions/checkout@v1 with: submodules: recursive + - name: Cache grpc + uses: actions/cache@v2 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Install dependencies + run: | + scripts/install_grpc /usr v1.31.x depends/grpc + sudo apt install -y ccache - name: Execute - run: CI_USE_DOCKER=1 CI_CONFIG=Release CI_CURVE=BLS12_377 scripts/ci build - + run: CI_CONFIG=Release CI_CURVE=BLS12_377 scripts/ci build From 93a8126efc4d9c49735b51469c2d63d6c5b2ea67 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Tue, 26 Jan 2021 13:11:39 +0000 Subject: [PATCH 14/18] ci: caching and mpc test in onpush-build-macos --- .github/workflows/onpush-build-macos.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/onpush-build-macos.yml b/.github/workflows/onpush-build-macos.yml index cecc82a9c..02c5107ef 100644 --- a/.github/workflows/onpush-build-macos.yml +++ b/.github/workflows/onpush-build-macos.yml @@ -38,7 +38,12 @@ jobs: with: key: submodules-${{ needs.submodules.outputs.commits }}-${{ runner.os }}-${{ matrix.config }} path: ~/Library/Caches/ccache + - name: Cache pip (for mpc tests) + uses: actions/cache@v2 + with: + path: ~/Library/Caches/pip + key: build-macos-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} - name: Install Dependencies run: brew install ${MACOS_BREW_PACKAGES} - name: Execute - run: CI_CONFIG=${{ matrix.config }} scripts/ci build + run: CI_MPC_TESTS=1 CI_CONFIG=${{ matrix.config }} scripts/ci build From 3e51d2ca7d6747b6cffc590cc1c5baf7275b0342 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Fri, 29 Jan 2021 17:31:56 +0000 Subject: [PATCH 15/18] ci: split the prover and integration tests --- .../workflows/onpullrequest-build-ubuntu.yml | 59 ++++++++++++++++--- scripts/ci | 30 ++++++++-- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/.github/workflows/onpullrequest-build-ubuntu.yml b/.github/workflows/onpullrequest-build-ubuntu.yml index 383a1589c..6010efaa0 100644 --- a/.github/workflows/onpullrequest-build-ubuntu.yml +++ b/.github/workflows/onpullrequest-build-ubuntu.yml @@ -37,7 +37,50 @@ jobs: git submodule sync echo "::set-output name=commits::"`git submodule status depends/libsodium | grep -oe '[0-9a-fA-F]\+' | head -c 8`-`git submodule status depends/libsnark | grep -oe '[0-9a-fA-F]\+' | head -c 8` - build-linux-full: + # Run the prover testing python scripts + prover-tests-linux: + runs-on: ubuntu-20.04 + needs: [onpr-build-grpc, onpr-submodules] + steps: + - uses: actions/checkout@v1 + with: + submodules: recursive + - uses: actions/setup-node@v1 + with: + node-version: 10 + - name: Cache grpc + uses: actions/cache@v2 + with: + key: grpc-1.31.x-${{ runner.os }}-test + path: depends/grpc + - name: Cache ccache + uses: actions/cache@v2 + with: + key: prover-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ runner.os }}-test + path: ~/.ccache + - name: Cache pip + uses: actions/cache@v2 + with: + path: | + ~/.cache/pip + ~/Library/Caches/pip + key: prover-tests-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} + - name: Cache npm + uses: actions/cache@v2 + with: + path: | + ~/.npm + depends/ganache-cli/node_modules + key: prover-tests-npm-${{ hashFiles('**/package-lock.json') }}-${{ runner.os }} + - name: Install dependencies + run: | + scripts/install_grpc /usr v1.31.x depends/grpc + sudo apt install -y ccache + - name: Execute + run: CI_CONFIG=Release CI_CURVE=ALT_BN128 CI_PROVER_TESTS=1 scripts/ci build + + # Run all unit tests and integration tests + integration-tests-linux: runs-on: ubuntu-20.04 needs: [onpr-build-grpc, onpr-submodules] strategy: @@ -55,25 +98,25 @@ jobs: with: key: grpc-1.31.x-${{ runner.os }}-test path: depends/grpc - # - name: Cache ccache - # uses: actions/cache@v2 - # with: - # key: submodules-${{ needs.onpr-submodules.outputs.commits }}-${{ runner.os }}-${{ matrix.curve }} - # path: ~/.ccache + - name: Cache ccache + uses: actions/cache@v2 + with: + key: integration-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test + path: ~/.ccache - name: Cache pip uses: actions/cache@v2 with: path: | ~/.cache/pip ~/Library/Caches/pip - key: build-linux-full-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} + key: integration-tests-pip-${{ hashFiles('**/setup.py') }}-${{ runner.os }} - name: Cache npm uses: actions/cache@v2 with: path: | ~/.npm depends/ganache-cli/node_modules - key: build-linux-full-npm-${{ hashFiles('**/package-lock.json') }}-${{ runner.os }} + key: integration-tests-npm-${{ hashFiles('**/package-lock.json') }}-${{ runner.os }} - name: Install dependencies run: | scripts/install_grpc /usr v1.31.x depends/grpc diff --git a/scripts/ci b/scripts/ci index a5e113e1b..85a284f13 100755 --- a/scripts/ci +++ b/scripts/ci @@ -223,7 +223,7 @@ function mpc_tests() { scripts/test_mpc_server_phase2 } -function integration_tests() { +function prover_tests() { # Native code is built. Setup client and ganache. _setup_ganache @@ -233,13 +233,30 @@ function integration_tests() { _start_ganache _start_prover_server - # Enter client env and run client test script + # Enter client env and run prover test scripts . client/env/bin/activate - - ./scripts/test_zeth_cli python -m test_commands.test_ether_mixing GROTH16 python -m test_commands.test_erc_token_mixing GROTH16 + deactivate + # Stop servers + _stop_prover_server + _stop_ganache +} + +function integration_tests() { + + # Native code is built. Setup client and ganache. + _setup_ganache + _setup_client + + # Start servers + _start_ganache + _start_prover_server + + # Enter client env and run client test script + . client/env/bin/activate + ./scripts/test_zeth_cli deactivate # Stop servers @@ -294,6 +311,10 @@ function build() { mpc_tests fi + if [ "${CI_PROVER_TESTS}" == "1" ] ; then + prover_tests + fi + if [ "${CI_INTEGRATION_TESTS}" == "1" ] ; then integration_tests fi @@ -354,6 +375,7 @@ echo CI_CHECK_FORMAT=${CI_CHECK_FORMAT} echo CI_EVENT_NAME=${CI_EVENT_NAME} echo CI_FULL_TEST=${CI_FULL_TESTS} echo CI_MPC_TESTS=${CI_MPC_TESTS} +echo CI_PROVER_TESTS=${CI_PROVER_TESTS} echo CI_INTEGRATION_TESTS=${CI_INTEGRATION_TESTS} if [ "${CI_CHECK_FORMAT}" == "1" ] ; then From 69704157da2342441902a984b94de3589c600b94 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Fri, 29 Jan 2021 18:39:22 +0000 Subject: [PATCH 16/18] ci: disable ccache on linux --- .github/workflows/onpullrequest-build-ubuntu.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/onpullrequest-build-ubuntu.yml b/.github/workflows/onpullrequest-build-ubuntu.yml index 6010efaa0..b5c0eff43 100644 --- a/.github/workflows/onpullrequest-build-ubuntu.yml +++ b/.github/workflows/onpullrequest-build-ubuntu.yml @@ -98,11 +98,13 @@ jobs: with: key: grpc-1.31.x-${{ runner.os }}-test path: depends/grpc - - name: Cache ccache - uses: actions/cache@v2 - with: - key: integration-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test - path: ~/.ccache + # ccache in this job seems to make the tests crash occasionally. Disabling + # until the cause is understood. + # - name: Cache ccache + # uses: actions/cache@v2 + # with: + # key: integration-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test + # path: ~/.ccache - name: Cache pip uses: actions/cache@v2 with: From 3de33495c7be064a7f1476f63913013dbc1fa977 Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Mon, 1 Feb 2021 10:46:57 +0000 Subject: [PATCH 17/18] ci: enable prover tests over all curves --- .github/workflows/onpullrequest-build-ubuntu.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/onpullrequest-build-ubuntu.yml b/.github/workflows/onpullrequest-build-ubuntu.yml index b5c0eff43..e5af31eb5 100644 --- a/.github/workflows/onpullrequest-build-ubuntu.yml +++ b/.github/workflows/onpullrequest-build-ubuntu.yml @@ -41,6 +41,9 @@ jobs: prover-tests-linux: runs-on: ubuntu-20.04 needs: [onpr-build-grpc, onpr-submodules] + strategy: + matrix: + curve: [ BLS12_377, ALT_BN128 ] steps: - uses: actions/checkout@v1 with: @@ -56,7 +59,7 @@ jobs: - name: Cache ccache uses: actions/cache@v2 with: - key: prover-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ runner.os }}-test + key: prover-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test path: ~/.ccache - name: Cache pip uses: actions/cache@v2 @@ -77,7 +80,7 @@ jobs: scripts/install_grpc /usr v1.31.x depends/grpc sudo apt install -y ccache - name: Execute - run: CI_CONFIG=Release CI_CURVE=ALT_BN128 CI_PROVER_TESTS=1 scripts/ci build + run: CI_CONFIG=Release CI_CURVE=${{ matrix.curve }} CI_PROVER_TESTS=1 scripts/ci build # Run all unit tests and integration tests integration-tests-linux: From 18bda7815a1417a278197cca46b7557955c64f0d Mon Sep 17 00:00:00 2001 From: Duncan Tebbs Date: Thu, 4 Feb 2021 10:05:34 +0000 Subject: [PATCH 18/18] ci: cosmetic script tweaks --- .github/workflows/onpullrequest-build-ubuntu.yml | 10 +++++----- .github/workflows/onpush-build-macos.yml | 2 +- .github/workflows/onpush-build-ubuntu.yml | 10 +++++----- scripts/install_grpc | 9 +++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/onpullrequest-build-ubuntu.yml b/.github/workflows/onpullrequest-build-ubuntu.yml index e5af31eb5..829d4ebed 100644 --- a/.github/workflows/onpullrequest-build-ubuntu.yml +++ b/.github/workflows/onpullrequest-build-ubuntu.yml @@ -19,7 +19,7 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Build grpc run: if ! [ -d depends/grpc ] ; then scripts/install_grpc /usr v1.31.x depends/grpc ; fi @@ -54,12 +54,12 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Cache ccache uses: actions/cache@v2 with: - key: prover-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test + key: prover-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }} path: ~/.ccache - name: Cache pip uses: actions/cache@v2 @@ -99,14 +99,14 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc # ccache in this job seems to make the tests crash occasionally. Disabling # until the cause is understood. # - name: Cache ccache # uses: actions/cache@v2 # with: - # key: integration-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }}-test + # key: integration-tests-ccache-${{ needs.onpr-submodules.outputs.commits }}-${{ matrix.curve }}-${{ runner.os }} # path: ~/.ccache - name: Cache pip uses: actions/cache@v2 diff --git a/.github/workflows/onpush-build-macos.yml b/.github/workflows/onpush-build-macos.yml index 02c5107ef..7b86fd776 100644 --- a/.github/workflows/onpush-build-macos.yml +++ b/.github/workflows/onpush-build-macos.yml @@ -34,7 +34,7 @@ jobs: with: submodules: recursive - name: Cache ccache - uses: actions/cache@v1 + uses: actions/cache@v2 with: key: submodules-${{ needs.submodules.outputs.commits }}-${{ runner.os }}-${{ matrix.config }} path: ~/Library/Caches/ccache diff --git a/.github/workflows/onpush-build-ubuntu.yml b/.github/workflows/onpush-build-ubuntu.yml index 158971460..1c711ff8a 100644 --- a/.github/workflows/onpush-build-ubuntu.yml +++ b/.github/workflows/onpush-build-ubuntu.yml @@ -19,7 +19,7 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Build grpc run: if ! [ -d depends/grpc ] ; then scripts/install_grpc /usr v1.31.x depends/grpc ; fi @@ -37,7 +37,7 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Cache pip (for mpc tests) uses: actions/cache@v2 @@ -59,9 +59,9 @@ jobs: with: submodules: recursive - name: Cache grpc - uses: actions/cache@v1 + uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Install dependencies run: | @@ -80,7 +80,7 @@ jobs: - name: Cache grpc uses: actions/cache@v2 with: - key: grpc-1.31.x-${{ runner.os }}-test + key: grpc-1.31.x-${{ runner.os }} path: depends/grpc - name: Install dependencies run: | diff --git a/scripts/install_grpc b/scripts/install_grpc index 085ba1e75..1dfbcffe8 100755 --- a/scripts/install_grpc +++ b/scripts/install_grpc @@ -3,7 +3,8 @@ # This script is only intended to run on the CI machines. Not for local # development. -if [ "" == "$1" ] || [ "" == "$2" ] || [ "" == "$3" ] ; then +# Expect 3 arguments, all non-empty. +if [ "$#" -ne 3 ] || [ "" == "$1" ] || [ "" == "$2" ] || [ "" == "$3" ] ; then echo "error: invalid arguments" echo "Usage: $0 " echo "" @@ -34,14 +35,14 @@ mkdir -p ${BUILD_DIR} pushd ${BUILD_DIR} # Clone repo and submodules (if DO_BUILD == 1) - if [ "1" == "${DO_BUILD}" ] ; then + if [ "${DO_BUILD}" == "1" ] ; then git clone --depth 1 -b ${VERSION} https://github.com/grpc/grpc . git submodule update --depth 1 --init --recursive fi # Install protobuf pushd third_party/protobuf - if [ "1" == "${DO_BUILD}" ] ; then + if [ "${DO_BUILD}" == "1" ] ; then [ -e ./configure ] || ./autogen.sh DIST_LANG=cpp ./configure --prefix ${INSTALL_DIR} make -j $(($(nproc)+1)) @@ -52,7 +53,7 @@ pushd ${BUILD_DIR} # Install grpc mkdir -p build pushd build - if [ "1" == "${DO_BUILD}" ] ; then + if [ "${DO_BUILD}" == "1" ] ; then cmake \ -DCMAKE_PREFIX_PATH=${INSTALL_DIR} \ -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \