CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 2m22s
77 lines
2.6 KiB
YAML
77 lines
2.6 KiB
YAML
name: CI Test Suite
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
tags-ignore:
|
|
- '*'
|
|
- '**'
|
|
- 'v*'
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Component Tests & Pipeline Verification
|
|
if: "!startsWith(github.ref, 'refs/tags/')"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install System Dependencies & Python
|
|
run: |
|
|
if command -v apt-get >/dev/null 2>&1; then
|
|
apt-get update -y
|
|
apt-get install -y python3 python3-pip python3-venv curl
|
|
fi
|
|
python3 -m pip install --upgrade pip --break-system-packages || python3 -m pip install --upgrade pip || true
|
|
pip3 install -r compilation/requirements.txt --break-system-packages || pip3 install -r compilation/requirements.txt
|
|
|
|
- name: Verify Python Syntax
|
|
run: |
|
|
python3 -m py_compile src/Server.py src/server_enrollment.py src/Win_Client.py src/Linux_Client.py compilation/package_dist.py compilation/upload_release.py tests/test_pipeline.py tests/*.py
|
|
|
|
- name: Run Component Unit Tests
|
|
run: |
|
|
python3 -m unittest discover -s tests -v
|
|
|
|
- name: Run End-to-End Pipeline Integration Test
|
|
run: |
|
|
# Clean up any leftover test configs or database
|
|
rm -f server_config.json client_config.json logar_state.db client_state.json
|
|
|
|
# 1. Initialize server config and export client configuration
|
|
python3 src/Server.py --create-client-config --server-host 127.0.0.1 --server-port 9443 --client-out client_config.json
|
|
|
|
# 2. Launch LOGAR server in the background
|
|
python3 src/Server.py &
|
|
SERVER_PID=$!
|
|
echo "[*] Server launched in background with PID $SERVER_PID"
|
|
|
|
# 3. Poll Hermes health / report endpoint until server is listening
|
|
READY=0
|
|
for i in $(seq 1 20); do
|
|
if curl -s http://127.0.0.1:8443/api/hermes/report >/dev/null 2>&1; then
|
|
echo "[+] LOGAR Server is ready after ${i}s."
|
|
READY=1
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if [ $READY -ne 1 ]; then
|
|
echo "[!] Server failed to start within 20 seconds."
|
|
kill $SERVER_PID || true
|
|
exit 1
|
|
fi
|
|
|
|
# 4. Execute end-to-end integration test
|
|
python3 tests/test_pipeline.py
|
|
|
|
# 5. Cleanly terminate background server
|
|
kill $SERVER_PID || true
|
|
wait $SERVER_PID 2>/dev/null || true
|
|
echo "[+] Server stopped successfully."
|