Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

hassbian-config: Adds function to test PR's #203

Merged
merged 2 commits into from
Oct 23, 2018
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
2 changes: 1 addition & 1 deletion package/etc/bash_completion.d/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _hassbian-config()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="install upgrade remove show log share-log --version --help"
opts="developer-test-pr install upgrade remove show log share-log --version --help"
altopts="--accept --force --debug --version --help --dev --beta"
inst=$(find /opt/hassbian/suites/ -maxdepth 1 -type f | awk -F'/|_' ' {print $NF}' | awk -F. '{print $1}')

Expand Down
28 changes: 28 additions & 0 deletions package/usr/local/bin/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ function check-permission {
return 0
}

function developer-test-pr { # This function fetches a active PR and build a installation package from that and install it on the system.
# This should only be used by maintainers to test PR's!
readonly PRNUMBER="$1"
readonly INSTALLDIR="/tmp/hassbian_config_install_${PRNUMBER}"
if [[ -z "$PRNUMBER" ]]; then
echo "Error: Missing PR argument."
echo ""
echo "Run: bash test_pr.sh PRNUMBER"
return 1
fi
git clone https://github.com/home-assistant/hassbian-scripts.git "$INSTALLDIR"
cd "$INSTALLDIR" || return 1
git fetch origin +refs/pull/"$PRNUMBER"/merge || return 1
git checkout FETCH_HEAD

chmod 755 -R package
dpkg-deb --build package/
apt install -y "$INSTALLDIR"/package.deb --reinstall --allow-downgrades

cd || return 1
rm -r "$INSTALLDIR"
}

function raspberry_pi_zero_check {
## Start check for Raspberry Pi Zero
if [ "$FORCE" != "true" ]; then
Expand Down Expand Up @@ -308,6 +331,11 @@ case $COMMAND in
shift # past argument
shift # past value
;;
"developer-test-pr")
RUN="developer-test-pr $2"
shift # past argument
shift # past value
;;
"log")
RUN="more $LOGFILE"
shift # past argument
Expand Down