Skip to content

Commit

Permalink
ci: add installation test for OS and arch
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBeucher committed Jul 31, 2024
1 parent e29ff95 commit 68344ba
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test installation script

on:
push:
branches:
- "*"
pull_request:
branches:
- master

jobs:
test-install:
name: Test install.sh
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os:
# - ubuntu-24.04
# - ubuntu-22.04
# - ubuntu-20.04
# - macos-14 # Docker install suported yet
- macos-13
- macos-12
# arch:
# - x64
# - arm64

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: (MacOS) Setup Docker
if: startsWith(matrix.os, 'macos')
# uses: docker-practice/actions-setup-docker@master
# timeout-minutes: 12
# uses: douglascamata/setup-docker-macos-action@main
uses: crazy-max/ghaction-setup-docker@v3

# Test the install script and cloudypad.sh for current commit
- name: Run install script
run: |
curl -fsSL https://raw.githubusercontent.com/PierreBeucher/cloudypad/${{ github.sha }}/install.sh | CLOUDYPAD_VERSION=${{ github.sha }} sh
- name: Check version
run: |
export PATH=$PATH:$HOME/.cloudypad/bin
export CLOUDYPAD_CONTAINER_NO_TTY=true
export CLOUDYPAD_CLI_LAUNCHER_DEBUG=true
cloudypad --version
18 changes: 14 additions & 4 deletions cloudypad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# and run instructions.
# Only a few commands need to run directly for user (eg. moonlight setup)

set -e
if [ -n "$CLOUDYPAD_CLI_LAUNCHER_DEBUG" ]; then
set -x
fi

CLOUDYPAD_VERSION=0.1.0
CLOUDYPAD_IMAGE="${CLOUDYPAD_IMAGE:-"crafteo/cloudypad:$CLOUDYPAD_VERSION"}"
Expand Down Expand Up @@ -43,12 +45,12 @@ fi
USER $(whoami)
EOF

container_build_output=$(docker build --progress plain -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1)
container_build_output=$(docker buildx build --progress plain -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1)
container_build_result=$?

if [ $container_build_result -ne 0 ]; then
echo "Error: could not build CloudyPad container image, build exited with code: $container_build_result" >&2
echo "Build command was: docker build --progress plain -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1" >&2
echo "Build command was: docker buildx build --progress plain -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1" >&2
echo "Build output: "
echo "$container_build_output"
echo
Expand Down Expand Up @@ -76,7 +78,15 @@ run_cloudypad_docker() {
)

# Build run command with proper directories
local cmd="docker run --rm -it"
local cmd="docker run --rm"

# Set interactive+tty by default
# no tty if CLOUDYPAD_CONTAINER_NO_TTY is set (for CI)
if [ -n "$CLOUDYPAD_CONTAINER_NO_TTY" ]; then
cmd="$cmd -t"
else
cmd="$cmd -it"
fi

# Only mount a directory if it exists on host
for mount in "${mounts[@]}"; do
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ if [ -n "$(which cloudypad)" ]; then
fi
fi

echo "Downloading Cloudy Pad CLI..."

# Create secure directory for Cloudy Pad home as it may contain sensitive data
mkdir -p "$CLOUDYPAD_HOME"
chmod 0700 $CLOUDYPAD_HOME

mkdir -p "$INSTALL_DIR"

echo "Downloading $CLOUDYPAD_SCRIPT_URL..."

if command -v curl >/dev/null 2>&1; then
curl --fail -sSL -o "$SCRIPT_PATH" "$CLOUDYPAD_SCRIPT_URL"
elif command -v wget >/dev/null 2>&1; then
Expand Down

0 comments on commit 68344ba

Please sign in to comment.