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
3 changes: 3 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ jobs:
- name: 'Analyzing Code Quality'
run: shellcheck ./*.sh extras/*.sh -x

- name: 'Testing CI/CD Compatibility'
run: bash extras/test-ci-compatibility.sh

80 changes: 80 additions & 0 deletions extras/test-ci-compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# CI/CD compatibility test for script-dialog library
# Tests that the library can be sourced without errors in headless environments

set -e # Exit on any error

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
EXIT_CODE=0

echo "Testing CI/CD compatibility..."
echo ""

# Test 1: With TERM=dumb (common in CI environments)
echo "Test 1: TERM=dumb (common in CI)"
export TERM=dumb
# shellcheck source=../script-dialog.sh
# shellcheck disable=SC1091 # Source file path is constructed at runtime
if output=$(source "${SCRIPT_DIR}"/../script-dialog.sh 2>&1); then
if echo "$output" | grep -iq "tput.*error\|no value for"; then
echo " ✗ FAILED: tput errors detected in output"
echo "$output"
EXIT_CODE=1
else
echo " ✓ PASSED: Library loaded without tput errors"
fi
else
echo " ✗ FAILED: Library failed to source"
EXIT_CODE=1
fi

# Clean up for next test
unset INTERFACE bold red yellow normal underline

# Test 2: With TERM unset (also common in CI)
echo "Test 2: TERM unset"
unset TERM
# shellcheck source=../script-dialog.sh
# shellcheck disable=SC1091 # Source file path is constructed at runtime
if output=$(source "${SCRIPT_DIR}"/../script-dialog.sh 2>&1); then
if echo "$output" | grep -iq "tput.*error\|no value for"; then
echo " ✗ FAILED: tput errors detected in output"
echo "$output"
EXIT_CODE=1
else
echo " ✓ PASSED: Library loaded without tput errors"
fi
else
echo " ✗ FAILED: Library failed to source"
EXIT_CODE=1
fi

# Clean up for next test
unset INTERFACE bold red yellow normal underline

# Test 3: With normal TERM (ensure we didn't break normal usage)
echo "Test 3: TERM=xterm-256color (normal usage)"
export TERM=xterm-256color
# shellcheck source=../script-dialog.sh
# shellcheck disable=SC1091 # Source file path is constructed at runtime
if output=$(source "${SCRIPT_DIR}"/../script-dialog.sh 2>&1); then
if echo "$output" | grep -iq "error"; then
echo " ✗ FAILED: Unexpected errors in output"
echo "$output"
EXIT_CODE=1
else
echo " ✓ PASSED: Library loaded successfully"
fi
else
echo " ✗ FAILED: Library failed to source"
EXIT_CODE=1
fi

echo ""
if [ $EXIT_CODE -eq 0 ]; then
echo "All CI/CD compatibility tests passed ✓"
else
echo "Some CI/CD compatibility tests failed ✗"
fi

exit $EXIT_CODE
6 changes: 3 additions & 3 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function _calculate-gui-title() {
# n/a
#######################################
function _calculate-tui-max() {
if ! command -v >/dev/null tput; then
if ! command -v tput >/dev/null 2>&1; then
return;
fi

if [ "$GUI" == "false" ] ; then
MAX_LINES=$(tput lines)
MAX_COLS=$(tput cols)
MAX_LINES=$(tput lines 2>/dev/null)
MAX_COLS=$(tput cols 2>/dev/null)
fi

# Never really fill the whole screen space
Expand Down
27 changes: 16 additions & 11 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,23 @@ XDG_ICO_CALENDAR="x-office-calendar"
XDG_ICO_DOCUMENT="x-office-document"

# see if it supports colors...
ncolors=$(tput colors)
if command -v tput >/dev/null 2>&1; then
ncolors=$(tput colors 2>/dev/null)
else
ncolors=""
fi

if [ "$NOCOLORS" == "" ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
bold="$(tput bold)"
underline="$(tput smul)"
#standout="$(tput smso)"
normal="$(tput sgr0)"
red="$(tput setaf 1)"
#green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
#blue="$(tput setaf 4)"
#magenta="$(tput setaf 5)"
#cyan="$(tput setaf 6)"
bold="$(tput bold 2>/dev/null)"
underline="$(tput smul 2>/dev/null)"
#standout="$(tput smso 2>/dev/null)"
normal="$(tput sgr0 2>/dev/null)"
red="$(tput setaf 1 2>/dev/null)"
#green="$(tput setaf 2 2>/dev/null)"
yellow="$(tput setaf 3 2>/dev/null)"
#blue="$(tput setaf 4 2>/dev/null)"
#magenta="$(tput setaf 5 2>/dev/null)"
#cyan="$(tput setaf 6 2>/dev/null)"
else
bold=""
underline=""
Expand Down