Merge branch 'develop' of github.com:JacobEberhardt/ZoKrates into short-field-display
This commit is contained in:
commit
a708e5ba07
11 changed files with 194 additions and 47 deletions
|
@ -2,6 +2,33 @@ version: 2
|
|||
|
||||
jobs:
|
||||
build:
|
||||
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: 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:
|
||||
|
@ -18,9 +45,6 @@ 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
|
||||
|
@ -30,22 +54,76 @@ 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: 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
|
||||
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
|
||||
- integration_test
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
49
scripts/release.sh
Executable file
49
scripts/release.sh
Executable file
|
@ -0,0 +1,49 @@
|
|||
# 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
|
||||
|
||||
# Use zokrates github bot
|
||||
git config --global user.email $GH_USER
|
||||
|
||||
# Release on Dockerhub
|
||||
|
||||
## Build
|
||||
docker build -t zokrates .
|
||||
|
||||
## Log into Dockerhub
|
||||
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
|
||||
echo "Published zokrates/zokrates:latest"
|
||||
|
||||
## Release under $TAG tag
|
||||
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"
|
||||
|
||||
cd zokrates_book
|
||||
|
||||
## Install mdbook
|
||||
wget -qO- $MDBOOK_TAR | tar xvz
|
||||
|
||||
## Build book
|
||||
./mdbook build
|
||||
|
||||
## 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
|
||||
echo "Published book"
|
||||
|
0
shadow.code
Normal file
0
shadow.code
Normal file
|
@ -1,9 +0,0 @@
|
|||
[package]
|
||||
name = "zokrates_wasm_plugin"
|
||||
version = "0.1.0"
|
||||
authors = ["Guillaume Ballet <gballet@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = "0.35.3"
|
||||
clap = "2.32.0"
|
|
@ -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.
|
||||
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}}
|
||||
```
|
7
zokrates_cli/examples/book/for_scope.code
Normal file
7
zokrates_cli/examples/book/for_scope.code
Normal file
|
@ -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
|
7
zokrates_cli/examples/book/function_scope.code
Normal file
7
zokrates_cli/examples/book/function_scope.code
Normal file
|
@ -0,0 +1,7 @@
|
|||
def foo() -> (field):
|
||||
// return myGlobal <- not allowed
|
||||
return 42
|
||||
|
||||
def main() -> (field):
|
||||
field myGlobal = 42
|
||||
return foo()
|
7
zokrates_cli/examples/book/no_shadowing.code
Normal file
7
zokrates_cli/examples/book/no_shadowing.code
Normal file
|
@ -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
|
4
zokrates_cli/examples/error/out_of_for_scope.code
Normal file
4
zokrates_cli/examples/error/out_of_for_scope.code
Normal file
|
@ -0,0 +1,4 @@
|
|||
def main() -> (field):
|
||||
for field i in 0..5 do
|
||||
endfor
|
||||
return i
|
|
@ -2,6 +2,6 @@ def foo() -> (field):
|
|||
return 1
|
||||
|
||||
def main() -> (field):
|
||||
bool a
|
||||
field a = 2
|
||||
field a = foo()
|
||||
return 1
|
Loading…
Reference in a new issue