Skip to content

Commit

Permalink
lint: run shfmt
Browse files Browse the repository at this point in the history
Related to #2834 and #2969.
  • Loading branch information
casperdcl committed Jan 30, 2020
1 parent d864caf commit 2e79ce3
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 148 deletions.
28 changes: 14 additions & 14 deletions scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
70 changes: 31 additions & 39 deletions scripts/build_posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions scripts/build_snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
74 changes: 37 additions & 37 deletions scripts/ci/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/ci/check_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scripts/ci/check_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/ci/deploy_condition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions scripts/ci/install_azurite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
16 changes: 8 additions & 8 deletions scripts/ci/install_hadoop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/install_oss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 2e79ce3

Please sign in to comment.