Skip to content

Commit

Permalink
Merge branch 'darwinia-network-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
freehere107 committed Apr 8, 2020
2 parents b2882ad + 71e05c9 commit d9aa30c
Show file tree
Hide file tree
Showing 149 changed files with 22,791 additions and 28,471 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cargo.lock linguist-generated=true
33 changes: 15 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
# Generated by Cargo
# will have compiled files and executables

**/target/

# These are backup files generated by rustfmt
**/*.rs.bk

.idea
.vscode
.DS_Store

test-client
node_runtime.wasm


# For cross compile
# Cross Compile Things
osxcross
darwin-x86_64
darwin-x86_64.tar.gz
Expand All @@ -23,5 +7,18 @@ linux-x86_64.tar.gz
windows-x86_64
windows-x86_64.tar.gz

# Macro expand file
# IDE Things
.idea
.vscode
expand.rs

# macOS Things
.DS_Store

# PM2 Things
.pm2.json

# Rust Things
**/*.rs.bk
**/target/
Cargo.toml.bak
File renamed without changes.
66 changes: 66 additions & 0 deletions .maintain/bootstrap.sh
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
26 changes: 26 additions & 0 deletions .maintain/ci/build_script.sh
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
27 changes: 27 additions & 0 deletions .maintain/ci/darwinia_test_script.sh
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
19 changes: 19 additions & 0 deletions .maintain/ci/fmt_script.sh
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"
26 changes: 26 additions & 0 deletions .maintain/ci/test_script.sh
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
37 changes: 37 additions & 0 deletions .maintain/hooks/pre-commit
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
20 changes: 20 additions & 0 deletions .maintain/utility/clean-offchain-builds.py
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()
Loading

0 comments on commit d9aa30c

Please sign in to comment.