From 2e79ce331824897fdc50fde195de69154f62566f Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 21:22:12 +0000 Subject: [PATCH 01/13] lint: run shfmt Related to #2834 and #2969. --- scripts/build_package.sh | 28 ++++++------- scripts/build_posix.sh | 70 ++++++++++++++------------------ scripts/build_snap.sh | 18 ++++----- scripts/ci/before_install.sh | 74 +++++++++++++++++----------------- scripts/ci/check_patch.sh | 2 +- scripts/ci/check_python.sh | 10 ++--- scripts/ci/deploy_condition.sh | 6 +-- scripts/ci/install_azurite.sh | 14 +++---- scripts/ci/install_hadoop.sh | 16 ++++---- scripts/ci/install_oss.sh | 6 +-- scripts/ci/retry.sh | 4 +- scripts/ci/script.sh | 2 +- scripts/completion/dvc.bash | 38 ++++++++--------- 13 files changed, 140 insertions(+), 148 deletions(-) diff --git a/scripts/build_package.sh b/scripts/build_package.sh index 1266ead8bf..7c61b32cf3 100755 --- a/scripts/build_package.sh +++ b/scripts/build_package.sh @@ -4,26 +4,26 @@ set -e set -x if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" >&2 - exit 1 + echo "Please run this script from repository root" >&2 + exit 1 fi -echo 'PKG = "pip"' > dvc/utils/build.py +echo 'PKG = "pip"' >dvc/utils/build.py python setup.py sdist python setup.py bdist_wheel --universal # Make sure we have a correct version if [[ -n "$TRAVIS_TAG" ]]; then - pip uninstall -y dvc - if which dvc; then - echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 - exit 1 - fi - pip install dist/dvc-*.whl - if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then - echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 - exit 1 - fi - pip uninstall -y dvc + pip uninstall -y dvc + if which dvc; then + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 + exit 1 + fi + pip install dist/dvc-*.whl + if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 + exit 1 + fi + pip uninstall -y dvc fi diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index 9903cf9043..a43f1c4ab8 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -27,8 +27,7 @@ else BASH_CMPLT_DIR=usr/local/etc/bash_completion.d fi -print_error() -{ +print_error() { echo -e "\e[31m$1\e[0m" >&2 } @@ -39,39 +38,34 @@ fi trap 'print_error "FAIL"; exit 1' ERR -print_info() -{ +print_info() { echo -e "\e[32m$1\e[0m" } -command_exists() -{ - command -v $1 > /dev/null 2>&1 +command_exists() { + command -v $1 >/dev/null 2>&1 } -fpm_build() -{ +fpm_build() { print_info "Building $1..." VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") fpm -s dir \ - -f \ - -t $1 \ - --description "$DESC" \ - $FPM_FLAGS \ - -n dvc \ - -v $VERSION \ - -C $BUILD_DIR \ - $FPM_PACKAGE_DIRS + -f \ + -t $1 \ + --description "$DESC" \ + $FPM_FLAGS \ + -n dvc \ + -v $VERSION \ + -C $BUILD_DIR \ + $FPM_PACKAGE_DIRS } -cleanup() -{ +cleanup() { print_info "Cleaning up..." rm -rf build } -install_dependencies() -{ +install_dependencies() { print_info "Installing fpm..." if command_exists dnf; then sudo dnf install ruby-devel gcc make rpm-build @@ -87,7 +81,7 @@ install_dependencies() fi gem install --no-document fpm - + # https://github.com/iterative/dvc/issues/2970 gem uninstall -i /Users/travis/.rvm/gems/ruby-2.4.3@global rubygems-bundler @@ -96,14 +90,13 @@ install_dependencies() pip install -r scripts/build-requirements.txt } -build_dvc() -{ +build_dvc() { print_info "Building dvc binary..." pyinstaller \ - --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ - --name dvc \ - --distpath $LIB_DIR \ - --specpath $BUILD_DIR + --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ + --name dvc \ + --distpath $LIB_DIR \ + --specpath $BUILD_DIR $LIB_DIR/dvc/dvc --help @@ -118,21 +111,20 @@ build_dvc() $BIN_DIR/dvc --help fi - # NOTE: temporarily not adding scripts to mac package. See [1] - # [1] https://github.com/iterative/dvc/issues/2585 - if [[ "$(uname)" == 'Linux' ]]; then - mkdir -p $BUILD_DIR/$BASH_CMPLT_DIR - cp scripts/completion/dvc.bash $BUILD_DIR/$BASH_CMPLT_DIR/dvc + # NOTE: temporarily not adding scripts to mac package. See [1] + # [1] https://github.com/iterative/dvc/issues/2585 + if [[ "$(uname)" == 'Linux' ]]; then + mkdir -p $BUILD_DIR/$BASH_CMPLT_DIR + cp scripts/completion/dvc.bash $BUILD_DIR/$BASH_CMPLT_DIR/dvc - mkdir -p $BUILD_DIR/$ZSH_CMPLT_DIR - cp scripts/completion/dvc.zsh $BUILD_DIR/$ZSH_CMPLT_DIR - fi + mkdir -p $BUILD_DIR/$ZSH_CMPLT_DIR + cp scripts/completion/dvc.zsh $BUILD_DIR/$ZSH_CMPLT_DIR + fi } -build() -{ +build() { cleanup - echo "PKG = \"$1\"" > dvc/utils/build.py + echo "PKG = \"$1\"" >dvc/utils/build.py build_dvc fpm_build $1 } diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh index ce78aea583..1ef6776bd3 100755 --- a/scripts/build_snap.sh +++ b/scripts/build_snap.sh @@ -3,24 +3,24 @@ set -e set -x if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" - exit 1 + echo "Please run this script from repository root" + exit 1 fi sudo snapcraft --use-lxd pip uninstall -y dvc if which dvc; then - echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 - exit 1 + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 + exit 1 fi sudo snap install --dangerous --classic dvc_*.snap if [[ -n "$TRAVIS_TAG" ]]; then - # Make sure we have a correct version - if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then - echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 - exit 1 - fi + # Make sure we have a correct version + if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 + exit 1 + fi fi # ensure basic commands can run # N.B.: cannot run `dvc get` on travis (#2956) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 2e9461be41..c154a62b6a 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -6,53 +6,53 @@ set -e scriptdir="$(dirname $0)" if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ulimit -a - sudo sysctl -w kern.maxproc=2048 - sudo sysctl -w kern.maxprocperuid=2048 - echo '\nulimit -u 2048' >> ~/.bash_profile - ulimit -a + ulimit -a + sudo sysctl -w kern.maxproc=2048 + sudo sysctl -w kern.maxprocperuid=2048 + echo '\nulimit -u 2048' >>~/.bash_profile + ulimit -a fi -echo > env.sh +echo >env.sh if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]]; then - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then - # NOTE: ssh keys for ssh test to be able to ssh to the localhost - ssh-keygen -t rsa -N "" -f mykey - mkdir -p ~/.ssh - cp mykey ~/.ssh/id_rsa - cp mykey.pub ~/.ssh/id_rsa.pub - cat mykey.pub >> ~/.ssh/authorized_keys - ssh-keyscan localhost >> ~/.ssh/known_hosts - ssh localhost ls &> /dev/null - ssh-keyscan 127.0.0.1 >> ~/.ssh/known_hosts - ssh 127.0.0.1 ls &> /dev/null - ssh-keyscan 0.0.0.0 >> ~/.ssh/known_hosts - ssh 0.0.0.0 ls &> /dev/null - fi - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - bash "$scriptdir/install_azurite.sh" - bash "$scriptdir/install_oss.sh" - bash "$scriptdir/install_hadoop.sh" - fi - - if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then - brew install openssl - $scriptdir/retry.sh brew cask install google-cloud-sdk - fi + if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then + # NOTE: ssh keys for ssh test to be able to ssh to the localhost + ssh-keygen -t rsa -N "" -f mykey + mkdir -p ~/.ssh + cp mykey ~/.ssh/id_rsa + cp mykey.pub ~/.ssh/id_rsa.pub + cat mykey.pub >>~/.ssh/authorized_keys + ssh-keyscan localhost >>~/.ssh/known_hosts + ssh localhost ls &>/dev/null + ssh-keyscan 127.0.0.1 >>~/.ssh/known_hosts + ssh 127.0.0.1 ls &>/dev/null + ssh-keyscan 0.0.0.0 >>~/.ssh/known_hosts + ssh 0.0.0.0 ls &>/dev/null + fi + + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + bash "$scriptdir/install_azurite.sh" + bash "$scriptdir/install_oss.sh" + bash "$scriptdir/install_hadoop.sh" + fi + + if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then + brew install openssl + $scriptdir/retry.sh brew cask install google-cloud-sdk + fi fi if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - $scriptdir/retry.sh choco install python --version 3.7.5 - echo 'PATH="/c/Python37:/c/Python37/Scripts:$PATH"' >> env.sh + $scriptdir/retry.sh choco install python --version 3.7.5 + echo 'PATH="/c/Python37:/c/Python37/Scripts:$PATH"' >>env.sh elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ln -s -f /usr/local/bin/python3 /usr/local/bin/python - ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip + ln -s -f /usr/local/bin/python3 /usr/local/bin/python + ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi if [[ -n "$TRAVIS_TAG" ]]; then - echo "export SNAP_CHANNEL=stable" >> env.sh + echo "export SNAP_CHANNEL=stable" >>env.sh else - echo "export SNAP_CHANNEL=edge" >> env.sh + echo "export SNAP_CHANNEL=edge" >>env.sh fi diff --git a/scripts/ci/check_patch.sh b/scripts/ci/check_patch.sh index 0ee8f8302c..f357086349 100755 --- a/scripts/ci/check_patch.sh +++ b/scripts/ci/check_patch.sh @@ -3,7 +3,7 @@ set -x set -e -pip install Pygments collective.checkdocs pre-commit +pip install Pygments collective.checkdocs pre-commit # stop the build if there are any readme formatting errors python setup.py checkdocs diff --git a/scripts/ci/check_python.sh b/scripts/ci/check_python.sh index 08e256cc46..77e86ecbef 100644 --- a/scripts/ci/check_python.sh +++ b/scripts/ci/check_python.sh @@ -4,15 +4,15 @@ set -e set -x if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - where python - where pip + where python + where pip else - which python - which pip + which python + which pip fi py_ver="$(python -c 'import sys; print(sys.version[0])')" if [[ "$py_ver" != 3 ]]; then - exit 1 + exit 1 fi diff --git a/scripts/ci/deploy_condition.sh b/scripts/ci/deploy_condition.sh index 9c2a600b5d..1309f76289 100755 --- a/scripts/ci/deploy_condition.sh +++ b/scripts/ci/deploy_condition.sh @@ -3,13 +3,13 @@ set -e if [[ $TRAVIS_EVENT_TYPE = pull_request || $TRAVIS_EVENT_TPYE = cron ]]; then - exit 2 + exit 2 fi # positional args are assumed to be file glob patterns to deploy if [[ ${#} -ge 1 ]]; then - # ensure at least one file exists - [[ -n "$(ls $@ 2>/dev/null)" ]] || exit 3 + # ensure at least one file exists + [[ -n "$(ls $@ 2>/dev/null)" ]] || exit 3 fi echo true diff --git a/scripts/ci/install_azurite.sh b/scripts/ci/install_azurite.sh index 813d5c03b3..30a7ef9437 100755 --- a/scripts/ci/install_azurite.sh +++ b/scripts/ci/install_azurite.sh @@ -4,11 +4,11 @@ set -e set -x # install docker - export DEBIAN_FRONTEND=noninteractive - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update - sudo apt-get install -y docker-ce +export DEBIAN_FRONTEND=noninteractive +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt-get update +sudo apt-get install -y docker-ce # run azurite sudo docker run -d --restart always -e executable=blob -p 10000:10000 \ @@ -17,5 +17,5 @@ sudo docker run -d --restart always -e executable=blob -p 10000:10000 \ azurite -l /data --blobHost 0.0.0.0 # save secrets -echo "export AZURE_STORAGE_CONTAINER_NAME='travis-tests'" >> env.sh -echo "export AZURE_STORAGE_CONNECTION_STRING='DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;'" >> env.sh +echo "export AZURE_STORAGE_CONTAINER_NAME='travis-tests'" >>env.sh +echo "export AZURE_STORAGE_CONNECTION_STRING='DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;'" >>env.sh diff --git a/scripts/ci/install_hadoop.sh b/scripts/ci/install_hadoop.sh index ee7e74845c..eaf50e977b 100755 --- a/scripts/ci/install_hadoop.sh +++ b/scripts/ci/install_hadoop.sh @@ -17,14 +17,14 @@ sudo mkdir hadoop sudo mv hadoop-2.6.5/* hadoop/ popd -echo "export HADOOP_HOME=/usr/local/hadoop" >> env.sh -echo "export HADOOP_MAPRED_HOME=/usr/local/hadoop" >> env.sh -echo "export HADOOP_COMMON_HOME=/usr/local/hadoop" >> env.sh -echo "export HADOOP_HDFS_HOME=/usr/local/hadoop" >> env.sh -echo "export YARN_HOME=/usr/local/hadoop" >> env.sh -echo "export HADOOP_COMMON_LIB_NATIVE_DIR=/usr/local/hadoop/lib/native" >> env.sh -echo "export JAVA_HOME=/usr/" >> env.sh -echo "export PATH=\$PATH:/usr/local/hadoop/sbin:/usr/local/hadoop/bin:$JAVA_PATH/bin" >> env.sh +echo "export HADOOP_HOME=/usr/local/hadoop" >>env.sh +echo "export HADOOP_MAPRED_HOME=/usr/local/hadoop" >>env.sh +echo "export HADOOP_COMMON_HOME=/usr/local/hadoop" >>env.sh +echo "export HADOOP_HDFS_HOME=/usr/local/hadoop" >>env.sh +echo "export YARN_HOME=/usr/local/hadoop" >>env.sh +echo "export HADOOP_COMMON_LIB_NATIVE_DIR=/usr/local/hadoop/lib/native" >>env.sh +echo "export JAVA_HOME=/usr/" >>env.sh +echo "export PATH=\$PATH:/usr/local/hadoop/sbin:/usr/local/hadoop/bin:$JAVA_PATH/bin" >>env.sh source env.sh diff --git a/scripts/ci/install_oss.sh b/scripts/ci/install_oss.sh index 11f4da7cd0..a56ac7cb79 100644 --- a/scripts/ci/install_oss.sh +++ b/scripts/ci/install_oss.sh @@ -5,6 +5,6 @@ set -euo pipefail git clone https://github.com/iterative/oss-emulator.git sudo docker image build -t oss:1.0 oss-emulator sudo docker run --detach --restart always -p 8880:8880 --name oss-emulator oss:1.0 -echo "export OSS_ENDPOINT='localhost:8880'" >> env.sh -echo "export OSS_ACCESS_KEY_ID='AccessKeyID'" >> env.sh -echo "export OSS_ACCESS_KEY_SECRET='AccessKeySecret'" >> env.sh +echo "export OSS_ENDPOINT='localhost:8880'" >>env.sh +echo "export OSS_ACCESS_KEY_ID='AccessKeyID'" >>env.sh +echo "export OSS_ACCESS_KEY_SECRET='AccessKeySecret'" >>env.sh diff --git a/scripts/ci/retry.sh b/scripts/ci/retry.sh index 490f92908a..cd2ff129fa 100755 --- a/scripts/ci/retry.sh +++ b/scripts/ci/retry.sh @@ -4,8 +4,8 @@ set -e N_RETRIES=3 for i in $(seq $N_RETRIES); do - echo "Attempt #$i" - $@ && exit $? + echo "Attempt #$i" + $@ && exit $? done exit $? diff --git a/scripts/ci/script.sh b/scripts/ci/script.sh index 48e7db623a..f9b6a72477 100644 --- a/scripts/ci/script.sh +++ b/scripts/ci/script.sh @@ -6,7 +6,7 @@ set -e python -mtests if [[ "$TRAVIS_PULL_REQUEST" == "false" && \ - "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then + "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then pip install codecov codecov fi diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 8c2d3b0612..40a2604410 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -71,31 +71,31 @@ _dvc_version='' # x="hello" # ${!x} -> ${hello} -> "world" # -_dvc () { - replace_hyphen () { - echo $(echo $1 | sed 's/-/_/g') - } +_dvc() { + replace_hyphen() { + echo $(echo $1 | sed 's/-/_/g') + } - local word="${COMP_WORDS[COMP_CWORD]}" + local word="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=() + COMPREPLY=() - if [ "${COMP_CWORD}" -eq 1 ]; then - case "$word" in - -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; - *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; - esac - elif [ "${COMP_CWORD}" -eq 2 ]; then - local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})" + if [ "${COMP_CWORD}" -eq 1 ]; then + case "$word" in + -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; + *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; + esac + elif [ "${COMP_CWORD}" -eq 2 ]; then + local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})" - COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) - elif [ "${COMP_CWORD}" -eq 3 ]; then - local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})_$(replace_hyphen ${COMP_WORDS[2]})" + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) + elif [ "${COMP_CWORD}" -eq 3 ]; then + local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})_$(replace_hyphen ${COMP_WORDS[2]})" - COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) - fi + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) + fi - return 0 + return 0 } complete -F _dvc dvc From 10c5103ed7e189c815d9948d9fa6d2275f8b3007 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:26:49 +0000 Subject: [PATCH 02/13] lint: run shfmt -i 2 --- scripts/build_package.sh | 26 ++--- scripts/build_posix.sh | 170 ++++++++++++++++----------------- scripts/build_snap.sh | 18 ++-- scripts/ci/before_install.sh | 72 +++++++------- scripts/ci/check_python.sh | 10 +- scripts/ci/deploy_condition.sh | 6 +- scripts/ci/install.sh | 8 +- scripts/ci/install_azurite.sh | 6 +- scripts/ci/retry.sh | 4 +- scripts/ci/script.sh | 6 +- scripts/completion/dvc.bash | 36 +++---- scripts/pypi_upload.sh | 4 +- 12 files changed, 183 insertions(+), 183 deletions(-) diff --git a/scripts/build_package.sh b/scripts/build_package.sh index 7c61b32cf3..4818d7a6e2 100755 --- a/scripts/build_package.sh +++ b/scripts/build_package.sh @@ -4,8 +4,8 @@ set -e set -x if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" >&2 - exit 1 + echo "Please run this script from repository root" >&2 + exit 1 fi echo 'PKG = "pip"' >dvc/utils/build.py @@ -15,15 +15,15 @@ python setup.py bdist_wheel --universal # Make sure we have a correct version if [[ -n "$TRAVIS_TAG" ]]; then - pip uninstall -y dvc - if which dvc; then - echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 - exit 1 - fi - pip install dist/dvc-*.whl - if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then - echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 - exit 1 - fi - pip uninstall -y dvc + pip uninstall -y dvc + if which dvc; then + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 + exit 1 + fi + pip install dist/dvc-*.whl + if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 + exit 1 + fi + pip uninstall -y dvc fi diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index a43f1c4ab8..83386e40d7 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -4,13 +4,13 @@ set -e set -x if [[ "$(uname)" == 'Linux' ]]; then - INSTALL_DIR=usr - FPM_FLAGS= + INSTALL_DIR=usr + FPM_FLAGS= else - INSTALL_DIR=usr/local - FPM_FLAGS='--osxpkg-identifier-prefix com.iterative' - FPM_FLAGS+=' --after-install scripts/fpm/after-install.sh' - FPM_FLAGS+=' --after-remove scripts/fpm/after-remove.sh' + INSTALL_DIR=usr/local + FPM_FLAGS='--osxpkg-identifier-prefix com.iterative' + FPM_FLAGS+=' --after-install scripts/fpm/after-install.sh' + FPM_FLAGS+=' --after-remove scripts/fpm/after-remove.sh' fi BUILD_DIR=build @@ -21,121 +21,121 @@ LIB_DIR=$BUILD_DIR/$INSTALL_DIR/lib FPM_PACKAGE_DIRS="usr" ZSH_CMPLT_DIR=usr/share/zsh/site-functions/_dvc if [[ "$(uname)" == 'Linux' ]]; then - BASH_CMPLT_DIR=etc/bash_completion.d - FPM_PACKAGE_DIRS="$FPM_PACKAGE_DIRS etc" + BASH_CMPLT_DIR=etc/bash_completion.d + FPM_PACKAGE_DIRS="$FPM_PACKAGE_DIRS etc" else - BASH_CMPLT_DIR=usr/local/etc/bash_completion.d + BASH_CMPLT_DIR=usr/local/etc/bash_completion.d fi print_error() { - echo -e "\e[31m$1\e[0m" >&2 + echo -e "\e[31m$1\e[0m" >&2 } if [ ! -d "dvc" ]; then - print_error "Please run this script from repository root" - exit 1 + print_error "Please run this script from repository root" + exit 1 fi trap 'print_error "FAIL"; exit 1' ERR print_info() { - echo -e "\e[32m$1\e[0m" + echo -e "\e[32m$1\e[0m" } command_exists() { - command -v $1 >/dev/null 2>&1 + command -v $1 >/dev/null 2>&1 } fpm_build() { - print_info "Building $1..." - VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") - fpm -s dir \ - -f \ - -t $1 \ - --description "$DESC" \ - $FPM_FLAGS \ - -n dvc \ - -v $VERSION \ - -C $BUILD_DIR \ - $FPM_PACKAGE_DIRS + print_info "Building $1..." + VERSION=$(python -c "import dvc; from dvc import __version__; print(str(__version__))") + fpm -s dir \ + -f \ + -t $1 \ + --description "$DESC" \ + $FPM_FLAGS \ + -n dvc \ + -v $VERSION \ + -C $BUILD_DIR \ + $FPM_PACKAGE_DIRS } cleanup() { - print_info "Cleaning up..." - rm -rf build + print_info "Cleaning up..." + rm -rf build } install_dependencies() { - print_info "Installing fpm..." - if command_exists dnf; then - sudo dnf install ruby-devel gcc make rpm-build - elif command_exists yum; then - sudo yum install ruby-devel gcc make rpm-build - elif command_exists apt-get; then - sudo apt-get update -y - sudo apt-get install ruby-dev build-essential rpm python-pip python-dev - elif command_exists brew; then - brew install ruby - else - echo "Unable to install fpm dependencies" && exit 1 - fi - - gem install --no-document fpm - - # https://github.com/iterative/dvc/issues/2970 - gem uninstall -i /Users/travis/.rvm/gems/ruby-2.4.3@global rubygems-bundler - - print_info "Installing requirements..." - pip install .[all] - pip install -r scripts/build-requirements.txt + print_info "Installing fpm..." + if command_exists dnf; then + sudo dnf install ruby-devel gcc make rpm-build + elif command_exists yum; then + sudo yum install ruby-devel gcc make rpm-build + elif command_exists apt-get; then + sudo apt-get update -y + sudo apt-get install ruby-dev build-essential rpm python-pip python-dev + elif command_exists brew; then + brew install ruby + else + echo "Unable to install fpm dependencies" && exit 1 + fi + + gem install --no-document fpm + + # https://github.com/iterative/dvc/issues/2970 + gem uninstall -i /Users/travis/.rvm/gems/ruby-2.4.3@global rubygems-bundler + + print_info "Installing requirements..." + pip install .[all] + pip install -r scripts/build-requirements.txt } build_dvc() { - print_info "Building dvc binary..." - pyinstaller \ - --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ - --name dvc \ - --distpath $LIB_DIR \ - --specpath $BUILD_DIR - - $LIB_DIR/dvc/dvc --help - - # NOTE: in osxpkg fpm replaces symlinks with actual file that it - # points to, so we need to use after-install hook. See FPM_FLAGS - # above. - if [[ "$(uname)" == 'Linux' ]]; then - mkdir -p $BIN_DIR - pushd $BIN_DIR - ln -s ../lib/dvc/dvc dvc - popd - $BIN_DIR/dvc --help - fi - - # NOTE: temporarily not adding scripts to mac package. See [1] - # [1] https://github.com/iterative/dvc/issues/2585 - if [[ "$(uname)" == 'Linux' ]]; then - mkdir -p $BUILD_DIR/$BASH_CMPLT_DIR - cp scripts/completion/dvc.bash $BUILD_DIR/$BASH_CMPLT_DIR/dvc - - mkdir -p $BUILD_DIR/$ZSH_CMPLT_DIR - cp scripts/completion/dvc.zsh $BUILD_DIR/$ZSH_CMPLT_DIR - fi + print_info "Building dvc binary..." + pyinstaller \ + --additional-hooks-dir $(pwd)/scripts/hooks dvc/__main__.py \ + --name dvc \ + --distpath $LIB_DIR \ + --specpath $BUILD_DIR + + $LIB_DIR/dvc/dvc --help + + # NOTE: in osxpkg fpm replaces symlinks with actual file that it + # points to, so we need to use after-install hook. See FPM_FLAGS + # above. + if [[ "$(uname)" == 'Linux' ]]; then + mkdir -p $BIN_DIR + pushd $BIN_DIR + ln -s ../lib/dvc/dvc dvc + popd + $BIN_DIR/dvc --help + fi + + # NOTE: temporarily not adding scripts to mac package. See [1] + # [1] https://github.com/iterative/dvc/issues/2585 + if [[ "$(uname)" == 'Linux' ]]; then + mkdir -p $BUILD_DIR/$BASH_CMPLT_DIR + cp scripts/completion/dvc.bash $BUILD_DIR/$BASH_CMPLT_DIR/dvc + + mkdir -p $BUILD_DIR/$ZSH_CMPLT_DIR + cp scripts/completion/dvc.zsh $BUILD_DIR/$ZSH_CMPLT_DIR + fi } build() { - cleanup - echo "PKG = \"$1\"" >dvc/utils/build.py - build_dvc - fpm_build $1 + cleanup + echo "PKG = \"$1\"" >dvc/utils/build.py + build_dvc + fpm_build $1 } install_dependencies if [[ "$(uname)" == 'Linux' ]]; then - build rpm - build deb + build rpm + build deb else - build osxpkg + build osxpkg fi cleanup diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh index 1ef6776bd3..93e7d51cc5 100755 --- a/scripts/build_snap.sh +++ b/scripts/build_snap.sh @@ -3,24 +3,24 @@ set -e set -x if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" - exit 1 + echo "Please run this script from repository root" + exit 1 fi sudo snapcraft --use-lxd pip uninstall -y dvc if which dvc; then - echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 - exit 1 + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 + exit 1 fi sudo snap install --dangerous --classic dvc_*.snap if [[ -n "$TRAVIS_TAG" ]]; then - # Make sure we have a correct version - if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then - echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 - exit 1 - fi + # Make sure we have a correct version + if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 + exit 1 + fi fi # ensure basic commands can run # N.B.: cannot run `dvc get` on travis (#2956) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index c154a62b6a..451179c9bb 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -6,53 +6,53 @@ set -e scriptdir="$(dirname $0)" if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ulimit -a - sudo sysctl -w kern.maxproc=2048 - sudo sysctl -w kern.maxprocperuid=2048 - echo '\nulimit -u 2048' >>~/.bash_profile - ulimit -a + ulimit -a + sudo sysctl -w kern.maxproc=2048 + sudo sysctl -w kern.maxprocperuid=2048 + echo '\nulimit -u 2048' >>~/.bash_profile + ulimit -a fi echo >env.sh if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]]; then - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then - # NOTE: ssh keys for ssh test to be able to ssh to the localhost - ssh-keygen -t rsa -N "" -f mykey - mkdir -p ~/.ssh - cp mykey ~/.ssh/id_rsa - cp mykey.pub ~/.ssh/id_rsa.pub - cat mykey.pub >>~/.ssh/authorized_keys - ssh-keyscan localhost >>~/.ssh/known_hosts - ssh localhost ls &>/dev/null - ssh-keyscan 127.0.0.1 >>~/.ssh/known_hosts - ssh 127.0.0.1 ls &>/dev/null - ssh-keyscan 0.0.0.0 >>~/.ssh/known_hosts - ssh 0.0.0.0 ls &>/dev/null - fi - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - bash "$scriptdir/install_azurite.sh" - bash "$scriptdir/install_oss.sh" - bash "$scriptdir/install_hadoop.sh" - fi - - if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then - brew install openssl - $scriptdir/retry.sh brew cask install google-cloud-sdk - fi + if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then + # NOTE: ssh keys for ssh test to be able to ssh to the localhost + ssh-keygen -t rsa -N "" -f mykey + mkdir -p ~/.ssh + cp mykey ~/.ssh/id_rsa + cp mykey.pub ~/.ssh/id_rsa.pub + cat mykey.pub >>~/.ssh/authorized_keys + ssh-keyscan localhost >>~/.ssh/known_hosts + ssh localhost ls &>/dev/null + ssh-keyscan 127.0.0.1 >>~/.ssh/known_hosts + ssh 127.0.0.1 ls &>/dev/null + ssh-keyscan 0.0.0.0 >>~/.ssh/known_hosts + ssh 0.0.0.0 ls &>/dev/null + fi + + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + bash "$scriptdir/install_azurite.sh" + bash "$scriptdir/install_oss.sh" + bash "$scriptdir/install_hadoop.sh" + fi + + if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then + brew install openssl + $scriptdir/retry.sh brew cask install google-cloud-sdk + fi fi if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - $scriptdir/retry.sh choco install python --version 3.7.5 - echo 'PATH="/c/Python37:/c/Python37/Scripts:$PATH"' >>env.sh + $scriptdir/retry.sh choco install python --version 3.7.5 + echo 'PATH="/c/Python37:/c/Python37/Scripts:$PATH"' >>env.sh elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ln -s -f /usr/local/bin/python3 /usr/local/bin/python - ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip + ln -s -f /usr/local/bin/python3 /usr/local/bin/python + ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi if [[ -n "$TRAVIS_TAG" ]]; then - echo "export SNAP_CHANNEL=stable" >>env.sh + echo "export SNAP_CHANNEL=stable" >>env.sh else - echo "export SNAP_CHANNEL=edge" >>env.sh + echo "export SNAP_CHANNEL=edge" >>env.sh fi diff --git a/scripts/ci/check_python.sh b/scripts/ci/check_python.sh index 77e86ecbef..b4ca089329 100644 --- a/scripts/ci/check_python.sh +++ b/scripts/ci/check_python.sh @@ -4,15 +4,15 @@ set -e set -x if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - where python - where pip + where python + where pip else - which python - which pip + which python + which pip fi py_ver="$(python -c 'import sys; print(sys.version[0])')" if [[ "$py_ver" != 3 ]]; then - exit 1 + exit 1 fi diff --git a/scripts/ci/deploy_condition.sh b/scripts/ci/deploy_condition.sh index 1309f76289..6b95494347 100755 --- a/scripts/ci/deploy_condition.sh +++ b/scripts/ci/deploy_condition.sh @@ -3,13 +3,13 @@ set -e if [[ $TRAVIS_EVENT_TYPE = pull_request || $TRAVIS_EVENT_TPYE = cron ]]; then - exit 2 + exit 2 fi # positional args are assumed to be file glob patterns to deploy if [[ ${#} -ge 1 ]]; then - # ensure at least one file exists - [[ -n "$(ls $@ 2>/dev/null)" ]] || exit 3 + # ensure at least one file exists + [[ -n "$(ls $@ 2>/dev/null)" ]] || exit 3 fi echo true diff --git a/scripts/ci/install.sh b/scripts/ci/install.sh index d91c207be5..425b6eaf62 100644 --- a/scripts/ci/install.sh +++ b/scripts/ci/install.sh @@ -14,9 +14,9 @@ git config --global user.email "dvctester@example.com" git config --global user.name "DVC Tester" if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY - aws configure set region us-east-2 + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY + aws configure set region us-east-2 - openssl enc -d -aes-256-cbc -md md5 -k $GCP_CREDS -in scripts/ci/gcp-creds.json.enc -out scripts/ci/gcp-creds.json + openssl enc -d -aes-256-cbc -md md5 -k $GCP_CREDS -in scripts/ci/gcp-creds.json.enc -out scripts/ci/gcp-creds.json fi diff --git a/scripts/ci/install_azurite.sh b/scripts/ci/install_azurite.sh index 30a7ef9437..d02223d8a0 100755 --- a/scripts/ci/install_azurite.sh +++ b/scripts/ci/install_azurite.sh @@ -12,9 +12,9 @@ sudo apt-get install -y docker-ce # run azurite sudo docker run -d --restart always -e executable=blob -p 10000:10000 \ - --tmpfs /opt/azurite/folder \ - mcr.microsoft.com/azure-storage/azurite:3.3.0-preview \ - azurite -l /data --blobHost 0.0.0.0 + --tmpfs /opt/azurite/folder \ + mcr.microsoft.com/azure-storage/azurite:3.3.0-preview \ + azurite -l /data --blobHost 0.0.0.0 # save secrets echo "export AZURE_STORAGE_CONTAINER_NAME='travis-tests'" >>env.sh diff --git a/scripts/ci/retry.sh b/scripts/ci/retry.sh index cd2ff129fa..07458c9948 100755 --- a/scripts/ci/retry.sh +++ b/scripts/ci/retry.sh @@ -4,8 +4,8 @@ set -e N_RETRIES=3 for i in $(seq $N_RETRIES); do - echo "Attempt #$i" - $@ && exit $? + echo "Attempt #$i" + $@ && exit $? done exit $? diff --git a/scripts/ci/script.sh b/scripts/ci/script.sh index f9b6a72477..2ad7ba26c4 100644 --- a/scripts/ci/script.sh +++ b/scripts/ci/script.sh @@ -6,7 +6,7 @@ set -e python -mtests if [[ "$TRAVIS_PULL_REQUEST" == "false" && \ - "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then - pip install codecov - codecov + "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then + pip install codecov + codecov fi diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 40a2604410..6505c1398e 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -72,30 +72,30 @@ _dvc_version='' # ${!x} -> ${hello} -> "world" # _dvc() { - replace_hyphen() { - echo $(echo $1 | sed 's/-/_/g') - } + replace_hyphen() { + echo $(echo $1 | sed 's/-/_/g') + } - local word="${COMP_WORDS[COMP_CWORD]}" + local word="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=() + COMPREPLY=() - if [ "${COMP_CWORD}" -eq 1 ]; then - case "$word" in - -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; - *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; - esac - elif [ "${COMP_CWORD}" -eq 2 ]; then - local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})" + if [ "${COMP_CWORD}" -eq 1 ]; then + case "$word" in + -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; + *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; + esac + elif [ "${COMP_CWORD}" -eq 2 ]; then + local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})" - COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) - elif [ "${COMP_CWORD}" -eq 3 ]; then - local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})_$(replace_hyphen ${COMP_WORDS[2]})" + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) + elif [ "${COMP_CWORD}" -eq 3 ]; then + local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})_$(replace_hyphen ${COMP_WORDS[2]})" - COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) - fi + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) + fi - return 0 + return 0 } complete -F _dvc dvc diff --git a/scripts/pypi_upload.sh b/scripts/pypi_upload.sh index 572bc0a2ee..5c9115662d 100755 --- a/scripts/pypi_upload.sh +++ b/scripts/pypi_upload.sh @@ -3,8 +3,8 @@ set -e if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" - exit 1 + echo "Please run this script from repository root" + exit 1 fi rm -rf dist/ From 98d2ca00c0fa372e576b3278cdfc8d12dcf12f59 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:35:45 +0000 Subject: [PATCH 03/13] lint: shfmt with -ci --- scripts/completion/dvc.bash | 4 +-- scripts/completion/dvc.zsh | 60 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 6505c1398e..2cd7d1cdf6 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -82,8 +82,8 @@ _dvc() { if [ "${COMP_CWORD}" -eq 1 ]; then case "$word" in - -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; - *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; + -*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;; + *) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;; esac elif [ "${COMP_CWORD}" -eq 2 ]; then local options_list="_dvc_$(replace_hyphen ${COMP_WORDS[1]})" diff --git a/scripts/completion/dvc.zsh b/scripts/completion/dvc.zsh index 03f9fa69c1..4e718026c7 100644 --- a/scripts/completion/dvc.zsh +++ b/scripts/completion/dvc.zsh @@ -275,34 +275,34 @@ _arguments \ '*::args:->args' case $words[1] in - add) _arguments $_dvc_global_options $_dvc_add ;; - cache) _arguments $_dvc_global_options $_dvc_cache ;; - checkout) _arguments $_dvc_global_options $_dvc_checkout ;; - commit) _arguments $_dvc_global_options $_dvc_commit ;; - config) _arguments $_dvc_global_options $_dvc_config ;; - destroy) _arguments $_dvc_global_options $_dvc_destroy ;; - diff) _arguments $_dvc_global_options $_dvc_diff ;; - fetch) _arguments $_dvc_global_options $_dvc_fetch ;; - get-url) _arguments $_dvc_global_options $_dvc_geturl ;; - get) _arguments $_dvc_global_options $_dvc_get ;; - gc) _arguments $_dvc_global_options $_dvc_gc ;; - import-url) _arguments $_dvc_global_options $_dvc_importurl ;; - import) _arguments $_dvc_global_options $_dvc_import ;; - init) _arguments $_dvc_global_options $_dvc_init ;; - install) _arguments $_dvc_global_options $_dvc_install ;; - lock) _arguments $_dvc_global_options $_dvc_lock ;; - metrics) _arguments $_dvc_global_options $_dvc_metrics ;; - move) _arguments $_dvc_global_options $_dvc_move ;; - pipeline) _arguments $_dvc_global_options $_dvc_pipeline ;; - pull) _arguments $_dvc_global_options $_dvc_pull ;; - push) _arguments $_dvc_global_options $_dvc_push ;; - remote) _arguments $_dvc_global_options $_dvc_remote ;; - remove) _arguments $_dvc_global_options $_dvc_remove ;; - repro) _arguments $_dvc_global_options $_dvc_repro ;; - root) _arguments $_dvc_global_options $_dvc_root ;; - run) _arguments $_dvc_global_options $_dvc_run ;; - status) _arguments $_dvc_global_options $_dvc_status ;; - unlock) _arguments $_dvc_global_options $_dvc_unlock ;; - unprotect) _arguments $_dvc_global_options $_dvc_unprotect ;; - update) _arguments $_dvc_global_options $_dvc_update ;; + add) _arguments $_dvc_global_options $_dvc_add ;; + cache) _arguments $_dvc_global_options $_dvc_cache ;; + checkout) _arguments $_dvc_global_options $_dvc_checkout ;; + commit) _arguments $_dvc_global_options $_dvc_commit ;; + config) _arguments $_dvc_global_options $_dvc_config ;; + destroy) _arguments $_dvc_global_options $_dvc_destroy ;; + diff) _arguments $_dvc_global_options $_dvc_diff ;; + fetch) _arguments $_dvc_global_options $_dvc_fetch ;; + get-url) _arguments $_dvc_global_options $_dvc_geturl ;; + get) _arguments $_dvc_global_options $_dvc_get ;; + gc) _arguments $_dvc_global_options $_dvc_gc ;; + import-url) _arguments $_dvc_global_options $_dvc_importurl ;; + import) _arguments $_dvc_global_options $_dvc_import ;; + init) _arguments $_dvc_global_options $_dvc_init ;; + install) _arguments $_dvc_global_options $_dvc_install ;; + lock) _arguments $_dvc_global_options $_dvc_lock ;; + metrics) _arguments $_dvc_global_options $_dvc_metrics ;; + move) _arguments $_dvc_global_options $_dvc_move ;; + pipeline) _arguments $_dvc_global_options $_dvc_pipeline ;; + pull) _arguments $_dvc_global_options $_dvc_pull ;; + push) _arguments $_dvc_global_options $_dvc_push ;; + remote) _arguments $_dvc_global_options $_dvc_remote ;; + remove) _arguments $_dvc_global_options $_dvc_remove ;; + repro) _arguments $_dvc_global_options $_dvc_repro ;; + root) _arguments $_dvc_global_options $_dvc_root ;; + run) _arguments $_dvc_global_options $_dvc_run ;; + status) _arguments $_dvc_global_options $_dvc_status ;; + unlock) _arguments $_dvc_global_options $_dvc_unlock ;; + unprotect) _arguments $_dvc_global_options $_dvc_unprotect ;; + update) _arguments $_dvc_global_options $_dvc_update ;; esac From f8c01e7fb379971b42a6dca809a67cfa8d151009 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:37:31 +0000 Subject: [PATCH 04/13] lint:pre-commit shfmt hook --- .pre-commit-config.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1cc91e2221..bbd114d08a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,14 @@ repos: hooks: - id: flake8 language_version: python3 +- repo: https://github.com/casperdcl/sh + rev: master + hooks: + - id: shfmt + language: golang + args: + - -l # list files whose formatting differs from shfmt's + - -d # error with a diff when the formatting differs + - -i # indentation + - '2' # 2 spaces + - -ci # switch cases will be indented From 22dd0d47ebdaa04591a4e677ca3349aed196306e Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:40:56 +0000 Subject: [PATCH 05/13] lint:pre-commit shfmt defaults --- .pre-commit-config.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbd114d08a..a64750c783 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,9 +14,3 @@ repos: hooks: - id: shfmt language: golang - args: - - -l # list files whose formatting differs from shfmt's - - -d # error with a diff when the formatting differs - - -i # indentation - - '2' # 2 spaces - - -ci # switch cases will be indented From 2734f49b9ed8ec16364b027c48ae91608e0c09fc Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:50:41 +0000 Subject: [PATCH 06/13] ci:check:fix go install --- scripts/ci/check_patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/check_patch.sh b/scripts/ci/check_patch.sh index f357086349..2c6674f5ae 100755 --- a/scripts/ci/check_patch.sh +++ b/scripts/ci/check_patch.sh @@ -9,4 +9,4 @@ pip install Pygments collective.checkdocs pre-commit python setup.py checkdocs # stop the build if there are any formatting errors -pre-commit run --all-files +GO111MODULE=on pre-commit run --all-files From 7a9512d02ec2420c89600b49fb6f105dacd65a3c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 22:55:19 +0000 Subject: [PATCH 07/13] ci:fix go version --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 971a2bb9e6..483ac7ed4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ jobs: os: linux language: python python: 3.7 + go: 1.13 before_install: install: script: ./scripts/ci/check_patch.sh From 493a340531c0f95d423acef30245e9aa5d90a35d Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 23:17:59 +0000 Subject: [PATCH 08/13] ci:attempt python=>go for checks --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 483ac7ed4d..c2851ed796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,7 @@ jobs: - name: "Check patch formatting" stage: check os: linux - language: python - python: 3.7 + language: go go: 1.13 before_install: install: From cf257f96175528ca515fb9b71681d905011c82d4 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 23:25:26 +0000 Subject: [PATCH 09/13] ci:still try to use go --- scripts/ci/check_patch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/check_patch.sh b/scripts/ci/check_patch.sh index 2c6674f5ae..7d64b88d82 100755 --- a/scripts/ci/check_patch.sh +++ b/scripts/ci/check_patch.sh @@ -3,10 +3,10 @@ set -x set -e -pip install Pygments collective.checkdocs pre-commit +python3 -m pip install --user Pygments collective.checkdocs pre-commit # stop the build if there are any readme formatting errors -python setup.py checkdocs +python3 setup.py checkdocs # stop the build if there are any formatting errors GO111MODULE=on pre-commit run --all-files From 605c4af9c6a031052ee5f428d77522bfe24c1483 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 23:35:36 +0000 Subject: [PATCH 10/13] ci:split checks into py & go jobs --- .travis.yml | 11 +++++++++-- scripts/ci/check_patch.sh | 9 ++++++--- scripts/ci/check_scripts.sh | 7 +++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100755 scripts/ci/check_scripts.sh diff --git a/.travis.yml b/.travis.yml index c2851ed796..62f6dd39f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,14 +24,21 @@ stages: jobs: include: # patch formatting checks - - name: "Check patch formatting" + - name: "Python formatting" stage: check + os: linux + language: python + python: 3.7 + before_install: + install: + script: ./scripts/ci/check_patch.sh + - name: "Script formatting" os: linux language: go go: 1.13 before_install: install: - script: ./scripts/ci/check_patch.sh + script: ./scripts/ci/check_scripts.sh # test jobs - name: "3.7 on Windows" stage: test diff --git a/scripts/ci/check_patch.sh b/scripts/ci/check_patch.sh index 7d64b88d82..b1935da6a3 100755 --- a/scripts/ci/check_patch.sh +++ b/scripts/ci/check_patch.sh @@ -3,10 +3,13 @@ set -x set -e -python3 -m pip install --user Pygments collective.checkdocs pre-commit +pip install Pygments collective.checkdocs pre-commit # stop the build if there are any readme formatting errors -python3 setup.py checkdocs +python setup.py checkdocs # stop the build if there are any formatting errors -GO111MODULE=on pre-commit run --all-files +err=0 +pre-commit run --all-files black || err=1 +pre-commit run --all-files flake8 || err=1 +exit $err diff --git a/scripts/ci/check_scripts.sh b/scripts/ci/check_scripts.sh new file mode 100755 index 0000000000..90bc79597f --- /dev/null +++ b/scripts/ci/check_scripts.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -x +set -e + +# stop the build if there are any formatting errors +GO111MODULE=on pre-commit run --all-files shfmt From 0f13f47269d8423cac4a40877ed14bfce78bf4d7 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 30 Jan 2020 23:42:29 +0000 Subject: [PATCH 11/13] ci:fix silly go check --- scripts/ci/check_scripts.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ci/check_scripts.sh b/scripts/ci/check_scripts.sh index 90bc79597f..e33dd0b6b8 100755 --- a/scripts/ci/check_scripts.sh +++ b/scripts/ci/check_scripts.sh @@ -3,5 +3,7 @@ set -x set -e +GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt + # stop the build if there are any formatting errors -GO111MODULE=on pre-commit run --all-files shfmt +shfmt -l -d -i 2 -ci -w . From 4e87bf9e0e270353312190fdd9b6b670f0c63bd6 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 31 Jan 2020 19:07:53 +0000 Subject: [PATCH 12/13] try beautysh --- scripts/ci/script.sh | 3 +-- scripts/completion/dvc.bash | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/ci/script.sh b/scripts/ci/script.sh index 2ad7ba26c4..37bfa37f02 100644 --- a/scripts/ci/script.sh +++ b/scripts/ci/script.sh @@ -5,8 +5,7 @@ set -e python -mtests -if [[ "$TRAVIS_PULL_REQUEST" == "false" && \ - "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then +if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then pip install codecov codecov fi diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 2cd7d1cdf6..0f56bbc09a 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -9,8 +9,8 @@ #---------------------------------------------------------- _dvc_commands='add cache checkout commit config destroy diff fetch get-url get gc \ - import-url import init install lock metrics move pipeline pull push \ - remote remove repro root run status unlock unprotect update version' + import-url import init install lock metrics move pipeline pull push \ + remote remove repro root run status unlock unprotect update version' _dvc_options='-h --help -V --version' _dvc_global_options='-h --help -q --quiet -v --verbose' From b0b69ce81972bbc23d1081289e4e409bc13bdd9a Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 31 Jan 2020 19:14:51 +0000 Subject: [PATCH 13/13] lint/pre-commit/ci: replace shfmt => beautysh --- .pre-commit-config.yaml | 7 ++++--- .travis.yml | 9 +-------- scripts/ci/check_patch.sh | 5 +---- scripts/ci/check_scripts.sh | 9 --------- 4 files changed, 6 insertions(+), 24 deletions(-) delete mode 100755 scripts/ci/check_scripts.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a64750c783..a2c5d11fe7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,8 +9,9 @@ repos: hooks: - id: flake8 language_version: python3 -- repo: https://github.com/casperdcl/sh +- repo: https://github.com/lovesegfault/beautysh rev: master hooks: - - id: shfmt - language: golang + - id: beautysh + language_version: python3 + args: [-i, '2'] # 2-space indentaion diff --git a/.travis.yml b/.travis.yml index 62f6dd39f8..971a2bb9e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ stages: jobs: include: # patch formatting checks - - name: "Python formatting" + - name: "Check patch formatting" stage: check os: linux language: python @@ -32,13 +32,6 @@ jobs: before_install: install: script: ./scripts/ci/check_patch.sh - - name: "Script formatting" - os: linux - language: go - go: 1.13 - before_install: - install: - script: ./scripts/ci/check_scripts.sh # test jobs - name: "3.7 on Windows" stage: test diff --git a/scripts/ci/check_patch.sh b/scripts/ci/check_patch.sh index b1935da6a3..f357086349 100755 --- a/scripts/ci/check_patch.sh +++ b/scripts/ci/check_patch.sh @@ -9,7 +9,4 @@ pip install Pygments collective.checkdocs pre-commit python setup.py checkdocs # stop the build if there are any formatting errors -err=0 -pre-commit run --all-files black || err=1 -pre-commit run --all-files flake8 || err=1 -exit $err +pre-commit run --all-files diff --git a/scripts/ci/check_scripts.sh b/scripts/ci/check_scripts.sh deleted file mode 100755 index e33dd0b6b8..0000000000 --- a/scripts/ci/check_scripts.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -x -set -e - -GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt - -# stop the build if there are any formatting errors -shfmt -l -d -i 2 -ci -w .