1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

Merge branch 'develop' into add-sharound

* develop:
  Remove the tools directory
  add doc, example and failing test for out of scope
  Add zokrates_field to kcov
  first build docker, then tag gh
  clean env
  revert dockerfile to original, enable master filter, enable push to dockerhub, git tag and mdbook
  clean, move bot addr to env, silence commands
  pass pw through stdin to silence warning
  remove useless checks, rename env var
  enable docker remote
  add docker login, get mdbook from tar
  allow wasm tests to fail
  add integration_test job
  use workflows

# Conflicts:
#	.circleci/config.yml
This commit is contained in:
sdeml 2019-01-31 08:59:59 +01:00
commit a7e5477d2b
12 changed files with 200 additions and 52 deletions

View file

@ -15,37 +15,115 @@ jobs:
- restore_cache:
keys:
- v5-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
- 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
- run:
name: Run tests
command: ZOKRATES_HOME=$(pwd)/stdlib/ 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: ZOKRATES_HOME=$(pwd)/stdlib/ 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
- run:
name: Publish book
command: ./scripts/publish_book.sh
command: ZOKRATES_HOME=$(pwd)/stdlib/ 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: v5-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
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
- run:
name: Build
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" ./build.sh
- run:
name: Run tests
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark RUSTFLAGS="-D warnings" cargo test --release -- --test-threads=1
- run:
name: Generate code coverage report
command: ./scripts/cov.sh
wasm_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: 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: ZOKRATES_HOME=$(pwd)/stdlib/ LIBSNARK_SOURCE_PATH=$HOME/libsnark ./build_libsnark.sh
- run:
name: Run integration tests
command: ZOKRATES_HOME=$(pwd)/stdlib/ 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

View file

@ -12,5 +12,6 @@ cargo kcov --print-install-kcov-sh | sh
cd zokrates_fs_resolver && WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark cargo kcov && cd ..
cd zokrates_core && WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark cargo kcov && cd ..
cd zokrates_cli && WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark cargo kcov && cd ..
cd zokrates_field && WITH_LIBSNARK=1 LIBSNARK_SOURCE_PATH=$HOME/libsnark cargo kcov && cd ..
bash <(curl -s https://codecov.io/bash)
echo "Uploaded code coverage"

View file

@ -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
View 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
View file

View 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"

View file

@ -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}}
```

View 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

View file

@ -0,0 +1,7 @@
def foo() -> (field):
// return myGlobal <- not allowed
return 42
def main() -> (field):
field myGlobal = 42
return foo()

View 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

View file

@ -0,0 +1,4 @@
def main() -> (field):
for field i in 0..5 do
endfor
return i

View file

@ -2,6 +2,6 @@ def foo() -> (field):
return 1
def main() -> (field):
bool a
field a = 2
field a = foo()
return 1