evennia/.github/workflows/github_action_test_suite.yml
2026-02-14 19:39:12 +01:00

183 lines
6.2 KiB
YAML

# This Evennia workflow will install Python dependencies, run tests with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: test-suite
on:
push:
branches: [main, develop]
paths-ignore:
- "docs/**"
pull_request:
branches: [main, develop]
jobs:
test-sqlite:
name: Test (SQLite)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
include:
- python-version: "3.12"
coverage-test: true
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up database (sqlite3)
uses: ./.github/actions/setup-database
with:
database: sqlite3
timeout-minutes: 5
- name: Run tests
uses: ./.github/actions/run-tests
with:
python-version: ${{ matrix.python-version }}
testing-db: sqlite3
coverage-test: ${{ matrix.coverage-test == true && 'true' || 'false' }}
needs-postgres-package: "false"
needs-mysql-package: "false"
coveralls-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
test-mysql:
name: Test (MySQL)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
- name: Set up MySQL
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.0"
root-password: root_password
user: evennia
password: password
my-cnf: |
[mysqld]
character-set-server=utf8mb3
collation-server=utf8mb3_unicode_ci
innodb_default_row_format=DYNAMIC
innodb_file_per_table=1
- name: Set up database (mysql)
uses: ./.github/actions/setup-database
with:
database: mysql
timeout-minutes: 5
- name: Run tests
uses: ./.github/actions/run-tests
with:
python-version: ${{ matrix.python-version }}
testing-db: mysql
coverage-test: "false"
needs-postgres-package: "false"
needs-mysql-package: "true"
test-postgresql:
name: Test (PostgreSQL)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
timeout-minutes: 35
services:
postgres:
image: postgres:14
env:
POSTGRES_DB: evennia
POSTGRES_USER: evennia
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
timeout-minutes: 2
- name: Set up database (postgresql)
uses: ./.github/actions/setup-database
with:
database: postgresql
timeout-minutes: 5
- name: Run tests
uses: ./.github/actions/run-tests
with:
python-version: ${{ matrix.python-version }}
testing-db: postgresql
coverage-test: "false"
needs-postgres-package: "true"
needs-mysql-package: "false"
- name: PostgreSQL diagnostics on failure
if: ${{ failure() }}
env:
PGPASSWORD: password
run: |
psql -h localhost -U evennia -d evennia -c "SELECT now() as ts, pid, usename, state, wait_event_type, wait_event, xact_start, query_start, LEFT(query, 240) AS query FROM pg_stat_activity ORDER BY query_start NULLS LAST;"
psql -h localhost -U evennia -d evennia -c "SELECT blocked_locks.pid AS blocked_pid, blocking_locks.pid AS blocking_pid, blocked_activity.usename AS blocked_user, blocking_activity.usename AS blocking_user, LEFT(blocked_activity.query, 160) AS blocked_query, LEFT(blocking_activity.query, 160) AS blocking_query FROM pg_locks blocked_locks JOIN pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid JOIN pg_locks blocking_locks ON blocking_locks.locktype = blocked_locks.locktype AND blocking_locks.database IS NOT DISTINCT FROM blocked_locks.database AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple AND blocking_locks.virtualxid IS NOT DISTINCT FROM blocked_locks.virtualxid AND blocking_locks.transactionid IS NOT DISTINCT FROM blocked_locks.transactionid AND blocking_locks.classid IS NOT DISTINCT FROM blocked_locks.classid AND blocking_locks.objid IS NOT DISTINCT FROM blocked_locks.objid AND blocking_locks.objsubid IS NOT DISTINCT FROM blocked_locks.objsubid AND blocking_locks.pid != blocked_locks.pid JOIN pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid WHERE NOT blocked_locks.granted;"
deploy:
name: Deploy Docker Image
needs: [test-sqlite, test-mysql, test-postgresql]
runs-on: ubuntu-latest
if: ${{ github.repository == 'evennia/evennia' && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push for main
if: ${{ github.ref == 'refs/heads/main' }}
id: docker_build_main
uses: docker/build-push-action@v3
with:
push: true
tags: evennia/evennia:latest
- name: Build and push for develop
if: ${{ github.ref == 'refs/heads/develop' }}
id: docker_build_develop
uses: docker/build-push-action@v3
with:
push: true
tags: evennia/evennia:develop