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

Commit

Permalink
Merge pull request #203 from ludeeus/developer-test-pr
Browse files Browse the repository at this point in the history
hassbian-config: Adds function to test PR's
  • Loading branch information
Landrash committed Oct 23, 2018
2 parents 2ee5a9f + 49cec57 commit c13bb38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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

0 comments on commit c13bb38

Please sign in to comment.