From 426d370413d19f85b9b09da9f5eb14918e3398f1 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Thu, 25 Mar 2021 04:03:44 +0000 Subject: [PATCH] fix ci --- .travis.yml | 3 +-- .travis/install.sh | 37 +++++++++++++++++++++++++++++++++++++ .travis/precommit.sh | 10 ++++++---- .travis/unittest.sh | 33 +++++++-------------------------- env.sh | 2 +- requirements.txt | 2 +- setup.sh | 1 + 7 files changed, 54 insertions(+), 34 deletions(-) create mode 100755 .travis/install.sh diff --git a/.travis.yml b/.travis.yml index 538e9df2a..b65b9a5fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,9 +25,8 @@ before_install: script: - exit_code=0 - - .travis/precommit.sh || exit_code=$(( exit_code | $? )) - docker run -i --rm -v "$PWD:/py_unittest" paddlepaddle/paddle:latest /bin/bash -c - 'cd /py_unittest; source env.sh; bash .travis/unittest.sh' || exit_code=$(( exit_code | $? )) + 'cd /py_unittest && bash .travis/precommit.sh && source env.sh && bash .travis/unittest.sh' || exit_code=$(( exit_code | $? )) exit $exit_code notifications: diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 000000000..ebb9fa657 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +setup_env(){ + cd tools && make && cd - +} + +install(){ + if [ -f "setup.sh" ]; then + bash setup.sh + #export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + fi + if [ $? != 0 ]; then + exit 1 + fi +} + +print_env(){ + cat /etc/lsb-release + gcc -v + g++ -v +} + +abort(){ + echo "Run install failed" 1>&2 + echo "Please check your code" 1>&2 + exit 1 +} + +trap 'abort' 0 +set -e + +print_env +setup_env +source tools/venv/bin/activate +install + +trap : 0 diff --git a/.travis/precommit.sh b/.travis/precommit.sh index bcbfb2bb5..e24447453 100755 --- a/.travis/precommit.sh +++ b/.travis/precommit.sh @@ -1,16 +1,18 @@ #!/bin/bash + function abort(){ echo "Your commit not fit PaddlePaddle code style" 1>&2 echo "Please use pre-commit scripts to auto-format your code" 1>&2 exit 1 } + trap 'abort' 0 set -e -cd `dirname $0` -cd .. -export PATH=/usr/bin:$PATH -pre-commit install + +source tools/venv/bin/activate + +python3 --version if ! pre-commit run -a ; then ls -lh diff --git a/.travis/unittest.sh b/.travis/unittest.sh index 476c2d9df..8e3071d05 100755 --- a/.travis/unittest.sh +++ b/.travis/unittest.sh @@ -1,43 +1,24 @@ #!/bin/bash -abort(){ - echo "Run unittest failed" 1>&2 - echo "Please check your code" 1>&2 - exit 1 -} - -print_env(){ - cat /etc/lsb-release - gcc -v - g++ -v -} - unittest(){ cd $1 > /dev/null - if [ -f "setup.sh" ]; then - bash setup.sh - export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - fi - if [ $? != 0 ]; then - exit 1 - fi find . -path ./tools/venv -prune -false -o -name 'tests' -type d -print0 | \ xargs -0 -I{} -n1 bash -c \ 'python3 -m unittest discover -v -s {}' cd - > /dev/null } +abort(){ + echo "Run unittest failed" 1>&2 + echo "Please check your code" 1>&2 + exit 1 +} + trap 'abort' 0 set -e - -print_env - - -cd tools; make; cd - -. tools/venv/bin/activate +source tools/venv/bin/activate pip3 install pytest - unittest . trap : 0 diff --git a/env.sh b/env.sh index 131c6495a..5486a1da3 100644 --- a/env.sh +++ b/env.sh @@ -7,4 +7,4 @@ export LC_ALL=C export PYTHONIOENCODING=UTF-8 export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} -export export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ diff --git a/requirements.txt b/requirements.txt index 585becbaf..d95db07bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ tensorboardX yacs typeguard pre-commit -paddlepaddle-gpu==2.0.0 +#paddlepaddle-gpu==2.0.0 diff --git a/setup.sh b/setup.sh index e2c38af77..c681583b8 100644 --- a/setup.sh +++ b/setup.sh @@ -6,6 +6,7 @@ if [ $(id -u) -eq 0 ]; then fi if [ -e /etc/lsb-release ];then + #${SUDO} apt-get update ${SUDO} apt-get install -y pkg-config libflac-dev libogg-dev libvorbis-dev libboost-dev swig python3-dev fi