Skip to content

Fix install on new config.php template format (broke all OSes) #12

Fix install on new config.php template format (broke all OSes)

Fix install on new config.php template format (broke all OSes) #12

Workflow file for this run

name: SimpleRisk Install/Uninstall Tests
on:
push:
branches: [main, "feature/**"]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
test:
name: "Test: ${{ matrix.os-slug }}"
runs-on: ubuntu-latest
strategy:
# Run all matrix jobs even if one fails so we get a full picture
fail-fast: false
matrix:
os-slug:
- ubuntu-22.04
- ubuntu-24.04
- debian-12
- debian-13
- centos-stream-9
- centos-stream-10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# ── Build ───────────────────────────────────────────────────────────────
- name: Build test image
run: |
docker build \
-f tests/dockerfiles/Dockerfile.${{ matrix.os-slug }} \
-t simplerisk-test:${{ matrix.os-slug }} \
tests/dockerfiles/
# ── Start container ─────────────────────────────────────────────────────
# All OSes use --init (tini as PID 1) so that child processes (Apache
# workers, mysqld) are properly reaped and multiple rapid service
# start/stop/restart calls during apt/dnf post-install triggers work
# correctly. CentOS/RHEL uses the /usr/local/bin/systemctl shim baked
# into the image; no real systemd is needed.
# --privileged is required for ufw/iptables inside Debian/Ubuntu and
# is harmless for CentOS.
- name: Start container
run: |
docker run -d \
--name simplerisk-test-${{ matrix.os-slug }} \
--privileged \
--init \
simplerisk-test:${{ matrix.os-slug }} \
/bin/bash -c "tail -f /dev/null"
sleep 2
# ── Pre-start services (Ubuntu only) ────────────────────────────────────
# Ubuntu images pre-install lamp-server^ during the Docker build (with
# policy-rc.d blocking auto-start). Start MySQL and Apache now so that
# the setup script finds them in the expected running state — mirroring
# what would happen on a freshly provisioned real server where the
# package post-install scripts start the services.
- name: Start pre-installed services (Ubuntu only)
if: ${{ startsWith(matrix.os-slug, 'ubuntu') }}
run: |
docker exec simplerisk-test-${{ matrix.os-slug }} service mysql start 2>/dev/null || true
docker exec simplerisk-test-${{ matrix.os-slug }} service apache2 start 2>/dev/null || true
sleep 2
# ── Copy files ──────────────────────────────────────────────────────────
- name: Copy scripts into container
run: |
CONTAINER="simplerisk-test-${{ matrix.os-slug }}"
docker cp simplerisk-setup.sh "$CONTAINER:/root/simplerisk-setup.sh"
docker cp tests/verify-install.sh "$CONTAINER:/root/verify-install.sh"
docker cp tests/verify-uninstall.sh "$CONTAINER:/root/verify-uninstall.sh"
docker exec "$CONTAINER" chmod +x \
/root/simplerisk-setup.sh \
/root/verify-install.sh \
/root/verify-uninstall.sh
# ── Install ─────────────────────────────────────────────────────────────
- name: Run install
run: |
docker exec simplerisk-test-${{ matrix.os-slug }} \
bash /root/simplerisk-setup.sh --yes --debug
# ── Verify install ──────────────────────────────────────────────────────
- name: Verify installation
run: |
docker exec simplerisk-test-${{ matrix.os-slug }} \
bash /root/verify-install.sh
# ── Uninstall ───────────────────────────────────────────────────────────
- name: Run uninstall
run: |
docker exec simplerisk-test-${{ matrix.os-slug }} \
bash /root/simplerisk-setup.sh --uninstall --yes --debug
# ── Verify uninstall ────────────────────────────────────────────────────
- name: Verify uninstallation
run: |
docker exec simplerisk-test-${{ matrix.os-slug }} \
bash /root/verify-uninstall.sh
# ── Diagnostics on failure ──────────────────────────────────────────────
- name: Collect diagnostics on failure
if: failure()
run: |
CONTAINER="simplerisk-test-${{ matrix.os-slug }}"
echo "=== /etc/my.cnf ===" && \
docker exec "$CONTAINER" cat /etc/my.cnf 2>/dev/null || true
echo "=== /etc/my.cnf.d/ ===" && \
docker exec "$CONTAINER" ls -la /etc/my.cnf.d/ 2>/dev/null || true
echo "=== /etc/my.cnf.d/* contents ===" && \
docker exec "$CONTAINER" sh -c 'for f in /etc/my.cnf.d/*.cnf; do echo "--- $f ---"; cat "$f"; done' 2>/dev/null || true
echo "=== MySQL sql_mode ===" && \
docker exec "$CONTAINER" sh -c \
'PW=$(grep "MYSQL ROOT PASSWORD:" /root/passwords.txt 2>/dev/null | cut -d" " -f4); mysql -uroot -p"$PW" -e "SELECT @@sql_mode;" 2>/dev/null' || true
echo "=== journalctl (last 50 lines) ===" && \
docker exec "$CONTAINER" journalctl -n 50 2>/dev/null || true
echo "=== Apache error log ===" && \
docker exec "$CONTAINER" cat /var/log/apache2/error.log 2>/dev/null || \
docker exec "$CONTAINER" cat /var/log/httpd/error_log 2>/dev/null || true
echo "=== MySQL error log (last 30 lines) ===" && \
docker exec "$CONTAINER" tail -30 /var/log/mysql/error.log 2>/dev/null || \
docker exec "$CONTAINER" tail -30 /var/log/mysqld.log 2>/dev/null || true
echo "=== /root/passwords.txt ===" && \
docker exec "$CONTAINER" cat /root/passwords.txt 2>/dev/null || true
# ── Teardown ────────────────────────────────────────────────────────────
- name: Teardown container
if: always()
run: |
docker rm -f simplerisk-test-${{ matrix.os-slug }} 2>/dev/null || true