From 12cdd76e3ff149e9647109f2fd6de45049232ad0 Mon Sep 17 00:00:00 2001 From: Pierre beucher Date: Tue, 30 Jul 2024 22:44:32 +0200 Subject: [PATCH] ci: add installation test for OS and arch --- .github/workflows/test-install.yml | 49 ++++++++++++++++++++++++++++++ cloudypad.sh | 18 +++++++++-- install.sh | 4 +-- 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test-install.yml diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml new file mode 100644 index 00000000..1f448072 --- /dev/null +++ b/.github/workflows/test-install.yml @@ -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 \ No newline at end of file diff --git a/cloudypad.sh b/cloudypad.sh index 4d70dc05..473ccc13 100755 --- a/cloudypad.sh +++ b/cloudypad.sh @@ -7,6 +7,10 @@ # and run instructions. # Only a few commands need to run directly for user (eg. moonlight setup) +if [ -n "$CLOUDYPAD_CLI_LAUNCHER_DEBUG" ]; then + set -x +fi + CLOUDYPAD_VERSION=0.1.1 CLOUDYPAD_IMAGE="${CLOUDYPAD_IMAGE:-"crafteo/cloudypad:$CLOUDYPAD_VERSION"}" CLOUDYPAD_TARGET_IMAGE="crafteo/cloudypad-local-runner:local" @@ -47,12 +51,12 @@ RUN if id -u $HOST_UID >/dev/null 2>&1; then \ USER $HOST_UID EOF -container_build_output=$(docker build --progress plain -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1) +container_build_output=$(docker buildx build -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 -t $CLOUDYPAD_TARGET_IMAGE - < /tmp/Dockerfile-cloudypad-run 2>&1" >&2 echo "Build output: " echo "$container_build_output" echo @@ -80,7 +84,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 diff --git a/install.sh b/install.sh index 0fd9032b..6cf41d3c 100755 --- a/install.sh +++ b/install.sh @@ -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