CI: run validate-on-os via script to fix quoting and reliability

- Add .github/scripts/ci-validate-upgrade.sh (single source for Docker validation)
- validate-on-os: run script inside container instead of inline bash -c
- Avoids nested quoting and glob/exit behavior differences across shells
- Same script can be run locally: bash .github/scripts/ci-validate-upgrade.sh
This commit is contained in:
master3395
2026-02-15 19:57:49 +01:00
parent e741dfba11
commit 8a06d7847d
2 changed files with 38 additions and 30 deletions

33
.github/scripts/ci-validate-upgrade.sh vendored Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Run inside CI Docker container (or repo root). Validates upgrade loader + modules and key files.
set -e
echo "=== Shell syntax check ==="
for f in cyberpanel_upgrade.sh preUpgrade.sh fix-phpmyadmin.sh cyberpanel.sh cyberpanel_utility.sh; do
[ ! -f "$f" ] && continue
bash -n "$f" || { echo "FAIL (syntax): $f"; exit 1; }
echo "OK $f"
done
test -f preUpgrade.sh && test -f cyberpanel_upgrade.sh || { echo "Missing required scripts"; exit 1; }
echo "=== Key files ==="
for f in preUpgrade.sh cyberpanel_upgrade.sh plogical/upgrade.py install/install.py; do
test -f "$f" || { echo "Missing: $f"; exit 1; }
done
grep -q 'BRANCH_NAME' preUpgrade.sh || exit 1
if [ -d upgrade_modules ]; then
for n in 00_common 01_variables 02_checks 03_mariadb 04_git_url 05_repository 06_components 07_branch_input 08_main_upgrade 09_sync 10_post_tweak 11_display_final; do
test -f "upgrade_modules/${n}.sh" || { echo "Missing: upgrade_modules/${n}.sh"; exit 1; }
done
grep -q 'Branch_Check\|Branch_Name' upgrade_modules/00_common.sh upgrade_modules/02_checks.sh || exit 1
grep -q 'upgrade_modules\|Pre_Upgrade_Branch_Input\|Set_Default_Variables' cyberpanel_upgrade.sh || exit 1
for f in upgrade_modules/*.sh; do
[ -f "$f" ] || continue
bash -n "$f" || { echo "FAIL (syntax): $f"; exit 1; }
done
else
grep -q 'Branch_Name\|download_install_phpmyadmin\|Branch_Check' cyberpanel_upgrade.sh || exit 1
fi
echo "Done."

View File

@@ -122,33 +122,8 @@ jobs:
- uses: actions/checkout@v4
- name: Validate on ${{ matrix.os }} (${{ matrix.image }})
run: |
docker run --rm \
-v "$PWD:/repo:ro" \
-w /repo \
"${{ matrix.image }}" \
bash -c '
set -e
echo "=== Shell syntax check ==="
for f in cyberpanel_upgrade.sh preUpgrade.sh fix-phpmyadmin.sh cyberpanel.sh cyberpanel_utility.sh; do
[ ! -f "$f" ] && continue
bash -n "$f" || { echo "FAIL (syntax): $f"; exit 1; }
echo "OK $f"
done
test -f preUpgrade.sh && test -f cyberpanel_upgrade.sh || { echo "Missing required scripts"; exit 1; }
echo "=== Key files ==="
for f in preUpgrade.sh cyberpanel_upgrade.sh plogical/upgrade.py install/install.py; do
test -f "$f" || { echo "Missing: $f"; exit 1; }
done
grep -q "BRANCH_NAME" preUpgrade.sh || exit 1
if [ -d upgrade_modules ]; then
for n in 00_common 01_variables 02_checks 03_mariadb 04_git_url 05_repository 06_components 07_branch_input 08_main_upgrade 09_sync 10_post_tweak 11_display_final; do
test -f "upgrade_modules/${n}.sh" || { echo "Missing: upgrade_modules/${n}.sh"; exit 1; }
done
grep -q "Branch_Check\|Branch_Name" upgrade_modules/00_common.sh upgrade_modules/02_checks.sh || exit 1
grep -q "upgrade_modules\|Pre_Upgrade_Branch_Input\|Set_Default_Variables" cyberpanel_upgrade.sh || exit 1
for f in upgrade_modules/*.sh; do [ -f "$f" ] && bash -n "$f" || exit 1; done
else
grep -q "Branch_Name\|download_install_phpmyadmin\|Branch_Check" cyberpanel_upgrade.sh || exit 1
fi
echo "Done."
'
if [ ! -f .github/scripts/ci-validate-upgrade.sh ]; then
echo "Missing .github/scripts/ci-validate-upgrade.sh"
exit 1
fi
docker run --rm -v "$PWD:/repo:ro" -w /repo "${{ matrix.image }}" bash /repo/.github/scripts/ci-validate-upgrade.sh