forked from darwinia-network/darwinia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'darwinia-network-master'
- Loading branch information
Showing
149 changed files
with
22,791 additions
and
28,471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root = true | ||
|
||
[*] | ||
charset=utf-8 | ||
end_of_line=lf | ||
indent_size=tab | ||
indent_style=tab | ||
insert_final_newline=true | ||
max_line_length=100 | ||
tab_width=4 | ||
trim_trailing_whitespace=true | ||
|
||
[*.py] | ||
charset=utf-8 | ||
indent_size=4 | ||
indent_style=space | ||
|
||
[*.yml] | ||
indent_size=2 | ||
indent_style=space | ||
tab_width=8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cargo.lock linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# The script help you set up your develop envirnment | ||
# | ||
# --fast: fast mode will skip OS pacakge dependency, only install git hooks and Rust | ||
# | ||
|
||
if [[ "$1" != "--fast" ]]; then | ||
if [[ "$OSTYPE" == "linux-gnu" ]]; then | ||
set -e | ||
if [ -f /etc/redhat-release ]; then | ||
echo "Redhat Linux detected, but current not support sorry." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
elif [ -f /etc/SuSE-release ]; then | ||
echo "Suse Linux detected, but current not support sorry." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
elif [ -f /etc/arch-release ]; then | ||
echo "Arch Linux detected." | ||
sudo pacman -Syu --needed --noconfirm cmake gcc openssl-1.0 clang llvm rocksdb curl | ||
export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0"; | ||
export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0" | ||
elif [ -f /etc/mandrake-release ]; then | ||
echo "Mandrake Linux detected, but current not support sorry." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
elif [ -f /etc/debian_version ]; then | ||
echo "Ubuntu/Debian Linux detected." | ||
sudo apt-get -y update | ||
sudo apt-get install -y cmake pkg-config libssl-dev | ||
else | ||
echo "Unknown Linux distribution." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
fi | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
set -e | ||
echo "Mac OS (Darwin) detected." | ||
if ! which brew >/dev/null 2>&1; then | ||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
fi | ||
brew upgrade | ||
brew install openssl cmake llvm | ||
elif [[ "$OSTYPE" == "freebsd"* ]]; then | ||
echo "FreeBSD detected, but current not support sorry." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
else | ||
echo "Unknown operating system." | ||
echo "Contribution is always welcome." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Setup git hooks | ||
cp .hooks/* .git/hooks | ||
|
||
# Install nightly Rust | ||
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly -y | ||
|
||
# Install wasm toolchain | ||
rustup target add wasm32-unknown-unknown | ||
|
||
# Install rustfmt for coding style checking | ||
rustup component add rustfmt --toolchain nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
rustup default $RUST_TOOLCHAIN | ||
|
||
source ~/.cargo/env | ||
|
||
rustup --version | ||
cargo --version | ||
rustc --version | ||
|
||
case $TARGET in | ||
# Without WASM | ||
"native") | ||
# There is some issue to build on ci server with SKIP_WASM_BUILD=1 | ||
cargo build --all --locked "$@" | ||
echo -e "\e[0;32m +-------------+ \n\e[0;32m | Native Pass | \n\e[0;32m +-------------+ \e[0m" | ||
;; | ||
|
||
# With WASM | ||
"wasm") | ||
WASM_BUILD_TYPE=release cargo build --locked "$@" | ||
echo -e "\e[0;32m +-----------+ \n\e[0;32m | WASM Pass | \n\e[0;32m +-----------+ \e[0m" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
echo -e "Test Darwinia ${1} ..." | ||
|
||
set -eux | ||
|
||
rustup default $RUST_TOOLCHAIN | ||
|
||
source ~/.cargo/env | ||
|
||
rustup --version | ||
cargo --version | ||
rustc --version | ||
|
||
case $TARGET in | ||
# Without WASM | ||
"native") | ||
# There is some issue to build on ci server with SKIP_WASM_BUILD=1 | ||
TARGET=native cargo test -p darwinia-${1} | ||
echo -e "\e[0;32m +------------+ \n\e[0;32m | ${1} Pass | \n\e[0;32m +------------+ \e[0m" | ||
;; | ||
|
||
# With WASM | ||
"wasm") | ||
WASM_BUILD_TYPE=release cargo test -p darwinia-${1} | ||
echo -e "\e[0;32m +------------+ \n\e[0;32m | ${1} Pass | \n\e[0;32m +------------+ \e[0m" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
# rustfmt is check as stable rust | ||
rustup default stable | ||
rustup component add rustfmt | ||
|
||
source ~/.cargo/env | ||
|
||
rustup --version | ||
cargo --version | ||
rustc --version | ||
|
||
# clean target cache if any | ||
rm -rf target | ||
|
||
cargo fmt --all | ||
echo -e "\e[0;32m +-------------+ \n\e[0;32m | Format Pass | \n\e[0;32m +-------------+ \e[0m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
rustup default $RUST_TOOLCHAIN | ||
|
||
source ~/.cargo/env | ||
|
||
rustup --version | ||
cargo --version | ||
rustc --version | ||
|
||
case $TARGET in | ||
# Without WASM, build then test | ||
"native") | ||
# There is some issue to build on ci server with SKIP_WASM_BUILD=1 | ||
cargo test --release --all --locked "$@" | ||
echo -e "\e[0;32m +------------+ \n\e[0;32m | Release OK | \n\e[0;32m +------------+ \e[0m" | ||
;; | ||
|
||
# With WASM, build then test | ||
"wasm") | ||
WASM_BUILD_TYPE=release cargo test --locked "$@" | ||
echo -e "\e[0;32m +------------+ \n\e[0;32m | Release OK | \n\e[0;32m +------------+ \e[0m" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
|
||
export PATH=$PATH:$HOME/.cargo/bin | ||
|
||
rustfmt --version &>/dev/null | ||
if [ $? != 0 ]; then | ||
printf "[pre_commit] [ERROR] \"rustfmt\" not available. \n" | ||
printf "[pre_commit] [ERROR] rustfmt can be installed via - \n" | ||
printf "[pre_commit] $ rustup component add rustfmt \n" | ||
exit 1 | ||
fi | ||
|
||
|
||
problem_files=() | ||
|
||
# first collect all the files that need reformatting | ||
for file in $(git diff --name-only --cached); do | ||
if [ ${file: -3} == ".rs" ]; then | ||
rustfmt --check $file | ||
if [ $? != 0 ]; then | ||
problem_files+=($file) | ||
fi | ||
fi | ||
done | ||
|
||
if [ ${#problem_files[@]} != 0 ]; then | ||
printf "[pre_commit] [ERROR] Plaese format the files via -\n" | ||
printf "[pre_commit] $ cargo fmt --all \n" | ||
printf "[pre_commit] [ERROR] If you want to keep your format with special reason, \n" | ||
printf "[pre_commit] [ERROR] you can use this macro. \n" | ||
printf "[pre_commit] #[rustfmt::skip] \n" | ||
exit 1 | ||
fi | ||
|
||
printf "[pre_commit] [SUCCESS] rustfmt ok \n" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from glob import iglob | ||
from os.path import abspath, dirname | ||
from pathlib import Path | ||
from shutil import rmtree | ||
|
||
for mode in ['debug', 'release']: | ||
for pattern in ['*eth_offchain*']: | ||
for path in iglob(''.join([ | ||
dirname(dirname(dirname(abspath(__file__)))), | ||
'/target/', | ||
mode, | ||
'/**/', | ||
pattern, | ||
]), recursive=True): | ||
print('removed:', path) | ||
path = Path(path) | ||
if path.is_dir(): | ||
rmtree(path) | ||
elif path.is_file: | ||
path.unlink() |
Oops, something went wrong.