1
0
Fork 0
mirror of synced 2025-09-23 04:08:33 +00:00

use workflows

This commit is contained in:
schaeff 2019-01-28 14:52:40 +01:00
parent 6e7d368a74
commit d72169dba9
4 changed files with 143 additions and 59 deletions

View file

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

View file

@ -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
# 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

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

34
scripts/release.sh Executable file
View file

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