Files
LOGAR/.gitea/workflows/ci.yml
T
Workflow config file is invalid. Please check your config file: resolve aliases: yaml: line 37: could not find expected ':'

95 lines
3.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 Dependencies
run: |
# 1. Ensure Python3 is present; try apt-get only if missing
if ! command -v python3 >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
apt-get update -y || true
apt-get install -y --no-install-recommends python3 || true
fi
fi
# 2. Bootstrap pip via ensurepip or version-appropriate get-pip.py
if ! python3 -m pip --version >/dev/null 2>&1; then
python3 -m ensurepip --default-pip 2>/dev/null || python3 -c "
import sys, urllib.request, subprocess
ver = f'{sys.version_info.major}.{sys.version_info.minor}'
url = f'https://bootstrap.pypa.io/pip/{ver}/get-pip.py' if sys.version_info < (3, 10) else 'https://bootstrap.pypa.io/get-pip.py'
print(f'[*] Downloading get-pip.py from {url} for Python {ver}...')
urllib.request.urlretrieve(url, '/tmp/get-pip.py')
subprocess.run([sys.executable, '/tmp/get-pip.py', '--break-system-packages'])
" || true
fi
# 3. Upgrade pip and install project dependencies
python3 -m pip install --upgrade pip --break-system-packages 2>/dev/null || python3 -m pip install --upgrade pip 2>/dev/null || true
python3 -m pip install -r compilation/requirements.txt --break-system-packages 2>/dev/null || python3 -m pip 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 python3 -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8443/api/hermes/report', timeout=1)" >/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."