diff --git a/.travis.yml b/.travis.yml index f3cbb4f4516..7a741b28745 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,14 +45,14 @@ script: - if [ "$RUN_TESTS" = "true" ]; then ./test.sh; fi install: | - [ "$RUN_COVERAGE" = "true" ] && - wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && + [ "$RUN_COVERAGE" = "false" ] || + (wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && - mkdir kcov-master/build && + mkdir -p kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && - cd ../.. + cd) after_success: - true && [ "$RUN_COVERAGE" = "true" ] && ./scripts/cov.sh "$KCOV_CMD" diff --git a/scripts/add_license.sh b/scripts/add_license.sh new file mode 100755 index 00000000000..1d916f42796 --- /dev/null +++ b/scripts/add_license.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for f in $(find . -name '*.rs'); do + cat license_header $f > $f.new + mv $f.new $f +done diff --git a/scripts/cov.sh b/scripts/cov.sh new file mode 100755 index 00000000000..8b49607e563 --- /dev/null +++ b/scripts/cov.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Installing KCOV under ubuntu +# https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650# +### Install deps +# $ sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev +# +### Compile kcov +# $ wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xf master.tar.gz +# $ cd kcov-master && mkdir build && cd build +# $ cmake .. && make && sudo make install + +### Running coverage + +KCOV_CMD=${1:-kcov} + +if ! type $KCOV_CMD > /dev/null; then + echo "Install kcov first (details inside this file). Aborting." + exit 1 +fi + +. ./scripts/targets.sh + +cargo test $TARGETS --no-run || exit $? +rm -rf target/coverage +mkdir -p target/coverage + +EXCLUDE="~/.multirust,rocksdb,secp256k1,/usr/,/.cargo,/root/.multirust,src/tests,util/json-tests,util/src/network/tests,sync/src/tests,ethcore/src/tests,ethcore/src/evm/tests,ethstore/tests target/kcov" +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethkey-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethstore-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethcore-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethash-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethcore_util-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethsync-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethcore_rpc-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethcore_signer-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethcore_dapps-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/deps/ethjson-* +$KCOV_CMD --exclude-pattern $EXCLUDE --include-pattern src --verify target/coverage target/debug/parity-* +xdg-open target/coverage/index.html diff --git a/scripts/doc.sh b/scripts/doc.sh new file mode 100755 index 00000000000..657f47567d1 --- /dev/null +++ b/scripts/doc.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# generate documentation only for partiy and ethcore libraries + +. ./scripts/targets.sh + +cargo doc --no-deps --verbose $TARGETS && + echo '' > target/doc/index.html diff --git a/scripts/fmt.sh b/scripts/fmt.sh new file mode 100755 index 00000000000..624b404ffcf --- /dev/null +++ b/scripts/fmt.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +RUSTFMT="rustfmt --write-mode overwrite" + +$RUSTFMT ./ethash/src/lib.rs +$RUSTFMT ./ethcore/src/lib.rs +$RUSTFMT ./evmjit/src/lib.rs +$RUSTFMT ./json/src/lib.rs +$RUSTFMT ./miner/src/lib.rs +$RUSTFMT ./parity/main.rs +$RUSTFMT ./rpc/src/lib.rs +$RUSTFMT ./signer/src/lib.rs +$RUSTFMT ./dapps/src/lib.rs +$RUSTFMT ./sync/src/lib.rs +$RUSTFMT ./util/src/lib.rs + diff --git a/scripts/hook.sh b/scripts/hook.sh new file mode 100755 index 00000000000..9b5512ac0f4 --- /dev/null +++ b/scripts/hook.sh @@ -0,0 +1,14 @@ +#!/bin/sh +FILE=./.git/hooks/pre-push +. ./scripts/targets.sh + +echo "#!/bin/sh\n" > $FILE +# Exit on any error +echo "set -e" >> $FILE +# Run release build +echo "cargo build --features dev" >> $FILE +# Build tests +echo "cargo test --no-run --features dev \\" >> $FILE +echo $TARGETS >> $FILE +echo "" >> $FILE +chmod +x $FILE diff --git a/scripts/targets.sh b/scripts/targets.sh new file mode 100644 index 00000000000..4c2b7ca6808 --- /dev/null +++ b/scripts/targets.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +export TARGETS=" + -p ethkey \ + -p ethstore \ + -p ethash \ + -p ethcore-util \ + -p ethcore \ + -p ethsync \ + -p ethcore-rpc \ + -p ethcore-signer \ + -p ethcore-dapps \ + -p parity \ + -p bigint"