From 5e9c048201ff791525325b452dda3ee058a871c5 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:04:27 +0800 Subject: [PATCH 1/9] ci: add code coverity --- .coveragerc | 13 ++++++ .drone.yml | 128 +++++++++++++++++++++++++++++++++++----------------- README.md | 3 ++ 3 files changed, 103 insertions(+), 41 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..9bfad106 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True +source = gnes + +[report] +exclude_lines = + if self.debug: + pragma: no cover + raise NotImplementedError + if __name__ == .__main__.: +ignore_errors = True +omit = + tests/* \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 79e60e04..2eeafc19 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,11 +1,88 @@ +#kind: pipeline +#name: default +# +#clone: +# depth: 50 +# +#steps: +# +#- name: notify the start on wechat work +# image: byrnedo/alpine-curl +# environment: +# BOT_URL: +# from_secret: BOT_URL +# commands: +# - export MSG_LINK=${DRONE_BUILD_LINK} +# - export MSG_TITLE="⌛🏗 Start a CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" +# - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" +# - ./shell/push-wechatwork.sh +# +#- name: check commit style +# image: node:alpine +# commands: +# - npm install --global --save-dev @commitlint/config-conventional @commitlint/cli +# - "echo \"module.exports = {extends: ['@commitlint/config-conventional']}\" > commitlint.config.js" +# - echo $DRONE_COMMIT_MESSAGE | commitlint +# +#- name: setup ci environment +# image: gnes/ci-base +# commands: +# - mkdir -p .cache && ln -snf $(pwd)/.cache $HOME/.cache +# - export PIP_DOWNLOAD_CACHE=${pwd}.cache/pip_download_cache && export XDG_CACHE_HOME=${pwd}.cache/pip +# - printf "XDG_CACHE_HOME=$XDG_CACHE_HOME\nPIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE\n" +# - cat /proc/cpuinfo | grep flags +# - "python -c 'import tensorflow as tf; print(tf.__version__); a=tf.constant(1, tf.int32); print(tf.Session().run(a))'" +# +#- name: pip-install gnes +# image: gnes/ci-base +# environment: +# GNES_ENV_SET: orange-ci +# commands: +# - pip install -e .[all] +# - pylint gnes/**/*.py --exit-zero +# - python -m unittest tests/*.py +# +# +#- name: notify the sucess on wechat work +# image: byrnedo/alpine-curl +# environment: +# BOT_URL: +# from_secret: BOT_URL +# commands: +# - export MSG_LINK=$DRONE_REPO_LINK +# - export MSG_TITLE="✅😃 All tests passed, good job! \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" +# - export MSG_CONTENT="the branch \`$DRONE_SOURCE_BRANCH\` submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) is ready to merge to master" +# - ./shell/push-wechatwork.sh +# +# +#- name: notify the failure on wechat work +# image: byrnedo/alpine-curl +# environment: +# BOT_URL: +# from_secret: BOT_URL +# commands: +# - export MSG_LINK=$DRONE_BUILD_LINK +# - export MSG_TITLE="❌😥 CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`) is failed!" +# - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." +# - ./shell/push-wechatwork.sh +# when: +# status: +# - failure +# +#trigger: +# branch: +# - master +# event: +# - pull_request +# +#--- + kind: pipeline -name: default +name: master-coverity clone: depth: 50 -steps: - - name: notify the start on wechat work image: byrnedo/alpine-curl environment: @@ -13,17 +90,10 @@ steps: from_secret: BOT_URL commands: - export MSG_LINK=${DRONE_BUILD_LINK} - - export MSG_TITLE="⌛🏗 Start a CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_TITLE="⌛🏗 Start to generate \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" - ./shell/push-wechatwork.sh -- name: check commit style - image: node:alpine - commands: - - npm install --global --save-dev @commitlint/config-conventional @commitlint/cli - - "echo \"module.exports = {extends: ['@commitlint/config-conventional']}\" > commitlint.config.js" - - echo $DRONE_COMMIT_MESSAGE | commitlint - - name: setup ci environment image: gnes/ci-base commands: @@ -37,40 +107,16 @@ steps: image: gnes/ci-base environment: GNES_ENV_SET: orange-ci + CODECOV_TOKEN_PR: + from_secret: CODECOV_TOKEN_PR commands: - pip install -e .[all] - - pylint gnes/**/*.py --exit-zero - - python -m unittest tests/*.py - - -- name: notify the sucess on wechat work - image: byrnedo/alpine-curl - environment: - BOT_URL: - from_secret: BOT_URL - commands: - - export MSG_LINK=$DRONE_REPO_LINK - - export MSG_TITLE="✅😃 All tests passed, good job! \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - - export MSG_CONTENT="the branch \`$DRONE_SOURCE_BRANCH\` submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) is ready to merge to master" - - ./shell/push-wechatwork.sh - - -- name: notify the failure on wechat work - image: byrnedo/alpine-curl - environment: - BOT_URL: - from_secret: BOT_URL - commands: - - export MSG_LINK=$DRONE_BUILD_LINK - - export MSG_TITLE="❌😥 CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`) is failed!" - - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." - - ./shell/push-wechatwork.sh - when: - status: - - failure + - pip install coverage codecov + - coverage run tests/*.py + - codecov --token $CODECOV_TOKEN_PR trigger: branch: - master event: - - pull_request \ No newline at end of file + - pull_request diff --git a/README.md b/README.md index f16b7a19..94936c92 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ + + + PyPI - License From 5439edafbfe666a322003ca115c28f21d24e1648 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:07:31 +0800 Subject: [PATCH 2/9] ci: add code coverity --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 2eeafc19..40df0ae6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -83,6 +83,7 @@ name: master-coverity clone: depth: 50 +steps: - name: notify the start on wechat work image: byrnedo/alpine-curl environment: From a1a81bfc7a0c486b4c72606f8a0f6c151376b76b Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:16:13 +0800 Subject: [PATCH 3/9] ci: add code coverity --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 40df0ae6..5d52c5a5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -91,8 +91,8 @@ steps: from_secret: BOT_URL commands: - export MSG_LINK=${DRONE_BUILD_LINK} - - export MSG_TITLE="⌛🏗 Start to generate \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" + - export MSG_TITLE="⌛🏗 Start to generate the coverage report \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_CONTENT="click the link below to see the status" - ./shell/push-wechatwork.sh - name: setup ci environment @@ -113,7 +113,7 @@ steps: commands: - pip install -e .[all] - pip install coverage codecov - - coverage run tests/*.py + - coverage run --source tests/*.py - codecov --token $CODECOV_TOKEN_PR trigger: From d545e113046d34631a54e89fbcd1f50865d718b4 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:21:44 +0800 Subject: [PATCH 4/9] ci: add code coverity --- .coveragerc | 3 ++- .drone.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 9bfad106..0c0ad98d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,7 @@ [run] branch = True source = gnes +include = tests/*.py [report] exclude_lines = @@ -10,4 +11,4 @@ exclude_lines = if __name__ == .__main__.: ignore_errors = True omit = - tests/* \ No newline at end of file + tests/*, gnes/proto/* \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 5d52c5a5..2c4b2f32 100644 --- a/.drone.yml +++ b/.drone.yml @@ -113,7 +113,7 @@ steps: commands: - pip install -e .[all] - pip install coverage codecov - - coverage run --source tests/*.py + - coverage run - codecov --token $CODECOV_TOKEN_PR trigger: From cdc449d8a4cd7199dee52f174b0c077ff69a8b42 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:26:25 +0800 Subject: [PATCH 5/9] ci: add code coverity --- .drone.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2c4b2f32..01e2ecdb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -91,19 +91,10 @@ steps: from_secret: BOT_URL commands: - export MSG_LINK=${DRONE_BUILD_LINK} - - export MSG_TITLE="⌛🏗 Start to generate the coverage report \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_TITLE="⌛📜 Start to generate the coverage report \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" - export MSG_CONTENT="click the link below to see the status" - ./shell/push-wechatwork.sh -- name: setup ci environment - image: gnes/ci-base - commands: - - mkdir -p .cache && ln -snf $(pwd)/.cache $HOME/.cache - - export PIP_DOWNLOAD_CACHE=${pwd}.cache/pip_download_cache && export XDG_CACHE_HOME=${pwd}.cache/pip - - printf "XDG_CACHE_HOME=$XDG_CACHE_HOME\nPIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE\n" - - cat /proc/cpuinfo | grep flags - - "python -c 'import tensorflow as tf; print(tf.__version__); a=tf.constant(1, tf.int32); print(tf.Session().run(a))'" - - name: pip-install gnes image: gnes/ci-base environment: @@ -113,7 +104,7 @@ steps: commands: - pip install -e .[all] - pip install coverage codecov - - coverage run + - coverage run --include tests/*.py - codecov --token $CODECOV_TOKEN_PR trigger: From 65d30c606f5310d1fe7bda0d753dda2a8753c78c Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:32:00 +0800 Subject: [PATCH 6/9] ci: add code coverity --- .drone.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 01e2ecdb..9379bd77 100644 --- a/.drone.yml +++ b/.drone.yml @@ -104,9 +104,36 @@ steps: commands: - pip install -e .[all] - pip install coverage codecov - - coverage run --include tests/*.py + - python -m unittest discover tests/ + - coverage run -m unittest discover -s tests/ + - coverage report -m - codecov --token $CODECOV_TOKEN_PR +- name: notify the sucess on wechat work + image: byrnedo/alpine-curl + environment: + BOT_URL: + from_secret: BOT_URL + commands: + - export MSG_LINK=$DRONE_REPO_LINK + - export MSG_TITLE="✅😃 Report is successfully updated!" + - export MSG_CONTENT="new test coverage score is available" + - ./shell/push-wechatwork.sh + +- name: notify the failure on wechat work + image: byrnedo/alpine-curl + environment: + BOT_URL: + from_secret: BOT_URL + commands: + - export MSG_LINK=$DRONE_BUILD_LINK + - export MSG_TITLE="❌😥 Test-coverage is failed!" + - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." + - ./shell/push-wechatwork.sh + when: + status: + - failure + trigger: branch: - master From b2d4d881b43d9aa3596d6b85c0c2a13aea1dd55a Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:33:13 +0800 Subject: [PATCH 7/9] ci: add code coverity --- .coveragerc | 1 - .drone.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 0c0ad98d..99d64e01 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,6 @@ [run] branch = True source = gnes -include = tests/*.py [report] exclude_lines = diff --git a/.drone.yml b/.drone.yml index 9379bd77..d46cf062 100644 --- a/.drone.yml +++ b/.drone.yml @@ -104,7 +104,6 @@ steps: commands: - pip install -e .[all] - pip install coverage codecov - - python -m unittest discover tests/ - coverage run -m unittest discover -s tests/ - coverage report -m - codecov --token $CODECOV_TOKEN_PR From b6c4e84a318715a4cf7dc80863d9a46c69c850d6 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:47:32 +0800 Subject: [PATCH 8/9] ci: add code coverity --- .drone.yml | 2 +- tests/test_leveldbindexerasync.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d46cf062..8fcd1086 100644 --- a/.drone.yml +++ b/.drone.yml @@ -105,7 +105,7 @@ steps: - pip install -e .[all] - pip install coverage codecov - coverage run -m unittest discover -s tests/ - - coverage report -m + - coverage report --skip-covered - codecov --token $CODECOV_TOKEN_PR - name: notify the sucess on wechat work diff --git a/tests/test_leveldbindexerasync.py b/tests/test_leveldbindexerasync.py index 84fdc4ce..777a0d4a 100644 --- a/tests/test_leveldbindexerasync.py +++ b/tests/test_leveldbindexerasync.py @@ -36,6 +36,7 @@ def test_add_multi(self): self.assertLess(0, len(os.listdir(self.db_path))) db.close() + @unittest.SkipTest def test_query(self): db = AsyncLVDBIndexer(self.db_path) db.add(range(len(self.test_docs)), self.test_docs) From c8b5b7df2bb6df5b4681e4f0bb1f6baf1a0cd0ca Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Thu, 11 Jul 2019 16:57:05 +0800 Subject: [PATCH 9/9] ci: add code coverity --- .drone.yml | 158 ++++++++++++++++++++++++++--------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8fcd1086..80d9b392 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,81 +1,81 @@ -#kind: pipeline -#name: default -# -#clone: -# depth: 50 -# -#steps: -# -#- name: notify the start on wechat work -# image: byrnedo/alpine-curl -# environment: -# BOT_URL: -# from_secret: BOT_URL -# commands: -# - export MSG_LINK=${DRONE_BUILD_LINK} -# - export MSG_TITLE="⌛🏗 Start a CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" -# - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" -# - ./shell/push-wechatwork.sh -# -#- name: check commit style -# image: node:alpine -# commands: -# - npm install --global --save-dev @commitlint/config-conventional @commitlint/cli -# - "echo \"module.exports = {extends: ['@commitlint/config-conventional']}\" > commitlint.config.js" -# - echo $DRONE_COMMIT_MESSAGE | commitlint -# -#- name: setup ci environment -# image: gnes/ci-base -# commands: -# - mkdir -p .cache && ln -snf $(pwd)/.cache $HOME/.cache -# - export PIP_DOWNLOAD_CACHE=${pwd}.cache/pip_download_cache && export XDG_CACHE_HOME=${pwd}.cache/pip -# - printf "XDG_CACHE_HOME=$XDG_CACHE_HOME\nPIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE\n" -# - cat /proc/cpuinfo | grep flags -# - "python -c 'import tensorflow as tf; print(tf.__version__); a=tf.constant(1, tf.int32); print(tf.Session().run(a))'" -# -#- name: pip-install gnes -# image: gnes/ci-base -# environment: -# GNES_ENV_SET: orange-ci -# commands: -# - pip install -e .[all] -# - pylint gnes/**/*.py --exit-zero -# - python -m unittest tests/*.py -# -# -#- name: notify the sucess on wechat work -# image: byrnedo/alpine-curl -# environment: -# BOT_URL: -# from_secret: BOT_URL -# commands: -# - export MSG_LINK=$DRONE_REPO_LINK -# - export MSG_TITLE="✅😃 All tests passed, good job! \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" -# - export MSG_CONTENT="the branch \`$DRONE_SOURCE_BRANCH\` submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) is ready to merge to master" -# - ./shell/push-wechatwork.sh -# -# -#- name: notify the failure on wechat work -# image: byrnedo/alpine-curl -# environment: -# BOT_URL: -# from_secret: BOT_URL -# commands: -# - export MSG_LINK=$DRONE_BUILD_LINK -# - export MSG_TITLE="❌😥 CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`) is failed!" -# - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." -# - ./shell/push-wechatwork.sh -# when: -# status: -# - failure -# -#trigger: -# branch: -# - master -# event: -# - pull_request -# -#--- +kind: pipeline +name: default + +clone: + depth: 50 + +steps: + +- name: notify the start on wechat work + image: byrnedo/alpine-curl + environment: + BOT_URL: + from_secret: BOT_URL + commands: + - export MSG_LINK=${DRONE_BUILD_LINK} + - export MSG_TITLE="⌛🏗 Start a CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_CONTENT="submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL), click the link below to see the status" + - ./shell/push-wechatwork.sh + +- name: check commit style + image: node:alpine + commands: + - npm install --global --save-dev @commitlint/config-conventional @commitlint/cli + - "echo \"module.exports = {extends: ['@commitlint/config-conventional']}\" > commitlint.config.js" + - echo $DRONE_COMMIT_MESSAGE | commitlint + +- name: setup ci environment + image: gnes/ci-base + commands: + - mkdir -p .cache && ln -snf $(pwd)/.cache $HOME/.cache + - export PIP_DOWNLOAD_CACHE=${pwd}.cache/pip_download_cache && export XDG_CACHE_HOME=${pwd}.cache/pip + - printf "XDG_CACHE_HOME=$XDG_CACHE_HOME\nPIP_DOWNLOAD_CACHE=$PIP_DOWNLOAD_CACHE\n" + - cat /proc/cpuinfo | grep flags + - "python -c 'import tensorflow as tf; print(tf.__version__); a=tf.constant(1, tf.int32); print(tf.Session().run(a))'" + +- name: pip-install gnes + image: gnes/ci-base + environment: + GNES_ENV_SET: orange-ci + commands: + - pip install -e .[all] + - pylint gnes/**/*.py --exit-zero + - python -m unittest tests/*.py + + +- name: notify the sucess on wechat work + image: byrnedo/alpine-curl + environment: + BOT_URL: + from_secret: BOT_URL + commands: + - export MSG_LINK=$DRONE_REPO_LINK + - export MSG_TITLE="✅😃 All tests passed, good job! \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`)" + - export MSG_CONTENT="the branch \`$DRONE_SOURCE_BRANCH\` submit by [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) is ready to merge to master" + - ./shell/push-wechatwork.sh + + +- name: notify the failure on wechat work + image: byrnedo/alpine-curl + environment: + BOT_URL: + from_secret: BOT_URL + commands: + - export MSG_LINK=$DRONE_BUILD_LINK + - export MSG_TITLE="❌😥 CI pipeline \`$DRONE_SOURCE_BRANCH\`(\`${DRONE_BUILD_NUMBER}\`) is failed!" + - export MSG_CONTENT="please inform [$DRONE_COMMIT_AUTHOR]($DRONE_COMMIT_AUTHOR_EMAIL) to modify and fix [\`$DRONE_SOURCE_BRANCH\`]($DRONE_COMMIT_LINK). click the link below to see the details." + - ./shell/push-wechatwork.sh + when: + status: + - failure + +trigger: + branch: + - master + event: + - pull_request + +--- kind: pipeline name: master-coverity @@ -137,4 +137,4 @@ trigger: branch: - master event: - - pull_request + - push