From 2d81b841e113bd5ebe120accbe278e61b42ac70f Mon Sep 17 00:00:00 2001 From: ashishsinghbora <135435891+ashishsinghbora@users.noreply.github.com> Date: Thu, 24 Sep 2026 23:45:27 +0530 Subject: [PATCH 1/3] ci: add multi-distro functional testing matrix (Ubuntu, Fedora, Arch, Alpine) --- .github/workflows/shellcheck.yml | 50 ++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index b86081e..2ca41ec 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -1,20 +1,20 @@ -name: Lint and Test +name: CI on: push: - branches: [ main, 'feat/**' ] + branches: [ main, 'feat/**', 'fix/**', 'test/**', 'ci/**', 'docs/**' ] pull_request: branches: [ main ] jobs: - shellcheck: - name: ShellCheck and Validation + lint-and-test: + name: Lint, ShellCheck & Full Test (Ubuntu) runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v4 - - name: Install dependencies + - name: Install ShellCheck run: | sudo apt-get update sudo apt-get install -y shellcheck @@ -22,3 +22,43 @@ jobs: - name: Run test suite run: | bash tests/test_all.sh + + distro-matrix: + name: Functional Test (${{ matrix.name }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu + image: ubuntu:24.04 + - name: Fedora + image: fedora:latest + - name: Arch Linux + image: archlinux:latest + - name: Alpine + image: alpine:latest + container: + image: ${{ matrix.image }} + steps: + - name: Install essential tools + run: | + if command -v apt-get >/dev/null 2>&1; then + apt-get update && apt-get install -y git bash coreutils python3 tar gzip bzip2 xz-utils zip unzip iproute2 procps + elif command -v dnf >/dev/null 2>&1; then + dnf install -y git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute procps-ng which + elif command -v pacman >/dev/null 2>&1; then + pacman -Syu --noconfirm git bash coreutils python tar gzip bzip2 xz zip unzip iproute2 procps-ng which + elif command -v apk >/dev/null 2>&1; then + apk add --no-cache git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute2 procps which + fi + + - name: Check out repository + uses: actions/checkout@v4 + + - name: Mark workspace as safe git repository + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + + - name: Run functional test suite + run: | + bash tests/functional_test.sh From ce12c6ac391b79557b8c5a7e7737b9a5b18cc617 Mon Sep 17 00:00:00 2001 From: ashishsinghbora <135435891+ashishsinghbora@users.noreply.github.com> Date: Thu, 24 Sep 2026 23:49:07 +0530 Subject: [PATCH 2/3] ci: ensure openssh and tools available in all distro containers and handle missing column in filesystem-info --- .github/workflows/shellcheck.yml | 8 ++++---- scripts/storage/filesystem-info.sh | 10 +++++++--- tests/functional_test.sh | 26 +++++++++++++++----------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 2ca41ec..1edcc0c 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -44,13 +44,13 @@ jobs: - name: Install essential tools run: | if command -v apt-get >/dev/null 2>&1; then - apt-get update && apt-get install -y git bash coreutils python3 tar gzip bzip2 xz-utils zip unzip iproute2 procps + apt-get update && apt-get install -y git bash coreutils python3 tar gzip bzip2 xz-utils zip unzip iproute2 procps openssh-client bsdmainutils elif command -v dnf >/dev/null 2>&1; then - dnf install -y git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute procps-ng which + dnf install -y git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute procps-ng which openssh util-linux elif command -v pacman >/dev/null 2>&1; then - pacman -Syu --noconfirm git bash coreutils python tar gzip bzip2 xz zip unzip iproute2 procps-ng which + pacman -Syu --noconfirm git bash coreutils python tar gzip bzip2 xz zip unzip iproute2 procps-ng which openssh util-linux elif command -v apk >/dev/null 2>&1; then - apk add --no-cache git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute2 procps which + apk add --no-cache git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute2 procps which openssh-client util-linux fi - name: Check out repository diff --git a/scripts/storage/filesystem-info.sh b/scripts/storage/filesystem-info.sh index 08972fe..4eab082 100755 --- a/scripts/storage/filesystem-info.sh +++ b/scripts/storage/filesystem-info.sh @@ -30,7 +30,11 @@ fi echo -e "\nMount points and options:" if command -v mount >/dev/null 2>&1; then - mount | column -t + if command -v column >/dev/null 2>&1; then + mount | column -t + else + mount + fi else echo "mount command not found." fi @@ -43,9 +47,9 @@ if command -v tune2fs >/dev/null 2>&1; then fstype=$(echo "$line" | awk '{print $3}') if [[ "$fstype" == ext* ]]; then echo "--- $dev ($fstype) ---" - tune2fs -l "$dev" | grep -E 'Filesystem state|Block count|Free blocks|Inode count|Free inodes' + (tune2fs -l "$dev" 2>/dev/null || true) | grep -E 'Filesystem state|Block count|Free blocks|Inode count|Free inodes' || true fi - done < <(df -T | tail -n +2) + done < <(df -T 2>/dev/null | tail -n +2 || true) else echo -e "\nFor detailed ext* info, install e2fsprogs (tune2fs)." fi diff --git a/tests/functional_test.sh b/tests/functional_test.sh index f8be4ab..351f5a9 100755 --- a/tests/functional_test.sh +++ b/tests/functional_test.sh @@ -236,17 +236,21 @@ echo "--- 7. SSH Key Setup ---" SSH_HOME="$TEST_TMP/ssh_home" mkdir -p "$SSH_HOME" -HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -p "" -y >/dev/null -assert_success "ssh-key-setup.sh generates Ed25519 key" test -f "$SSH_HOME/.ssh/id_ed25519" -assert_success "ssh-key-setup.sh enforces 0700 permission on .ssh" test "$(stat -c "%a" "$SSH_HOME/.ssh")" = "700" -assert_success "ssh-key-setup.sh enforces 0600 permission on private key" test "$(stat -c "%a" "$SSH_HOME/.ssh/id_ed25519")" = "600" - -assert_failure "ssh-key-setup.sh refuses overwrite without -f" \ - env HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -p "" - -HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -f -y -p "" -c "updated@host" >/dev/null -BACKUP_KEYS=$(find "$SSH_HOME/.ssh" -name "id_ed25519.pub.bak_*" | wc -l) -assert_success "ssh-key-setup.sh creates backup before overwrite" test "$BACKUP_KEYS" -ge 1 +if command -v ssh-keygen >/dev/null 2>&1; then + HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -p "" -y >/dev/null + assert_success "ssh-key-setup.sh generates Ed25519 key" test -f "$SSH_HOME/.ssh/id_ed25519" + assert_success "ssh-key-setup.sh enforces 0700 permission on .ssh" test "$(stat -c "%a" "$SSH_HOME/.ssh")" = "700" + assert_success "ssh-key-setup.sh enforces 0600 permission on private key" test "$(stat -c "%a" "$SSH_HOME/.ssh/id_ed25519")" = "600" + + assert_failure "ssh-key-setup.sh refuses overwrite without -f" \ + env HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -p "" + + HOME="$SSH_HOME" "$ROOT_DIR/scripts/ssh/ssh-key-setup.sh" -f -y -p "" -c "updated@host" >/dev/null + BACKUP_KEYS=$(find "$SSH_HOME/.ssh" -name "id_ed25519.pub.bak_*" | wc -l) + assert_success "ssh-key-setup.sh creates backup before overwrite" test "$BACKUP_KEYS" -ge 1 +else + echo " ⚠️ ssh-keygen not installed; skipping ssh-key-setup test" +fi # ---------------------------------------------------------------------- # 8. Package Manager Mock Suite From 252e949ac467362bcf47690c5456449e77661a43 Mon Sep 17 00:00:00 2001 From: ashishsinghbora <135435891+ashishsinghbora@users.noreply.github.com> Date: Thu, 24 Sep 2026 23:52:34 +0530 Subject: [PATCH 3/3] fix(system): handle missing lsmod gracefully and add kmod to CI matrix --- .github/workflows/shellcheck.yml | 8 ++++---- scripts/system/kernel-info.sh | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 1edcc0c..0eba34c 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -44,13 +44,13 @@ jobs: - name: Install essential tools run: | if command -v apt-get >/dev/null 2>&1; then - apt-get update && apt-get install -y git bash coreutils python3 tar gzip bzip2 xz-utils zip unzip iproute2 procps openssh-client bsdmainutils + apt-get update && apt-get install -y git bash coreutils python3 tar gzip bzip2 xz-utils zip unzip iproute2 procps openssh-client bsdmainutils kmod elif command -v dnf >/dev/null 2>&1; then - dnf install -y git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute procps-ng which openssh util-linux + dnf install -y git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute procps-ng which openssh util-linux kmod elif command -v pacman >/dev/null 2>&1; then - pacman -Syu --noconfirm git bash coreutils python tar gzip bzip2 xz zip unzip iproute2 procps-ng which openssh util-linux + pacman -Syu --noconfirm git bash coreutils python tar gzip bzip2 xz zip unzip iproute2 procps-ng which openssh util-linux kmod elif command -v apk >/dev/null 2>&1; then - apk add --no-cache git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute2 procps which openssh-client util-linux + apk add --no-cache git bash coreutils python3 tar gzip bzip2 xz zip unzip iproute2 procps which openssh-client util-linux kmod fi - name: Check out repository diff --git a/scripts/system/kernel-info.sh b/scripts/system/kernel-info.sh index 0a5a245..ebb377b 100755 --- a/scripts/system/kernel-info.sh +++ b/scripts/system/kernel-info.sh @@ -23,7 +23,15 @@ done echo "Kernel version:" && uname -r -echo -e "\nLoaded modules:" && lsmod +echo -e "\nLoaded modules:" +if command -v lsmod >/dev/null 2>&1; then + lsmod +elif [[ -r /proc/modules ]]; then + echo "(showing first 20 modules from /proc/modules)" + (head -n 20 /proc/modules 2>/dev/null || true) +else + echo "Kernel module information not available." +fi if [[ -r /proc/config.gz ]]; then echo -e "\nKernel config (compressed, preview):"