Add CI workflow and test script for CasaOS Docker fix (#68)

* Add CI workflow and test script for CasaOS Docker fix

Introduces a GitHub Actions workflow to automate testing of the CasaOS Docker API version fix script. Adds a comprehensive test-script.sh for simulating Docker upgrades, verifying the fix, and testing edge cases. Enhances run.sh with non-interactive mode support and colored output, and updates confirmation prompts to respect the NON_INTERACTIVE environment variable.

* Fix color variable typo and improve version check

Corrects the YIGHLIGHT variable to YELLOW for output coloring. Updates Docker API version comparison to use awk for proper numeric comparison. Also improves error reporting in test_fix_script by capturing and returning the actual exit code.

* Add CasaOS version check hang handling and tests

Introduces timeout handling for 'casaos -v' in run.sh to prevent script hangs if CasaOS is in a broken state. Updates test-script.sh to add a dedicated test for CasaOS version check hang handling and includes it in the bug fix test suite. Updates workflow to run the new bug fix tests. Script version updated to 2025.11.0.

* Fix local variable assignment in test-script.sh

Refactored the assignment of the 'output' variable to avoid combining declaration and command substitution, improving compatibility and clarity in the script.

* Fix local variable assignment in test-script.sh

Separated declaration and assignment of the 'output' variable to avoid issues with local scoping in subshells. This improves compatibility and reliability of the test script.
This commit is contained in:
Christopher
2025-11-27 15:45:15 -06:00
committed by GitHub
parent 5fd56bad46
commit 72ac7a3811
3 changed files with 1879 additions and 9 deletions

34
.github/workflows/test-casaos-fix.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Test CasaOS Fix Docker API Version
on:
push:
paths:
- 'casaos-fix-docker-api-version/**'
pull_request:
paths:
- 'casaos-fix-docker-api-version/**'
workflow_dispatch:
jobs:
test-fix-script:
runs-on: ubuntu-latest
env:
NON_INTERACTIVE: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make scripts executable
run: |
chmod +x casaos-fix-docker-api-version/run.sh
chmod +x casaos-fix-docker-api-version/test-script.sh
- name: Run bug fix tests
working-directory: casaos-fix-docker-api-version
run: |
sudo -E ./test-script.sh test-bugfixes
- name: Run full test
working-directory: casaos-fix-docker-api-version
run: |
sudo -E ./test-script.sh full

View File

@@ -19,8 +19,47 @@ else
SUDO="sudo"
fi
# Check for non-interactive mode
if [ "$NON_INTERACTIVE" = "true" ]; then
echo "Running in NON-INTERACTIVE mode"
fi
# Function to print colored output
print_info() {
local msg="$1"
local color="$2"
# Default to no color
local no_color="\033[0m"
local text_color="$no_color"
case "$color" in
"green")
text_color="\033[32m"
;;
"red")
text_color="\033[31m"
;;
"yellow")
text_color="\033[33m"
;;
"blue")
text_color="\033[34m"
;;
"magenta")
text_color="\033[35m"
;;
"cyan")
text_color="\033[36m"
;;
esac
# Print the message with the selected color
echo -e "${text_color}${msg}${no_color}"
}
echo "=========================================="
echo "BigBear CasaOS Docker Version Fix Script 1.6.3"
echo "BigBear CasaOS Docker Version Fix Script 2025.11.0"
echo "=========================================="
echo ""
echo "Here are some links:"
@@ -242,7 +281,10 @@ check_docker_binary_locations() {
# Function to check if CasaOS is installed
check_casaos() {
if command -v casaos &>/dev/null; then
echo "CasaOS is installed: $(casaos -v 2>/dev/null || echo 'version unknown')"
# Use timeout to prevent hanging if CasaOS is in a broken state
local version
version=$(timeout 5 casaos -v 2>/dev/null) || version="version unknown"
echo "CasaOS is installed: $version"
return 0
else
echo "CasaOS not detected."
@@ -1346,8 +1388,12 @@ downgrade_docker() {
echo ""
# Ask for user confirmation
if [ "$NON_INTERACTIVE" = "true" ]; then
REPLY="yes"
else
read -p "Do you want to proceed with Docker reset? (yes/no): " -r REPLY 2>/dev/null || REPLY="no"
echo ""
fi
if [[ $REPLY =~ ^[Yy][Ee][Ss]$ ]] || [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Performing Docker reset..."
@@ -1526,7 +1572,7 @@ main() {
case "$1" in
apply-override|override)
echo "=========================================="
echo "BigBear CasaOS Docker Version Fix Script 1.6.3"
echo "BigBear CasaOS Docker Version Fix Script 2025.11.0"
echo "=========================================="
echo ""
apply_docker_api_override
@@ -1534,7 +1580,7 @@ main() {
;;
remove-override|no-override)
echo "=========================================="
echo "BigBear CasaOS Docker Version Fix Script 1.6.3"
echo "BigBear CasaOS Docker Version Fix Script 2025.11.0"
echo "=========================================="
echo ""
remove_docker_api_override
@@ -1542,7 +1588,7 @@ main() {
;;
help|--help|-h)
echo "=========================================="
echo "BigBear CasaOS Docker Version Fix Script 1.6.3"
echo "BigBear CasaOS Docker Version Fix Script 2025.11.0"
echo "=========================================="
echo ""
show_usage
@@ -1573,8 +1619,12 @@ main() {
echo ""
echo "The script may hang or fail during package downloads."
echo ""
if [ "$NON_INTERACTIVE" = "true" ]; then
REPLY="yes"
else
read -p "Do you want to continue anyway? (yes/no): " -r REPLY
echo ""
fi
if [[ ! $REPLY =~ ^[Yy][Ee][Ss]$|^[Yy]$ ]]; then
echo "Script cancelled."
echo ""

File diff suppressed because it is too large Load Diff