Skip to content
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

lint: improve coding style of shell scripts #507

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions release-core.sh
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
#!/bin/sh -xe
#!/bin/bash

OPERATION=$2
PACKAGE_VERSION=$1
PYTHON_BIN=`which python3`
if [ $PYTHON_BIN == "" ]; then
PYTHON_BIN=$(which python3)
if [ "$PYTHON_BIN" == "" ]; then
echo "Python 3.x required."
exit 1
fi
PYTHON_VERSION=`python3 --version | cut -d ' ' -f 2 | cut -d . -f 1,2`
PYTHON_VERSION=$(python3 --version | cut -d ' ' -f 2 | cut -d . -f 1,2)

STAGING_DIR=${HOME}/python-sdk-core-distribute-staging
SOURCE_NAME=aliyun-python-sdk-core
SOURCE_DIR=`pwd`
SOURCE_DIR=$(pwd)
COPY_DIR=${STAGING_DIR}/copy
UNPACK_DIR=${STAGING_DIR}/unpack
INSTALL_DIR=${STAGING_DIR}/install


if [ $OPERATION == "dist" ]; then
if [ "$OPERATION" == "dist" ]; then
echo "making package"
rm ${STAGING_DIR} -rf
mkdir -p ${COPY_DIR}
cp -r ${SOURCE_NAME} ${COPY_DIR}/
cd ${COPY_DIR}/${SOURCE_NAME}
rm "${STAGING_DIR}" -rf
mkdir -p "${COPY_DIR}"
cp -r ${SOURCE_NAME} "${COPY_DIR}"/
cd "${COPY_DIR}"/${SOURCE_NAME}

if [ $PACKAGE_VERSION == "core" ]; then
if [ "$PACKAGE_VERSION" == "core" ]; then
rm setup3.py dist *.egg-info -rf; python3 setup.py sdist
elif [ $PACKAGE_VERSION == "core-v3" ]; then
elif [ "$PACKAGE_VERSION" == "core-v3" ]; then
rm setup.py dist *.egg-info -rf; mv setup3.py setup.py; python3 setup.py sdist
fi

fi

if [ $OPERATION == "test" ]; then
if [ "$OPERATION" == "test" ]; then
echo "testing package"
rm $UNPACK_DIR -rf
rm $INSTALL_DIR -rf
mkdir -p $UNPACK_DIR
mkdir -p $INSTALL_DIR
TAR_FILE=`find ${COPY_DIR}/${SOURCE_NAME}/dist -name aliyun-python-sdk-core*.tar.gz`
cd $UNPACK_DIR; tar xvf $TAR_FILE
cd `find . -name aliyun-python-sdk-core*`
rm "$UNPACK_DIR" -rf
rm "$INSTALL_DIR" -rf
mkdir -p "$UNPACK_DIR"
mkdir -p "$INSTALL_DIR"
TAR_FILE=$(find "${COPY_DIR}"/${SOURCE_NAME}/dist -name aliyun-python-sdk-core*.tar.gz)
cd "$UNPACK_DIR"; tar xvf "$TAR_FILE"
cd $(find . -name aliyun-python-sdk-core*)
SITE_PACKAGES=$INSTALL_DIR/lib/python$PYTHON_VERSION/site-packages
mkdir $SITE_PACKAGES -p
cp -r $SOURCE_DIR/$SOURCE_NAME/tests $SITE_PACKAGES/
export PYTHONPATH=$SITE_PACKAGES
python3 setup.py install --prefix=$INSTALL_DIR
mkdir "$SITE_PACKAGES" -p
cp -r "$SOURCE_DIR"/$SOURCE_NAME/tests "$SITE_PACKAGES"/
export PYTHONPATH="$SITE_PACKAGES"
python3 setup.py install --prefix="$INSTALL_DIR"

cd $SOURCE_DIR
export PYTHONPATH=$PYTHONPATH:`ls | grep aliyun-python-sdk- | grep -v core | xargs | sed 's/ /:/g'`
cd "$SOURCE_DIR"
export PYTHONPATH="$PYTHONPATH":$(ls | grep aliyun-python-sdk- | grep -v core | xargs | sed 's/ /:/g')
python3 -m pytest python-sdk-functional-test
fi


if [ $OPERATION == "release" ]; then
if [ "$OPERATION" == "release" ]; then
echo "releasing package"
cd ${COPY_DIR}/${SOURCE_NAME}
cd "${COPY_DIR}"/${SOURCE_NAME}
twine upload dist/*
fi
9 changes: 5 additions & 4 deletions run_all_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

export PYTHONPATH=$PYTHONPATH:`ls | grep aliyun-python-sdk- | xargs | sed 's/ /:/g'`
for i in `ls | grep aliyun-python-sdk-`; do
echo "Adding $i to PYTHONPATH ..."
export PYTHONPATH=$PYTHONPATH:`pwd`/$i > /dev/null
export PYTHONPATH="$PYTHONPATH":$(ls | grep aliyun-python-sdk- | xargs | sed 's/ /:/g')
for i in $(ls | grep aliyun-python-sdk-); do
# Add to PYTHONPATH
export PYTHONPATH="$PYTHONPATH":$(pwd)/"$i" > /dev/null
done

coverage run -a --source="./aliyun-python-sdk-core/aliyunsdkcore" --branch -m pytest python-sdk-functional-test
Loading