############################################################################### # .gitlab-ci.yml — CI pipeline for bash script testing # # Stages: # 1. lint — ShellCheck static analysis + bash syntax check # 2. test — Run --help and --dry-run in Ubuntu and RHEL containers ############################################################################### stages: - lint - test variables: SHELLCHECK_SEVERITY: "warning" # ───────────────────────────────────────────── # Lint Stage # ───────────────────────────────────────────── shellcheck: stage: lint image: koalaman/shellcheck-alpine:stable script: - echo "Running ShellCheck on all .sh files..." - find . -name "*.sh" -not -path "./.git/*" -print0 | xargs -0 -r shellcheck --severity="$SHELLCHECK_SEVERITY" --format=tty bash-syntax: stage: lint image: bash:5 script: - echo "Checking bash syntax (bash -n)..." - | errors=0 for script in $(find . -name "*.sh" -not -path "./.git/*"); do if ! bash -n "$script" 2>&1; then errors=$((errors + 1)) fi done if [ "$errors" -gt 0 ]; then echo "FAILED: $errors script(s) have syntax errors" exit 1 fi echo "All scripts pass syntax check" # ───────────────────────────────────────────── # Test Stage — Ubuntu # ───────────────────────────────────────────── test-ubuntu: stage: test image: ubuntu:24.04 before_script: - apt-get update -qq - apt-get install -y -qq procps iproute2 kmod >/dev/null 2>&1 script: - echo "=== Testing on Ubuntu 24.04 ===" - | for script in $(find . -maxdepth 1 -name "*.sh" -not -path "./.git/*"); do echo "" echo "--- $(basename "$script") --help ---" bash "$script" --help 2>&1 || true done - echo "" - echo "--- networktuning.sh --dry-run ---" - bash networktuning.sh --dry-run 2>&1 || true # ───────────────────────────────────────────── # Test Stage — RHEL # ───────────────────────────────────────────── test-rhel: stage: test image: rockylinux:9 before_script: - dnf install -y -q procps iproute kmod >/dev/null 2>&1 script: - echo "=== Testing on Rocky Linux 9 ===" - | for script in $(find . -maxdepth 1 -name "*.sh" -not -path "./.git/*"); do echo "" echo "--- $(basename "$script") --help ---" bash "$script" --help 2>&1 || true done - echo "" - echo "--- networktuning.sh --dry-run ---" - bash networktuning.sh --dry-run 2>&1 || true