Files
CyberPanel/.github/workflows/ci.yml
master3395 8a06d7847d 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
2026-02-15 19:57:49 +01:00

130 lines
5.0 KiB
YAML

# Lightweight CI for v2.5.5-dev (free for public repos).
# Validates shell syntax, Python version fetcher, and key files on all supported OSes via Docker.
# CloudLinux and RHEL use Rocky/Alma images as proxies (same family, no official Docker images).
name: CI
on:
push:
branches: [v2.5.5-dev, stable, master]
pull_request:
branches: [v2.5.5-dev, stable, master]
jobs:
validate-shell:
name: Validate shell scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Syntax check shell scripts
run: |
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; }
if [ -d upgrade_modules ]; then
echo "=== Upgrade modules syntax ==="
for f in upgrade_modules/*.sh; do
[ -f "$f" ] || continue
bash -n "$f" || { echo "FAIL (syntax): $f"; exit 1; }
echo "OK $f"
done
fi
echo "All shell scripts passed syntax check"
validate-python:
name: Validate Python (version fetcher)
runs-on: ubuntu-latest
if: hashFiles('plogical/versionFetcher.py') != ''
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install requests
run: pip install requests
- name: Run version fetcher (phpMyAdmin / SnappyMail)
run: |
PYTHONPATH=. python3 -c "
from plogical.versionFetcher import get_latest_phpmyadmin_version, get_latest_snappymail_version
pma = get_latest_phpmyadmin_version()
snappy = get_latest_snappymail_version()
assert pma and len(pma) >= 5, 'phpMyAdmin version invalid'
assert snappy and len(snappy) >= 3, 'SnappyMail version invalid'
print('phpMyAdmin:', pma, 'SnappyMail:', snappy)
"
smoke-key-files:
name: Key files present
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check key install/upgrade files exist
run: |
for f in preUpgrade.sh cyberpanel_upgrade.sh plogical/upgrade.py install/install.py; do
test -f "$f" || { echo "Missing: $f"; exit 1; }
done
test -f plogical/versionFetcher.py && echo "versionFetcher.py present" || echo "versionFetcher.py optional (not on all branches)"
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
else
grep -q 'Branch_Name\|download_install_phpmyadmin\|Branch_Check' cyberpanel_upgrade.sh || exit 1
fi
echo "Key files OK"
# Run validation inside a container per supported OS (AlmaLinux, CentOS, CloudLinux, Debian, RHEL, Rocky, Ubuntu).
validate-on-os:
name: Validate on ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: AlmaLinux 8
image: almalinux:8
- os: AlmaLinux 9
image: almalinux:9
- os: AlmaLinux 10
image: almalinux:10
- os: CentOS 7
image: centos:7
- os: CloudLinux 8
image: rockylinux:8
- os: CloudLinux 9
image: rockylinux:9
- os: Debian 11
image: debian:11
- os: Debian 12
image: debian:12
- os: Debian 13
image: debian:13
- os: RHEL 8
image: almalinux:8
- os: RHEL 9
image: almalinux:9
- os: RockyLinux 8
image: rockylinux:8
- os: RockyLinux 9
image: rockylinux:9
- os: Ubuntu 20.04
image: ubuntu:20.04
- os: Ubuntu 22.04
image: ubuntu:22.04
- os: Ubuntu 24.04
image: ubuntu:24.04
steps:
- uses: actions/checkout@v4
- name: Validate on ${{ matrix.os }} (${{ matrix.image }})
run: |
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