Skip to content

Commit 5c1a013

Browse files
authored
Merge pull request #158 from cyjseagull/dev-bak3
sync code from dev into master
2 parents 6c47a4e + 1f46228 commit 5c1a013

File tree

619 files changed

+58202
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

619 files changed

+58202
-2
lines changed

.ci/ci_check.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
3+
set -e
4+
LOG_INFO() {
5+
local content=${1}
6+
echo -e "\033[32m ${content}\033[0m"
7+
}
8+
check_basic()
9+
{
10+
# check code format
11+
bash gradlew verifyGoogleJavaFormat
12+
# build
13+
bash gradlew build --info
14+
}
15+
16+
download_tassl()
17+
{
18+
mkdir -p ~/.fisco/
19+
if [ "$(uname)" == "Darwin" ];then
20+
curl -LO https://github.com/FISCO-BCOS/LargeFiles/raw/master/tools/tassl_mac.tar.gz
21+
mv tassl_mac.tar.gz ~/.fisco/tassl.tar.gz
22+
else
23+
curl -LO https://github.com/FISCO-BCOS/LargeFiles/raw/master/tools/tassl.tar.gz
24+
mv tassl.tar.gz ~/.fisco/tassl.tar.gz
25+
fi
26+
tar -xvf ~/.fisco/tassl.tar.gz
27+
}
28+
29+
download_build_chain()
30+
{
31+
tag=$(curl -sS "https://gitee.com/api/v5/repos/FISCO-BCOS/FISCO-BCOS/tags" | grep -oe "\"name\":\"v[2-9]*\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
32+
LOG_INFO "--- current tag: $tag"
33+
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${tag}/build_chain.sh" && chmod u+x build_chain.sh
34+
}
35+
36+
get_sed_cmd()
37+
{
38+
local sed_cmd="sed -i"
39+
if [ "$(uname)" == "Darwin" ];then
40+
sed_cmd="sed -i .bkp"
41+
fi
42+
echo "$sed_cmd"
43+
}
44+
45+
prepare_environment()
46+
{
47+
## prepare resources for integration test
48+
mkdir -p src/integration-test/resources/
49+
mkdir -p conf
50+
cp -r nodes/127.0.0.1/sdk/* conf
51+
cp src/test/resources/config-example.toml src/integration-test/resources/config.toml
52+
cp src/test/resources/config-example.toml src/test/resources/config.toml
53+
cp src/test/resources/log4j.properties src/integration-test/resources/
54+
cp -r src/test/resources/amop conf/amop
55+
cp -r src/test/resources/amop src/integration-test/resources/amop
56+
rm -rf src/integration-test/resources/abi
57+
rm -rf src/integration-test/resources/bin
58+
cp -r src/test/resources/ecdsa/abi src/integration-test/resources/abi
59+
cp -r src/test/resources/ecdsa/bin src/integration-test/resources/bin
60+
mkdir -p sdk-amop/src/test/resources
61+
cp -r src/test/resources/ sdk-amop/src/test/resources
62+
63+
sed_cmd=$(get_sed_cmd)
64+
65+
local node_type="${1}"
66+
if [ "${node_type}" == "sm" ];then
67+
rm -rf src/integration-test/resources/abi
68+
rm -rf src/integration-test/resources/bin
69+
cp -r src/test/resources/gm/abi src/integration-test/resources/abi
70+
cp -r src/test/resources/gm/bin src/integration-test/resources/bin
71+
fi
72+
}
73+
74+
build_node()
75+
{
76+
local node_type="${1}"
77+
if [ "${node_type}" == "sm" ];then
78+
./build_chain.sh -l 127.0.0.1:4 -g
79+
sed_cmd=$(get_sed_cmd)
80+
$sed_cmd 's/sm_crypto_channel=false/sm_crypto_channel=true/g' nodes/127.0.0.1/node*/config.ini
81+
else
82+
./build_chain.sh -l 127.0.0.1:4
83+
fi
84+
./nodes/127.0.0.1/fisco-bcos -v
85+
./nodes/127.0.0.1/start_all.sh
86+
}
87+
88+
clean_node()
89+
{
90+
bash nodes/127.0.0.1/stop_all.sh
91+
rm -rf nodes
92+
}
93+
94+
# check integration-test for non-gm node
95+
check_standard_node()
96+
{
97+
build_node
98+
prepare_environment
99+
## run integration test
100+
bash gradlew clean integrationTest --info
101+
## clean
102+
clean_node
103+
}
104+
105+
check_sm_node()
106+
{
107+
build_node "sm"
108+
prepare_environment "sm"
109+
## run integration test
110+
bash gradlew clean integrationTest --info
111+
## clean
112+
clean_node
113+
}
114+
LOG_INFO "------ download_tassl---------"
115+
download_tassl
116+
LOG_INFO "------ check_basic---------"
117+
./gradlew build -x test
118+
LOG_INFO "------ download_build_chain---------"
119+
download_build_chain
120+
LOG_INFO "------ check_standard_node---------"
121+
check_standard_node
122+
LOG_INFO "------ check_sm_node---------"
123+
check_sm_node
124+
LOG_INFO "------ check_basic---------"
125+
check_basic
126+
#LOG_INFO "------ check_log---------"
127+
#cat log/* |grep -i error
128+
#cat log/* |grep -i warn

.ci/ci_check_commit.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
scan_code_script="cobra/cobra.py -f json -o /tmp/report.json -t "
6+
ignore_files=(sh crt key json toml SignatureTest.java Ok.java bin abi ChannelTest.java ParallelOkDemo.java PerformanceAmop.java DagPrecompiledDemo.java KeyToolTest.java CryptoSuite.java AmopMsgHandlerTest.java TopicManager.java PrivateTopicVerifyTest.java AmopMsgBuilder.java TopicManagerTest.java AmopSubscribe.java AmopPublisher.java AmopPublisherPrivate.java AmopSubscribePrivate.java AmopPublisherFile.java AmopPublisherPrivateFile.java DemoAmopCallback.java FileToByteArrayHelper.java OkD.java TableTest.java PerformanceTable.java HelloWorld.java PerformanceRPC.java CodecTest.java ResponseTest.java ConfigTest.java)
7+
commit_limit=6
8+
9+
LOG_ERROR() {
10+
content=${1}
11+
echo -e "\033[31m${content}\033[0m"
12+
}
13+
14+
LOG_INFO() {
15+
content=${1}
16+
echo -e "\033[32m${content}\033[0m"
17+
}
18+
19+
should_ignore() {
20+
local file=${1}
21+
for ignore in ${ignore_files[*]}; do
22+
if echo "${file}" | grep "${ignore}" &>/dev/null; then
23+
echo "ignore ${file} ${ignore}"
24+
return 0
25+
fi
26+
done
27+
return 1
28+
}
29+
30+
scan_code() {
31+
# Redirect output to stderr.
32+
exec 1>&2
33+
for file in $(git diff-index --name-status HEAD^ | awk '{print $2}'); do
34+
if should_ignore "${file}"; then continue; fi
35+
if [ ! -f "${file}" ]; then continue; fi
36+
LOG_INFO "check file ${file}"
37+
python ${scan_code_script} "$file"
38+
trigger_rules=$(jq -r '.' /tmp/report.json | grep 'trigger_rules' | awk '{print $2}' | sed 's/,//g')
39+
echo "trigger_rules is ${trigger_rules}"
40+
rm /tmp/report.json
41+
if [ ${trigger_rules} -ne 0 ]; then
42+
echo "######### ERROR: Scan code failed, please adjust them before commit"
43+
exit 1
44+
fi
45+
done
46+
}
47+
48+
install_cobra() {
49+
git clone https://github.com/WhaleShark-Team/cobra.git
50+
pip install -r cobra/requirements.txt
51+
cp cobra/config.template cobra/config
52+
}
53+
54+
check_commit_message()
55+
{
56+
local commits=$(git rev-list --count HEAD^..HEAD)
57+
if [ ${commit_limit} -lt ${commits} ]; then
58+
LOG_ERROR "${commits} commits, limit is ${commit_limit}"
59+
exit 1
60+
fi
61+
local unique_commit=$(git log --format=%s HEAD^..HEAD | sort -u | wc -l)
62+
if [ ${unique_commit} -ne ${commits} ]; then
63+
LOG_ERROR "${commits} != ${unique_commit}, please make commit message unique!"
64+
exit 1
65+
fi
66+
local merges=$(git log --format=%s HEAD^..HEAD | grep -i merge | wc -l)
67+
if [ ${merges} -gt 2 ]; then
68+
LOG_ERROR "PR contain merge : ${merges}, Please rebase!"
69+
exit 1
70+
fi
71+
}
72+
73+
check_commit_message
74+
install_cobra
75+
scan_code

.circleci/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2.1
2+
jobs:
3+
build:
4+
working_directory: /java-sdk
5+
docker:
6+
- image: centos:7
7+
environment:
8+
PATH=$PATH:/usr/bin
9+
steps:
10+
- run:
11+
name: Setup dependencies
12+
command: |
13+
yum install -y epel-release centos-release-scl which
14+
yum install -y git openssl-devel openssl java java-devel
15+
- checkout
16+
- run:
17+
name: Compile
18+
command: |
19+
bash gradlew build -x test -x integrationTest
20+
- run:
21+
name: Integration Test
22+
command: |
23+
bash .ci/ci_check.sh

.codecov.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
codecov:
2+
branch: *
3+
coverage:
4+
ignore:
5+
- "src/integration-test/**/*"
6+
status:
7+
project:
8+
default:
9+
target: 30%
10+
threshold: null
11+
if_not_found: success
12+
patch:
13+
default:
14+
enabled: no
15+
if_not_found: success
16+
changes:
17+
default:
18+
enabled: no
19+
if_not_found: success

.github/workflows/workflow.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Java-SDK GitHub Actions
2+
on:
3+
pull_request:
4+
release:
5+
types: [published, created, edited]
6+
env:
7+
CCACHE_DIR: ${{ github.workspace }}/ccache
8+
9+
jobs:
10+
build:
11+
name: build
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-18.04, ubuntu-16.04, macos-latest]
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 5
20+
- name: install macOS dependencies
21+
if: runner.os == 'macOS'
22+
run: brew install openssl@1.1 openjdk
23+
- name: install Ubuntu dependencies
24+
if: runner.os == 'Linux'
25+
run: sudo apt-get update && sudo apt install -y git curl libssl-dev default-jdk build-essential
26+
- name: run integration testing
27+
run: /bin/bash .ci/ci_check.sh

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.gradle/
2+
.idea/
3+
log/
4+
build
5+
java-sdk.iml
6+
7+
## eclipse ##
8+
.classpath
9+
.project
10+
.settings/
11+
bin/
12+
out/
13+
dist/
14+
conf/
15+
16+
## integration test files
17+
nodes/
18+
src/integration-test/resources/
19+
build_chain.sh
20+
account/
21+
conf/
22+
gmcert.cnf
23+
gmsm2.param
24+
integrationTestEnv.sh
25+
gradle.properties
26+
gpg.gpg

0 commit comments

Comments
 (0)