From d72169dba97bf2e5b30a168d2e073eb627fa44dd Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 14:52:40 +0100 Subject: [PATCH 01/13] use workflows --- .circleci/config.yml | 98 ++++++++++++++++++++++++++++++++++------- Dockerfile | 52 +++++++++++----------- scripts/publish_book.sh | 18 -------- scripts/release.sh | 34 ++++++++++++++ 4 files changed, 143 insertions(+), 59 deletions(-) delete mode 100755 scripts/publish_book.sh create mode 100755 scripts/release.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 890dc501..9dd4fe72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,9 +18,36 @@ jobs: - run: name: Check format command: rustup component add rustfmt-preview; cargo fmt --all -- --check - # - run: - # name: Download wasm32 target - # command: rustup target add wasm32-unknown-unknown + - run: + name: Build libsnark + command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh + - run: + name: Build + command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" ./build.sh + - save_cache: + paths: + - /usr/local/cargo/registry + - target/debug/.fingerprint + - target/debug/build + - target/debug/deps + key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + test: + docker: + - image: rustlang/rust:nightly-slim + steps: + - checkout + - run: + name: Version information + command: rustc --version; cargo --version; rustup --version + - run: + name: Calculate dependencies + command: cargo generate-lockfile + - restore_cache: + keys: + - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - run: + name: Check format + command: rustup component add rustfmt-preview; cargo fmt --all -- --check - run: name: Build libsnark command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh @@ -30,22 +57,63 @@ jobs: - run: name: Run tests command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --test-threads=1 - # - run: - # name: Run tests with WASM enabled - # command: cd zokrates_core && cargo test --release --features wasm -- --test-threads=1 - run: name: Run integration tests command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --ignored - run: name: Generate code coverage report command: ./scripts/cov.sh + wasm_test: + docker: + - image: rustlang/rust:nightly-slim + steps: + - checkout - run: - name: Publish book - command: ./scripts/publish_book.sh - - save_cache: - paths: - - /usr/local/cargo/registry - - target/debug/.fingerprint - - target/debug/build - - target/debug/deps - key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + name: Version information + command: rustc --version; cargo --version; rustup --version + - run: + name: Calculate dependencies + command: cargo generate-lockfile + - restore_cache: + keys: + - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - run: + name: Download wasm32 target + command: rustup target add wasm32-unknown-unknown + - run: + name: Build libsnark + command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh + - run: + name: Run tests with WASM enabled + command: cd zokrates_core && cargo test --release --features wasm -- --test-threads=1 + deploy: + docker: + - image: circleci/python + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Release + command: ./scripts/release.sh + +workflows: + version: 2 + build-test-and-deploy: + jobs: + - build + - test + - wasm_test + - integration_test + - deploy: + # filters: + # branches: + # only: + # - master + requires: + - build + - test + - wasm_test + - integration_test + + diff --git a/Dockerfile b/Dockerfile index 243beed8..4d92a966 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,24 +10,24 @@ ENV LIBSNARK_SOURCE_PATH=/home/zokrates/libsnark-$LIBSNARK_COMMIT ENV WITH_LIBSNARK=1 ENV ZOKRATES_HOME=/home/zokrates/.zokrates -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - build-essential \ - cmake \ - curl \ - libboost-dev \ - libboost-program-options-dev \ - libgmp3-dev \ - libprocps-dev \ - libssl-dev \ - pkg-config \ - python-markdown \ - git \ - && rm -rf /var/lib/apt/lists/* \ - && git clone https://github.com/scipr-lab/libsnark.git $LIBSNARK_SOURCE_PATH \ - && git -C $LIBSNARK_SOURCE_PATH checkout $LIBSNARK_COMMIT \ - && git -C $LIBSNARK_SOURCE_PATH submodule update --init --recursive \ - && chown -R zokrates:zokrates $LIBSNARK_SOURCE_PATH +# RUN apt-get update && apt-get install -y --no-install-recommends \ +# ca-certificates \ +# build-essential \ +# cmake \ +# curl \ +# libboost-dev \ +# libboost-program-options-dev \ +# libgmp3-dev \ +# libprocps-dev \ +# libssl-dev \ +# pkg-config \ +# python-markdown \ +# git \ +# && rm -rf /var/lib/apt/lists/* \ +# && git clone https://github.com/scipr-lab/libsnark.git $LIBSNARK_SOURCE_PATH \ +# && git -C $LIBSNARK_SOURCE_PATH checkout $LIBSNARK_COMMIT \ +# && git -C $LIBSNARK_SOURCE_PATH submodule update --init --recursive \ +# && chown -R zokrates:zokrates $LIBSNARK_SOURCE_PATH USER zokrates @@ -37,11 +37,11 @@ COPY --chown=zokrates:zokrates . src RUN mkdir $ZOKRATES_HOME -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y \ - && export PATH=/home/zokrates/.cargo/bin:$PATH \ - && (cd src;./build_release.sh) \ - && mv ./src/target/release/zokrates . \ - && mv ./src/zokrates_cli/examples . \ - && mv ./src/stdlib/* $ZOKRATES_HOME \ - && rustup self uninstall -y \ - && rm -rf $LIBSNARK_SOURCE_PATH src \ No newline at end of file +# RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y \ +# && export PATH=/home/zokrates/.cargo/bin:$PATH \ +# && (cd src;./build_release.sh) \ +# && mv ./src/target/release/zokrates . \ +# && mv ./src/zokrates_cli/examples . \ +# && mv ./src/stdlib/* $ZOKRATES_HOME \ +# && rustup self uninstall -y \ +# && rm -rf $LIBSNARK_SOURCE_PATH src \ No newline at end of file diff --git a/scripts/publish_book.sh b/scripts/publish_book.sh deleted file mode 100755 index 40957469..00000000 --- a/scripts/publish_book.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Exit if any subcommand fails -set -e - -if [ "$CIRCLE_BRANCH" == "master" ]; then - apt-get update - apt-get -qq install git python-minimal - python --version - cargo install mdbook - cd zokrates_book && mdbook build - git config --global user.email "stefan.deml+zokratesbot@decentriq.ch" - git clone https://github.com/Zokrates/zokrates.github.io.git - git clone https://github.com/davisp/ghp-import.git - cd zokrates.github.io - TAG=$(cat ../zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed -e 's/"//g') && echo $TAG - ../ghp-import/ghp_import.py -n -p -f -m "Documentation upload. Version: $TAG" -b "master" -r https://zokratesbot:"$GH_TOKEN"@github.com/Zokrates/zokrates.github.io.git ../book - echo "Published book" -fi - diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 00000000..c096054f --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,34 @@ +# Exit if any subcommand fails +set -e + +# Get tag +TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed -e 's/"//g') && echo $TAG + +# Release on Github +git tag $TAG +# git push origin $TAG + +# Release on Dockerhub + +# Build +docker build -t zokrates . + +## Release under `latest` tag +docker tag zokrates:latest zokrates/zokrates:latest +#docker push zokrates/zokrates:latest + +## Release under $TAG tag +docker tag zokrates:latest zokrates/zokrates:$TAG +#docker push zokrates/zokrates:$TAG + +# Publish book +python --version +cargo install mdbook +cd zokrates_book && mdbook build +git config --global user.email "stefan.deml+zokratesbot@decentriq.ch" +git clone https://github.com/Zokrates/zokrates.github.io.git +git clone https://github.com/davisp/ghp-import.git +cd zokrates.github.io +#../ghp-import/ghp_import.py -n -p -f -m "Documentation upload. Version: $TAG" -b "master" -r https://zokratesbot:"$GH_TOKEN"@github.com/Zokrates/zokrates.github.io.git ../book +echo "Published book" + From ddaa961b89481e8c3403c48944ec0df2dbf5cc5c Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 14:55:13 +0100 Subject: [PATCH 02/13] add integration_test job --- .circleci/config.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9dd4fe72..c786e343 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,9 +57,6 @@ jobs: - run: name: Run tests command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --test-threads=1 - - run: - name: Run integration tests - command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --ignored - run: name: Generate code coverage report command: ./scripts/cov.sh @@ -86,6 +83,26 @@ jobs: - run: name: Run tests with WASM enabled command: cd zokrates_core && cargo test --release --features wasm -- --test-threads=1 + integration_test: + docker: + - image: rustlang/rust:nightly-slim + steps: + - checkout + - run: + name: Version information + command: rustc --version; cargo --version; rustup --version + - run: + name: Calculate dependencies + command: cargo generate-lockfile + - restore_cache: + keys: + - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - run: + name: Build libsnark + command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh + - run: + name: Run integration tests + command: WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --ignored deploy: docker: - image: circleci/python From c594886596ad5a20f8ec53181fc18f4db375539f Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 15:02:30 +0100 Subject: [PATCH 03/13] allow wasm tests to fail --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c786e343..58a56920 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -130,7 +130,6 @@ workflows: requires: - build - test - - wasm_test - integration_test From 3bc6ecae6aa337795475bf5fd8393a43562032d1 Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 19:52:00 +0100 Subject: [PATCH 04/13] add docker login, get mdbook from tar --- .circleci/config.yml | 4 ++-- scripts/release.sh | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58a56920..c3c16264 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,8 +108,8 @@ jobs: - image: circleci/python steps: - checkout - - setup_remote_docker: - docker_layer_caching: true + # - setup_remote_docker: + # docker_layer_caching: true - run: name: Release command: ./scripts/release.sh diff --git a/scripts/release.sh b/scripts/release.sh index c096054f..19e12b31 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,6 +1,8 @@ # Exit if any subcommand fails set -e +ls zokrates_book + # Get tag TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed -e 's/"//g') && echo $TAG @@ -8,23 +10,35 @@ TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed - git tag $TAG # git push origin $TAG -# Release on Dockerhub +## Release on Dockerhub -# Build +## Build docker build -t zokrates . +## Log into Dockerhub +docker login -u $DOCKER_USER -p $DOCKER_PASS + ## Release under `latest` tag docker tag zokrates:latest zokrates/zokrates:latest -#docker push zokrates/zokrates:latest +# docker push zokrates/zokrates:latest +echo "Published zokrates/zokrates:latest" ## Release under $TAG tag docker tag zokrates:latest zokrates/zokrates:$TAG -#docker push zokrates/zokrates:$TAG +# docker push zokrates/zokrates:$TAG +echo "Published zokrates/zokrates:$TAG" # Publish book -python --version -cargo install mdbook -cd zokrates_book && mdbook build +MDBOOK_SOURCE="https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.1/mdbook-v0.2.1-x86_64-unknown-linux-gnu.tar.gz" + +cd zokrates_book + +## Install mdbook +wget -qO- $MDBOOK_SOURCE | tar xvz + +## Build book +./mdbook build + git config --global user.email "stefan.deml+zokratesbot@decentriq.ch" git clone https://github.com/Zokrates/zokrates.github.io.git git clone https://github.com/davisp/ghp-import.git From 7a14e0025f638bb3be18b529fd0946f4bbc98720 Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 19:55:09 +0100 Subject: [PATCH 05/13] enable docker remote --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3c16264..58a56920 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,8 +108,8 @@ jobs: - image: circleci/python steps: - checkout - # - setup_remote_docker: - # docker_layer_caching: true + - setup_remote_docker: + docker_layer_caching: true - run: name: Release command: ./scripts/release.sh From 08cda8ed33b0af41e3462edbdc5599284264382f Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:05:43 +0100 Subject: [PATCH 06/13] remove useless checks, rename env var --- .circleci/config.yml | 6 ------ scripts/release.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 58a56920..6baf8f9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,9 +15,6 @@ jobs: - restore_cache: keys: - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} - - run: - name: Check format - command: rustup component add rustfmt-preview; cargo fmt --all -- --check - run: name: Build libsnark command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh @@ -77,9 +74,6 @@ jobs: - run: name: Download wasm32 target command: rustup target add wasm32-unknown-unknown - - run: - name: Build libsnark - command: LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh - run: name: Run tests with WASM enabled command: cd zokrates_core && cargo test --release --features wasm -- --test-threads=1 diff --git a/scripts/release.sh b/scripts/release.sh index 19e12b31..81ef47ab 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,7 +16,7 @@ git tag $TAG docker build -t zokrates . ## Log into Dockerhub -docker login -u $DOCKER_USER -p $DOCKER_PASS +docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS ## Release under `latest` tag docker tag zokrates:latest zokrates/zokrates:latest From 4a58229dc6bafd6c4262aed50d93537e12c4c322 Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:14:30 +0100 Subject: [PATCH 07/13] pass pw through stdin to silence warning --- scripts/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index 81ef47ab..ed045ffd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,7 +16,7 @@ git tag $TAG docker build -t zokrates . ## Log into Dockerhub -docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS +echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USER --password-stdin ## Release under `latest` tag docker tag zokrates:latest zokrates/zokrates:latest From 231d7611cb2aab334e4c0ae5e70553eb541eb45a Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:22:40 +0100 Subject: [PATCH 08/13] clean, move bot addr to env, silence commands --- scripts/release.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index ed045ffd..32f0d779 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,8 +1,6 @@ # Exit if any subcommand fails set -e -ls zokrates_book - # Get tag TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed -e 's/"//g') && echo $TAG @@ -37,11 +35,11 @@ cd zokrates_book wget -qO- $MDBOOK_SOURCE | tar xvz ## Build book -./mdbook build +./mdbook build > /dev/null -git config --global user.email "stefan.deml+zokratesbot@decentriq.ch" -git clone https://github.com/Zokrates/zokrates.github.io.git -git clone https://github.com/davisp/ghp-import.git +git config --global user.email $GH_USER +git clone https://github.com/Zokrates/zokrates.github.io.git > /dev/null +git clone https://github.com/davisp/ghp-import.git > /dev/null cd zokrates.github.io #../ghp-import/ghp_import.py -n -p -f -m "Documentation upload. Version: $TAG" -b "master" -r https://zokratesbot:"$GH_TOKEN"@github.com/Zokrates/zokrates.github.io.git ../book echo "Published book" From 14ea912ea2831d33e10224ad883c2d8420dbf49b Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:35:19 +0100 Subject: [PATCH 09/13] revert dockerfile to original, enable master filter, enable push to dockerhub, git tag and mdbook --- .circleci/config.yml | 8 +++---- Dockerfile | 52 ++++++++++++++++++++++---------------------- scripts/release.sh | 21 ++++++++++-------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6baf8f9a..730e5d5f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,10 +117,10 @@ workflows: - wasm_test - integration_test - deploy: - # filters: - # branches: - # only: - # - master + filters: + branches: + only: + - master requires: - build - test diff --git a/Dockerfile b/Dockerfile index 4d92a966..243beed8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,24 +10,24 @@ ENV LIBSNARK_SOURCE_PATH=/home/zokrates/libsnark-$LIBSNARK_COMMIT ENV WITH_LIBSNARK=1 ENV ZOKRATES_HOME=/home/zokrates/.zokrates -# RUN apt-get update && apt-get install -y --no-install-recommends \ -# ca-certificates \ -# build-essential \ -# cmake \ -# curl \ -# libboost-dev \ -# libboost-program-options-dev \ -# libgmp3-dev \ -# libprocps-dev \ -# libssl-dev \ -# pkg-config \ -# python-markdown \ -# git \ -# && rm -rf /var/lib/apt/lists/* \ -# && git clone https://github.com/scipr-lab/libsnark.git $LIBSNARK_SOURCE_PATH \ -# && git -C $LIBSNARK_SOURCE_PATH checkout $LIBSNARK_COMMIT \ -# && git -C $LIBSNARK_SOURCE_PATH submodule update --init --recursive \ -# && chown -R zokrates:zokrates $LIBSNARK_SOURCE_PATH +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + build-essential \ + cmake \ + curl \ + libboost-dev \ + libboost-program-options-dev \ + libgmp3-dev \ + libprocps-dev \ + libssl-dev \ + pkg-config \ + python-markdown \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && git clone https://github.com/scipr-lab/libsnark.git $LIBSNARK_SOURCE_PATH \ + && git -C $LIBSNARK_SOURCE_PATH checkout $LIBSNARK_COMMIT \ + && git -C $LIBSNARK_SOURCE_PATH submodule update --init --recursive \ + && chown -R zokrates:zokrates $LIBSNARK_SOURCE_PATH USER zokrates @@ -37,11 +37,11 @@ COPY --chown=zokrates:zokrates . src RUN mkdir $ZOKRATES_HOME -# RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y \ -# && export PATH=/home/zokrates/.cargo/bin:$PATH \ -# && (cd src;./build_release.sh) \ -# && mv ./src/target/release/zokrates . \ -# && mv ./src/zokrates_cli/examples . \ -# && mv ./src/stdlib/* $ZOKRATES_HOME \ -# && rustup self uninstall -y \ -# && rm -rf $LIBSNARK_SOURCE_PATH src \ No newline at end of file +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y \ + && export PATH=/home/zokrates/.cargo/bin:$PATH \ + && (cd src;./build_release.sh) \ + && mv ./src/target/release/zokrates . \ + && mv ./src/zokrates_cli/examples . \ + && mv ./src/stdlib/* $ZOKRATES_HOME \ + && rustup self uninstall -y \ + && rm -rf $LIBSNARK_SOURCE_PATH src \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index 32f0d779..e8ed0a72 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -4,11 +4,14 @@ set -e # Get tag TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed -e 's/"//g') && echo $TAG +# Use zokrates github bot +git config --global user.email $GH_USER + # Release on Github git tag $TAG -# git push origin $TAG +git push origin $TAG -## Release on Dockerhub +# Release on Dockerhub ## Build docker build -t zokrates . @@ -18,12 +21,12 @@ echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USER --password-stdin ## Release under `latest` tag docker tag zokrates:latest zokrates/zokrates:latest -# docker push zokrates/zokrates:latest +docker push zokrates/zokrates:latest echo "Published zokrates/zokrates:latest" ## Release under $TAG tag docker tag zokrates:latest zokrates/zokrates:$TAG -# docker push zokrates/zokrates:$TAG +docker push zokrates/zokrates:$TAG echo "Published zokrates/zokrates:$TAG" # Publish book @@ -35,12 +38,12 @@ cd zokrates_book wget -qO- $MDBOOK_SOURCE | tar xvz ## Build book -./mdbook build > /dev/null +./mdbook build -git config --global user.email $GH_USER -git clone https://github.com/Zokrates/zokrates.github.io.git > /dev/null -git clone https://github.com/davisp/ghp-import.git > /dev/null +## Deploy to github.io +git clone https://github.com/Zokrates/zokrates.github.io.git +git clone https://github.com/davisp/ghp-import.git cd zokrates.github.io -#../ghp-import/ghp_import.py -n -p -f -m "Documentation upload. Version: $TAG" -b "master" -r https://zokratesbot:"$GH_TOKEN"@github.com/Zokrates/zokrates.github.io.git ../book +../ghp-import/ghp_import.py -n -p -f -m "Documentation upload. Version: $TAG" -b "master" -r https://zokratesbot:"$GH_TOKEN"@github.com/Zokrates/zokrates.github.io.git ../book echo "Published book" From feca495f7153dd213638a6b275a57da2da4d5ade Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:44:12 +0100 Subject: [PATCH 10/13] clean env --- scripts/release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index e8ed0a72..b325c671 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -30,12 +30,12 @@ docker push zokrates/zokrates:$TAG echo "Published zokrates/zokrates:$TAG" # Publish book -MDBOOK_SOURCE="https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.1/mdbook-v0.2.1-x86_64-unknown-linux-gnu.tar.gz" +MDBOOK_TAR="https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.1/mdbook-v0.2.1-x86_64-unknown-linux-gnu.tar.gz" cd zokrates_book ## Install mdbook -wget -qO- $MDBOOK_SOURCE | tar xvz +wget -qO- $MDBOOK_TAR | tar xvz ## Build book ./mdbook build From 250c849a7608060e0b0f6591e4fa7e20acc6b7a1 Mon Sep 17 00:00:00 2001 From: schaeff Date: Mon, 28 Jan 2019 20:45:36 +0100 Subject: [PATCH 11/13] first build docker, then tag gh --- scripts/release.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index b325c671..5453d2a1 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -7,10 +7,6 @@ TAG=$(cat ./zokrates_cli/Cargo.toml | grep '^version' | awk '{print $3}' | sed - # Use zokrates github bot git config --global user.email $GH_USER -# Release on Github -git tag $TAG -git push origin $TAG - # Release on Dockerhub ## Build @@ -29,6 +25,10 @@ docker tag zokrates:latest zokrates/zokrates:$TAG docker push zokrates/zokrates:$TAG echo "Published zokrates/zokrates:$TAG" +# Release on Github +git tag $TAG +git push origin $TAG + # Publish book MDBOOK_TAR="https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.1/mdbook-v0.2.1-x86_64-unknown-linux-gnu.tar.gz" From f9cce777f0bbef3b0469e87cc69d6fc98755688d Mon Sep 17 00:00:00 2001 From: schaeff Date: Tue, 29 Jan 2019 11:24:16 +0100 Subject: [PATCH 12/13] add doc, example and failing test for out of scope --- shadow.code | 0 zokrates_book/src/concepts/variables.md | 24 ++++++++++++++++++- zokrates_cli/examples/book/for_scope.code | 7 ++++++ .../examples/book/function_scope.code | 7 ++++++ zokrates_cli/examples/book/no_shadowing.code | 7 ++++++ .../examples/error/out_of_for_scope.code | 4 ++++ ...licate_declaration.code => shadowing.code} | 2 +- 7 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 shadow.code create mode 100644 zokrates_cli/examples/book/for_scope.code create mode 100644 zokrates_cli/examples/book/function_scope.code create mode 100644 zokrates_cli/examples/book/no_shadowing.code create mode 100644 zokrates_cli/examples/error/out_of_for_scope.code rename zokrates_cli/examples/error/{duplicate_declaration.code => shadowing.code} (86%) diff --git a/shadow.code b/shadow.code new file mode 100644 index 00000000..e69de29b diff --git a/zokrates_book/src/concepts/variables.md b/zokrates_book/src/concepts/variables.md index 645619ba..dab25416 100644 --- a/zokrates_book/src/concepts/variables.md +++ b/zokrates_book/src/concepts/variables.md @@ -1,4 +1,26 @@ ## Variables Variables can have any name which does not start with a number. Underscores are not allowed in variable names. -Variables are mutable, and always passed by values to functions. \ No newline at end of file +Variables are mutable, and always passed by value to functions. + +### Shadowing + +Shadowing is not allowed. +```zokrates +{{#include ../../../zokrates_cli/examples/book/no_shadowing.code}} +``` + +### Scope + +#### Function + +Functions have their own scope +```zokrates +{{#include ../../../zokrates_cli/examples/book/function_scope.code}} +``` + +#### For-loop +For-loops have their own scope +```zokrates +{{#include ../../../zokrates_cli/examples/book/for_scope.code}} +``` \ No newline at end of file diff --git a/zokrates_cli/examples/book/for_scope.code b/zokrates_cli/examples/book/for_scope.code new file mode 100644 index 00000000..50655615 --- /dev/null +++ b/zokrates_cli/examples/book/for_scope.code @@ -0,0 +1,7 @@ +def main() -> (field): + field a = 0 + for field i in 0..5 do + a = a + i + endfor + // return i <- not allowed + return a \ No newline at end of file diff --git a/zokrates_cli/examples/book/function_scope.code b/zokrates_cli/examples/book/function_scope.code new file mode 100644 index 00000000..d1f060f7 --- /dev/null +++ b/zokrates_cli/examples/book/function_scope.code @@ -0,0 +1,7 @@ +def foo() -> (field): + // return myGlobal <- not allowed + return 42 + +def main() -> (field): + field myGlobal = 42 + return foo() \ No newline at end of file diff --git a/zokrates_cli/examples/book/no_shadowing.code b/zokrates_cli/examples/book/no_shadowing.code new file mode 100644 index 00000000..8d852911 --- /dev/null +++ b/zokrates_cli/examples/book/no_shadowing.code @@ -0,0 +1,7 @@ +def main() -> (field): + field a = 2 + // field a = 3 <- not allowed + for field i in 0..5 do + // field a = 7 <- not allowed + endfor + return a \ No newline at end of file diff --git a/zokrates_cli/examples/error/out_of_for_scope.code b/zokrates_cli/examples/error/out_of_for_scope.code new file mode 100644 index 00000000..b005b833 --- /dev/null +++ b/zokrates_cli/examples/error/out_of_for_scope.code @@ -0,0 +1,4 @@ +def main() -> (field): + for field i in 0..5 do + endfor + return i \ No newline at end of file diff --git a/zokrates_cli/examples/error/duplicate_declaration.code b/zokrates_cli/examples/error/shadowing.code similarity index 86% rename from zokrates_cli/examples/error/duplicate_declaration.code rename to zokrates_cli/examples/error/shadowing.code index 919eb2a0..d3345294 100644 --- a/zokrates_cli/examples/error/duplicate_declaration.code +++ b/zokrates_cli/examples/error/shadowing.code @@ -2,6 +2,6 @@ def foo() -> (field): return 1 def main() -> (field): - bool a + field a = 2 field a = foo() return 1 \ No newline at end of file From 761d4b5904585f655693e36a26c586862f946196 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Wed, 30 Jan 2019 08:59:05 -0800 Subject: [PATCH 13/13] Remove the tools directory --- tools/zokrates_wasm_plugin/Cargo.toml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 tools/zokrates_wasm_plugin/Cargo.toml diff --git a/tools/zokrates_wasm_plugin/Cargo.toml b/tools/zokrates_wasm_plugin/Cargo.toml deleted file mode 100644 index d7c304cf..00000000 --- a/tools/zokrates_wasm_plugin/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "zokrates_wasm_plugin" -version = "0.1.0" -authors = ["Guillaume Ballet "] -edition = "2018" - -[dependencies] -parity-wasm = "0.35.3" -clap = "2.32.0" \ No newline at end of file