Skip to content

Commit

Permalink
Add integration test for the install script (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamero committed Oct 12, 2022
1 parent 9ce49e6 commit 6f1e7db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/integration-install.yml
@@ -0,0 +1,21 @@
name: Install Script Integration Test
on:
pull_request:
branches: [ main ]

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Install Script
run: ./scripts/install.sh
- name: Validate Command is Installed
run: |
if ! command -v draft &> /dev/null
then
echo "draft could not be found"
exit 1
fi
- name: Validate Draft Command Runs
run: draft -h
17 changes: 10 additions & 7 deletions scripts/install.sh
Expand Up @@ -10,7 +10,7 @@
# ###### # # # # # # ##### ####### ###
#
# usage:
# curl -fsSL https://raw.githubusercontent.com/Azure/draft/scripts/install.sh | bash
# curl -fsSL https://raw.githubusercontent.com/Azure/draft/main/scripts/install.sh | bash
set -e
set -f

Expand Down Expand Up @@ -127,10 +127,12 @@ copy_draft_files() {
if [ ! -d "$HOME/.local/bin" ]; then
mkdir -p "$HOME/.local/bin"
fi
mv /tmp/draftcli "$HOME/.local/bin/draftcli"
mv /tmp/draftcli "$HOME/.local/bin/draft"
echo "Installing to $HOME/.local/bin"
else
echo "installation target directory is write protected, run as root to override"
sudo mv /tmp/draftcli /usr/local/bin/draftcli
echo "Installation target directory is write protected, run as root to override"
sudo mv /tmp/draftcli /usr/local/bin/draft
echo "Installing to /usr/local/bin"
fi
}

Expand All @@ -144,13 +146,13 @@ install() {
elif [[ "$OSTYPE" == "win32" ]]; then
OS="win"
else
echo "Draft cli isn't supported for your platform - $OSTYPE"
echo "Draft CLI isn't supported for your platform - $OSTYPE"
file_issue_prompt
exit 1
fi

if [[ "$ARCH" != "x86_64" ]]; then
echo "Draft cli is only available for linux x86_64 architecture"
echo "Draft CLI is only available for linux x86_64 architecture"
file_issue_prompt
exit 1
fi
Expand All @@ -162,7 +164,8 @@ install() {
check_jq_processor_present
download_draft_cli_stable_version
copy_draft_files
echo "Draft CLI kubernetes installed."
echo "Draft CLI installed."
echo "Run 'draft -h' for usage"
}

install

0 comments on commit 6f1e7db

Please sign in to comment.