1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +00:00
webvirtcloud/.github/workflows/test.yml
catborise f889861e18 fix(migrations): a fresh PostgreSQL database migrates, and CI tests it
The first appsettings migrations insert the default rows with fixed ids,
which a PostgreSQL id sequence does not see; the login lockout migration,
the first to insert without an id, then collided with id 1. It now moves
the sequence past the existing rows first (a no-op on sqlite), which also
covers a database upgraded from any earlier migration. A test compute
password exceeded its 14-character column, which only PostgreSQL enforces.
2026-10-07 16:31:56 +03:00

113 lines
3.2 KiB
YAML

name: Test Suite
on:
push:
branches: ['**']
pull_request:
branches: [master]
# the jobs only read the code
permissions:
contents: read
jobs:
test:
name: Python ${{ matrix.python-version }} / ${{ matrix.database }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
database: [sqlite]
include:
- python-version: '3.12'
database: postgresql
# Used by the postgresql leg only; settings fall back to sqlite when
# WEBVIRTCLOUD_DB_HOST is empty.
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: webvirtcloud
POSTGRES_PASSWORD: webvirtcloud
POSTGRES_DB: webvirtcloud
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
WEBVIRTCLOUD_DB_HOST: ${{ matrix.database == 'postgresql' && 'localhost' || '' }}
WEBVIRTCLOUD_DB_PASSWORD: webvirtcloud
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
conf/requirements.txt
dev/requirements.txt
# Build headers for the sdist-only bindings (libvirt-python, python-ldap)
- name: Install System Dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
libvirt-dev \
libldap2-dev \
libsasl2-dev \
pkg-config \
gcc
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r dev/requirements.txt
- name: Configure WebVirtCloud Settings
run: |
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
SECRET_KEY=$(python -c 'import secrets; print(secrets.token_urlsafe(50))')
sed -i "s|^SECRET_KEY = .*|SECRET_KEY = \"${SECRET_KEY}\"|" webvirtcloud/settings.py
- name: Check For Missing Migrations
run: python manage.py makemigrations --check --dry-run
- name: Run Django Migrations
run: python manage.py migrate --noinput
# Includes the vrtManager tests; fails below the coverage floor in pyproject.toml
- name: Run Test Suite
run: |
coverage run manage.py test
coverage report --skip-covered
- name: Validate OpenAPI Schema
run: python manage.py spectacular --validate --fail-on-warn --file /dev/null
# Security warnings (HSTS, secure cookies) depend on the deployment;
# gate on errors only.
- name: Deployment Checks
run: python manage.py check --deploy --fail-level ERROR
- name: Audit Installed Packages
run: pip-audit
docker:
name: Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build Image
run: docker build -t webvirtcloud:ci .