Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
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

- 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 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 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 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 kmod
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
10 changes: 7 additions & 3 deletions scripts/storage/filesystem-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 9 additions & 1 deletion scripts/system/kernel-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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):"
Expand Down
26 changes: 15 additions & 11 deletions tests/functional_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading