Ensure all helper scripts pushd/popd

Make sure all of these move to the root of the repository first, then
return to where they were afterwards, using pushd/popd. This allows them
to be executed from anywhere in the repo.
This commit is contained in:
Joshua Boniface 2021-11-06 03:16:02 -04:00
parent 4eb0f3bb8a
commit 83e887c4ee
8 changed files with 29 additions and 4 deletions

View File

@ -27,6 +27,9 @@ fi
HOSTS=( ${@} ) HOSTS=( ${@} )
echo "> Deploying to host(s): ${HOSTS[@]}" echo "> Deploying to host(s): ${HOSTS[@]}"
# Move to repo root if we're not
pushd $( git rev-parse --show-toplevel ) &>/dev/null
# Prepare code # Prepare code
echo "Preparing code (format and lint)..." echo "Preparing code (format and lint)..."
./prepare || exit ./prepare || exit
@ -64,3 +67,5 @@ done
if [[ -z ${KEEP_ARTIFACTS} ]]; then if [[ -z ${KEEP_ARTIFACTS} ]]; then
rm ../pvc*_${version}* rm ../pvc*_${version}*
fi fi
popd &>/dev/null

View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
pushd $( git rev-parse --show-toplevel ) &>/dev/null
ver="$( head -1 debian/changelog | awk -F'[()-]' '{ print $2 }' )" ver="$( head -1 debian/changelog | awk -F'[()-]' '{ print $2 }' )"
git pull git pull
rm ../pvc_* rm ../pvc_*
@ -6,3 +7,4 @@ find . -name "__pycache__" -exec rm -r {} \;
dh_make -p pvc_${ver} --createorig --single --yes dh_make -p pvc_${ver} --createorig --single --yes
dpkg-buildpackage -us -uc dpkg-buildpackage -us -uc
dh_clean dh_clean
popd &>/dev/null

View File

@ -2,6 +2,7 @@
set -o xtrace set -o xtrace
exec 3>&1 exec 3>&1
exec 1>&2 exec 1>&2
pushd $( git rev-parse --show-toplevel ) &>/dev/null
# Ensure we're up to date # Ensure we're up to date
git pull --rebase git pull --rebase
# Update the version to a sensible git revision for easy visualization # Update the version to a sensible git revision for easy visualization
@ -37,3 +38,4 @@ cp -a ${tmpdir}/api-Daemon.py api-daemon/pvcapid/Daemon.py
# Clean up # Clean up
rm -r ${tmpdir} rm -r ${tmpdir}
dh_clean dh_clean
popd &>/dev/null

View File

@ -7,6 +7,8 @@ if [[ -z ${new_version} ]]; then
exit 1 exit 1
fi fi
pushd $( git rev-parse --show-toplevel ) &>/dev/null
current_version="$( cat .version )" current_version="$( cat .version )"
echo "${current_version} -> ${new_version}" echo "${current_version} -> ${new_version}"
@ -47,6 +49,8 @@ mv ${deb_changelog_file} debian/changelog
git add node-daemon/pvcnoded/Daemon.py api-daemon/pvcapid/Daemon.py client-cli/setup.py debian/changelog CHANGELOG.md .version git add node-daemon/pvcnoded/Daemon.py api-daemon/pvcapid/Daemon.py client-cli/setup.py debian/changelog CHANGELOG.md .version
git commit -v git commit -v
popd &>/dev/null
echo echo
echo "GitLab release message:" echo "GitLab release message:"
echo echo

4
format
View File

@ -5,10 +5,14 @@ if ! which black &>/dev/null; then
exit 1 exit 1
fi fi
pushd $( git rev-parse --show-toplevel ) &>/dev/null
echo "Formatting..." echo "Formatting..."
black --safe --exclude api-daemon/migrations . black --safe --exclude api-daemon/migrations .
ret=$? ret=$?
if [[ $ret -eq 0 ]]; then if [[ $ret -eq 0 ]]; then
echo "Successfully formatted project!" echo "Successfully formatted project!"
fi fi
popd &>/dev/null
exit $ret exit $ret

View File

@ -4,8 +4,10 @@
VERSION="$( head -1 debian/changelog | awk -F'[()-]' '{ print $2 }' )" VERSION="$( head -1 debian/changelog | awk -F'[()-]' '{ print $2 }' )"
pushd api-daemon pushd $( git rev-parse --show-toplevel ) &>/dev/null
pushd api-daemon &>/dev/null
export PVC_CONFIG_FILE="./pvcapid.sample.yaml" export PVC_CONFIG_FILE="./pvcapid.sample.yaml"
./pvcapid-manage.py db migrate -m "PVC version ${VERSION}" ./pvcapid-manage.py db migrate -m "PVC version ${VERSION}"
./pvcapid-manage.py db upgrade ./pvcapid-manage.py db upgrade
popd popd &>/dev/null
popd &>/dev/null

View File

@ -2,6 +2,8 @@
# Generate the Zookeeper migration files # Generate the Zookeeper migration files
pushd api-daemon pushd $( git rev-parse --show-toplevel ) &>/dev/null
pushd api-daemon &>/dev/null
./pvcapid-manage-zk.py ./pvcapid-manage-zk.py
popd popd &>/dev/null
popd &>/dev/null

4
lint
View File

@ -5,10 +5,14 @@ if ! which flake8 &>/dev/null; then
exit 1 exit 1
fi fi
pushd $( git rev-parse --show-toplevel ) &>/dev/null
echo "Linting..." echo "Linting..."
flake8 flake8
ret=$? ret=$?
if [[ $ret -eq 0 ]]; then if [[ $ret -eq 0 ]]; then
echo "No linting issues found!" echo "No linting issues found!"
fi fi
popd &>/dev/null
exit $ret exit $ret