-
Notifications
You must be signed in to change notification settings - Fork 61
sync code from dev into master #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
48050c7
cdb1d35
1fd62be
7afea9d
efe1b5a
1b2faf3
ae85445
9b8ed51
883fdde
0c1a81f
362f69b
9e39429
1ed3e4b
5c3b983
199d03e
d033c76
878fe13
3507353
21c0b4b
203aebf
5364a9e
71b3800
f821320
f979aaf
b14d755
6378e9c
b72845d
2214a6e
5985346
70b0a7e
ed014b9
48d445e
445ebfd
79a603f
5fe1fb8
829ccdc
ec55160
86749df
8537891
c07be68
8d894f9
b1418ef
ce68360
2a134d8
3c05fac
9236174
14741ff
e9eff89
a54591b
79a1dd2
f61627c
c1db99c
e963c08
ec51675
41e0349
1dcc369
11f7201
deff7cd
b27a02b
c8bd969
751d14e
59c3b49
456096b
850b348
55512d9
70e7b5c
55250a7
e83e95f
6962be4
0bbe3a2
bca2be0
7b13850
672b487
5c48871
4e6d7ee
a5c0d2a
ff89dfa
f466e6f
3041f4d
35b9bae
03a14b4
0da0851
1eaba24
71dbf40
3a13c44
6d26a0e
9cca9eb
48bd6cf
4fb9e03
5e589e5
d7ac976
9b2c9dd
46b9d31
1da1322
5dfeece
322bbb2
f325a35
6f1d5c6
634a399
3d67fbc
46a89d4
4caf563
1a976aa
d18c2a8
c9489e7
6c32acd
37f7af1
9693450
bc8958d
b545a50
dfd0962
8abe96e
02c6863
d7a441e
1919c90
bb0cf25
66b5338
352e7ad
8f2bece
be6240a
1f46228
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| LOG_INFO() { | ||
| local content=${1} | ||
| echo -e "\033[32m ${content}\033[0m" | ||
| } | ||
| check_basic() | ||
| { | ||
| # check code format | ||
| bash gradlew verifyGoogleJavaFormat | ||
| # build | ||
| bash gradlew build --info | ||
| } | ||
|
|
||
| download_tassl() | ||
| { | ||
| mkdir -p ~/.fisco/ | ||
| if [ "$(uname)" == "Darwin" ];then | ||
| curl -LO https://github.com/FISCO-BCOS/LargeFiles/raw/master/tools/tassl_mac.tar.gz | ||
| mv tassl_mac.tar.gz ~/.fisco/tassl.tar.gz | ||
| else | ||
| curl -LO https://github.com/FISCO-BCOS/LargeFiles/raw/master/tools/tassl.tar.gz | ||
| mv tassl.tar.gz ~/.fisco/tassl.tar.gz | ||
| fi | ||
| tar -xvf ~/.fisco/tassl.tar.gz | ||
| } | ||
|
|
||
| download_build_chain() | ||
| { | ||
| 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) | ||
| LOG_INFO "--- current tag: $tag" | ||
| curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${tag}/build_chain.sh" && chmod u+x build_chain.sh | ||
| } | ||
|
|
||
| get_sed_cmd() | ||
| { | ||
| local sed_cmd="sed -i" | ||
| if [ "$(uname)" == "Darwin" ];then | ||
| sed_cmd="sed -i .bkp" | ||
| fi | ||
| echo "$sed_cmd" | ||
| } | ||
|
|
||
| prepare_environment() | ||
| { | ||
| ## prepare resources for integration test | ||
| mkdir -p src/integration-test/resources/ | ||
| mkdir -p conf | ||
| cp -r nodes/127.0.0.1/sdk/* conf | ||
| cp src/test/resources/config-example.toml src/integration-test/resources/config.toml | ||
| cp src/test/resources/config-example.toml src/test/resources/config.toml | ||
| cp src/test/resources/log4j.properties src/integration-test/resources/ | ||
| cp -r src/test/resources/amop conf/amop | ||
| cp -r src/test/resources/amop src/integration-test/resources/amop | ||
| rm -rf src/integration-test/resources/abi | ||
| rm -rf src/integration-test/resources/bin | ||
| cp -r src/test/resources/ecdsa/abi src/integration-test/resources/abi | ||
| cp -r src/test/resources/ecdsa/bin src/integration-test/resources/bin | ||
| mkdir -p sdk-amop/src/test/resources | ||
| cp -r src/test/resources/ sdk-amop/src/test/resources | ||
|
|
||
| sed_cmd=$(get_sed_cmd) | ||
|
|
||
| local node_type="${1}" | ||
| if [ "${node_type}" == "sm" ];then | ||
| rm -rf src/integration-test/resources/abi | ||
| rm -rf src/integration-test/resources/bin | ||
| cp -r src/test/resources/gm/abi src/integration-test/resources/abi | ||
| cp -r src/test/resources/gm/bin src/integration-test/resources/bin | ||
| fi | ||
| } | ||
|
|
||
| build_node() | ||
| { | ||
| local node_type="${1}" | ||
| if [ "${node_type}" == "sm" ];then | ||
| ./build_chain.sh -l 127.0.0.1:4 -g | ||
| sed_cmd=$(get_sed_cmd) | ||
| $sed_cmd 's/sm_crypto_channel=false/sm_crypto_channel=true/g' nodes/127.0.0.1/node*/config.ini | ||
| else | ||
| ./build_chain.sh -l 127.0.0.1:4 | ||
| fi | ||
| ./nodes/127.0.0.1/fisco-bcos -v | ||
| ./nodes/127.0.0.1/start_all.sh | ||
| } | ||
|
|
||
| clean_node() | ||
| { | ||
| bash nodes/127.0.0.1/stop_all.sh | ||
| rm -rf nodes | ||
| } | ||
|
|
||
| # check integration-test for non-gm node | ||
| check_standard_node() | ||
| { | ||
| build_node | ||
| prepare_environment | ||
| ## run integration test | ||
| bash gradlew clean integrationTest --info | ||
| ## clean | ||
| clean_node | ||
| } | ||
|
|
||
| check_sm_node() | ||
| { | ||
| build_node "sm" | ||
| prepare_environment "sm" | ||
| ## run integration test | ||
| bash gradlew clean integrationTest --info | ||
| ## clean | ||
| clean_node | ||
| } | ||
| LOG_INFO "------ download_tassl---------" | ||
| download_tassl | ||
| LOG_INFO "------ check_basic---------" | ||
| ./gradlew build -x test | ||
| LOG_INFO "------ download_build_chain---------" | ||
| download_build_chain | ||
| LOG_INFO "------ check_standard_node---------" | ||
| check_standard_node | ||
| LOG_INFO "------ check_sm_node---------" | ||
| check_sm_node | ||
| LOG_INFO "------ check_basic---------" | ||
| check_basic | ||
| #LOG_INFO "------ check_log---------" | ||
| #cat log/* |grep -i error | ||
| #cat log/* |grep -i warn |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||||||
| #!/bin/bash | ||||||||||||||
|
|
||||||||||||||
| set -e | ||||||||||||||
|
|
||||||||||||||
| scan_code_script="cobra/cobra.py -f json -o /tmp/report.json -t " | ||||||||||||||
| 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) | ||||||||||||||
| commit_limit=6 | ||||||||||||||
|
|
||||||||||||||
| LOG_ERROR() { | ||||||||||||||
| content=${1} | ||||||||||||||
| echo -e "\033[31m${content}\033[0m" | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| LOG_INFO() { | ||||||||||||||
| content=${1} | ||||||||||||||
| echo -e "\033[32m${content}\033[0m" | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| should_ignore() { | ||||||||||||||
| local file=${1} | ||||||||||||||
| for ignore in ${ignore_files[*]}; do | ||||||||||||||
| if echo "${file}" | grep "${ignore}" &>/dev/null; then | ||||||||||||||
| echo "ignore ${file} ${ignore}" | ||||||||||||||
| return 0 | ||||||||||||||
| fi | ||||||||||||||
| done | ||||||||||||||
| return 1 | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| scan_code() { | ||||||||||||||
| # Redirect output to stderr. | ||||||||||||||
| exec 1>&2 | ||||||||||||||
| for file in $(git diff-index --name-status HEAD^ | awk '{print $2}'); do | ||||||||||||||
| if should_ignore "${file}"; then continue; fi | ||||||||||||||
| if [ ! -f "${file}" ]; then continue; fi | ||||||||||||||
| LOG_INFO "check file ${file}" | ||||||||||||||
| python ${scan_code_script} "$file" | ||||||||||||||
| trigger_rules=$(jq -r '.' /tmp/report.json | grep 'trigger_rules' | awk '{print $2}' | sed 's/,//g') | ||||||||||||||
| echo "trigger_rules is ${trigger_rules}" | ||||||||||||||
| rm /tmp/report.json | ||||||||||||||
| if [ ${trigger_rules} -ne 0 ]; then | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Double quote to prevent globbing and word splitting. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| echo "######### ERROR: Scan code failed, please adjust them before commit" | ||||||||||||||
| exit 1 | ||||||||||||||
| fi | ||||||||||||||
| done | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| install_cobra() { | ||||||||||||||
| git clone https://github.com/WhaleShark-Team/cobra.git | ||||||||||||||
| pip install -r cobra/requirements.txt | ||||||||||||||
| cp cobra/config.template cobra/config | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| check_commit_message() | ||||||||||||||
| { | ||||||||||||||
| local commits=$(git rev-list --count HEAD^..HEAD) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Declare and assign separately to avoid masking return values. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| if [ ${commit_limit} -lt ${commits} ]; then | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Double quote to prevent globbing and word splitting. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| LOG_ERROR "${commits} commits, limit is ${commit_limit}" | ||||||||||||||
| exit 1 | ||||||||||||||
| fi | ||||||||||||||
| local unique_commit=$(git log --format=%s HEAD^..HEAD | sort -u | wc -l) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Declare and assign separately to avoid masking return values. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| if [ ${unique_commit} -ne ${commits} ]; then | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Double quote to prevent globbing and word splitting. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| LOG_ERROR "${commits} != ${unique_commit}, please make commit message unique!" | ||||||||||||||
| exit 1 | ||||||||||||||
| fi | ||||||||||||||
| local merges=$(git log --format=%s HEAD^..HEAD | grep -i merge | wc -l) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Consider using grep -c instead of grep|wc -l. (view)
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Declare and assign separately to avoid masking return values. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| if [ ${merges} -gt 2 ]; then | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ShellCheck] Double quote to prevent globbing and word splitting. (view)
References: You can close this issue if no need to fix it. Learn more. |
||||||||||||||
| LOG_ERROR "PR contain merge : ${merges}, Please rebase!" | ||||||||||||||
| exit 1 | ||||||||||||||
| fi | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| check_commit_message | ||||||||||||||
| install_cobra | ||||||||||||||
| scan_code | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| version: 2.1 | ||
| jobs: | ||
| build: | ||
| working_directory: /java-sdk | ||
| docker: | ||
| - image: centos:7 | ||
| environment: | ||
| PATH=$PATH:/usr/bin | ||
| steps: | ||
| - run: | ||
| name: Setup dependencies | ||
| command: | | ||
| yum install -y epel-release centos-release-scl which | ||
| yum install -y git openssl-devel openssl java java-devel | ||
| - checkout | ||
| - run: | ||
| name: Compile | ||
| command: | | ||
| bash gradlew build -x test -x integrationTest | ||
| - run: | ||
| name: Integration Test | ||
| command: | | ||
| bash .ci/ci_check.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| codecov: | ||
| branch: * | ||
| coverage: | ||
| ignore: | ||
| - "src/integration-test/**/*" | ||
| status: | ||
| project: | ||
| default: | ||
| target: 30% | ||
| threshold: null | ||
| if_not_found: success | ||
| patch: | ||
| default: | ||
| enabled: no | ||
| if_not_found: success | ||
| changes: | ||
| default: | ||
| enabled: no | ||
| if_not_found: success |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Java-SDK GitHub Actions | ||
| on: | ||
| pull_request: | ||
| release: | ||
| types: [published, created, edited] | ||
| env: | ||
| CCACHE_DIR: ${{ github.workspace }}/ccache | ||
|
|
||
| jobs: | ||
| build: | ||
| name: build | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-18.04, ubuntu-16.04, macos-latest] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 5 | ||
| - name: install macOS dependencies | ||
| if: runner.os == 'macOS' | ||
| run: brew install openssl@1.1 openjdk | ||
| - name: install Ubuntu dependencies | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt install -y git curl libssl-dev default-jdk build-essential | ||
| - name: run integration testing | ||
| run: /bin/bash .ci/ci_check.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| .gradle/ | ||
| .idea/ | ||
| log/ | ||
| build | ||
| java-sdk.iml | ||
|
|
||
| ## eclipse ## | ||
| .classpath | ||
| .project | ||
| .settings/ | ||
| bin/ | ||
| out/ | ||
| dist/ | ||
| conf/ | ||
|
|
||
| ## integration test files | ||
| nodes/ | ||
| src/integration-test/resources/ | ||
| build_chain.sh | ||
| account/ | ||
| conf/ | ||
| gmcert.cnf | ||
| gmsm2.param | ||
| integrationTestEnv.sh | ||
| gradle.properties | ||
| gpg.gpg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ShellCheck] Double quote to prevent globbing and word splitting. (view)
SC2086infoReferences:
You can close this issue if no need to fix it. Learn more.