Files
Commonwealth-Online-Server/.github/workflows/linux-compatibility.yml
T

114 lines
3.2 KiB
YAML

name: Linux Compatibility
on:
push:
paths:
- "server/**"
- ".gitattributes"
- ".gitignore"
- ".github/workflows/linux-compatibility.yml"
pull_request:
paths:
- "server/**"
- ".gitattributes"
- ".gitignore"
- ".github/workflows/linux-compatibility.yml"
jobs:
ubuntu:
name: Ubuntu dedicated server
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Verify start.sh line endings
run: |
python3 - <<'PY'
from pathlib import Path
data = Path("start.sh").read_bytes()
assert b"\r\n" not in data, "start.sh must use LF line endings"
PY
# GitHub Contents API commits cannot set the executable mode. Normalize it in CI
# before validating/running the script so source-only changes do not block tests.
chmod +x start.sh
test -x start.sh
- name: Syntax and shellcheck
run: |
bash -n start.sh
shellcheck start.sh
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create clean venv and install server deps
run: |
python -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install -r requirements-server.txt pytest
# Ensure GUI-only deps are not required for dedicated server
! .venv/bin/python -c "import PySide6" 2>/dev/null
- name: Compile and test
run: |
.venv/bin/python -m compileall -q .
.venv/bin/python -m pytest -q
.venv/bin/python test_npc_protocol.py
.venv/bin/python test_combat_protocol.py
arch:
name: Arch Linux container
runs-on: ubuntu-latest
container:
image: archlinux:latest
defaults:
run:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install packages
run: |
pacman -Syu --noconfirm python python-pip shellcheck
- name: Verify start.sh line endings
run: |
python - <<'PY'
from pathlib import Path
data = Path("start.sh").read_bytes()
assert b"\r\n" not in data, "start.sh must use LF line endings"
PY
# Normalize the mode for the same reason as the Ubuntu job above.
chmod +x start.sh
test -x start.sh
- name: Syntax and shellcheck
run: |
bash -n start.sh
shellcheck start.sh
- name: Create clean venv and install server deps
run: |
python -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install -r requirements-server.txt pytest
- name: Compile and test
run: |
.venv/bin/python -m compileall -q .
.venv/bin/python -m pytest -q
.venv/bin/python test_npc_protocol.py
.venv/bin/python test_combat_protocol.py