From 7b77859ea55a56a6c3e13586614383a6398c5c4a Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Sun, 3 Nov 2024 12:35:51 -0600 Subject: [PATCH] Add bootstrap test on Alpine Linux --- .github/workflows/test-bootstrap.yml | 35 ++++++++++++++++++---------- bootstrap/test/test-bootstrap.sh | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+), 12 deletions(-) create mode 100755 bootstrap/test/test-bootstrap.sh diff --git a/.github/workflows/test-bootstrap.yml b/.github/workflows/test-bootstrap.yml index 0f0ab66..693d16b 100644 --- a/.github/workflows/test-bootstrap.yml +++ b/.github/workflows/test-bootstrap.yml @@ -14,6 +14,7 @@ jobs: name: | ${{ matrix.platform.os_name }} - ${{ matrix.platform.script }} - ${{ ( matrix.tag == '' && 'no tag' ) || matrix.tag }} runs-on: ${{ matrix.platform.os }} + container: ${{ matrix.platform.container }} strategy: fail-fast: false matrix: @@ -21,6 +22,16 @@ jobs: - os_name: Linux os: ubuntu-latest script: bootstrap-ubi.sh + - os_name: Alpine Linux (ash) + os: ubuntu-latest + container: + image: alpine:latest + env: + GITHUB_TOKEN: ${{ github.token }} + volumes: + - "${{ github.workspace }}:/workspace" + options: "--workdir /workspace" + script: bootstrap-ubi.sh - os_name: macOS os: macOS-latest script: bootstrap-ubi.sh @@ -42,22 +53,22 @@ jobs: tag: v0.1.1 steps: - uses: actions/checkout@v4 + - name: Install curl and sudo on Alpine + shell: sh + run: | + apk update + apk add curl sudo + if: matrix.platform.container != null - name: Run bootstrap script - shell: bash + shell: sh run: | set -e - mkdir -p "$HOME/bin" - UBI_DEBUG_BOOTSTRAP=1 TAG="${{ matrix.tag }}" ./bootstrap/${{ matrix.platform.script }} - if [ ! -x "$HOME/bin/ubi" ]; then - echo "Running ./bootstrap/${{ matrix.platform.script }} did not install ubi!" - exit 1 - fi - - "$HOME/bin/ubi" --project houseabsolute/precious --in "$HOME/bin" - if [ ! -x "$HOME/bin/precious" ]; then - echo "Running ubi did not install precious!" - exit 1 + if [ $( id -u ) -eq 0 ]; then + adduser -D github + sudo -u github ./bootstrap/test/test-bootstrap.sh "${{ matrix.platform.script }}" "${{ matrix.tag }}" + else + ./bootstrap/test/test-bootstrap.sh "${{ matrix.platform.script }}" "${{ matrix.tag }}" fi exit 0 diff --git a/bootstrap/test/test-bootstrap.sh b/bootstrap/test/test-bootstrap.sh new file mode 100755 index 0000000..fa0762c --- /dev/null +++ b/bootstrap/test/test-bootstrap.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e +set -x + +SCRIPT="$1" +# shellcheck disable=SC2034 # This is used by the bootstrap scripts. +TAG="$2" + +mkdir -p "$HOME/bin" + +UBI_DEBUG_BOOTSTRAP=1 "./bootstrap/$SCRIPT" +if [ ! -x "$HOME/bin/ubi" ]; then + echo "Running ./bootstrap/$SCRIPT did not install ubi!" + exit 1 +fi + +"$HOME/bin/ubi" --project houseabsolute/precious --in "$HOME/bin" +if [ ! -x "$HOME/bin/precious" ]; then + echo "Running ubi did not install precious!" + exit 1 +fi + +exit 0