evennia/.github/workflows/github_action_test_suite.yml
2025-12-19 12:42:24 +01:00

187 lines
4.9 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.11", "3.12", "3.13"]
include:
- python-version: "3.11"
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.11", "3.12", "3.13"]
timeout-minutes: 35
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: evennia
MYSQL_USER: evennia
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=3
--entrypoint="
sh
-c
"printf '[mysqld]\ncharacter-set-server=utf8mb4\ncollation-server=utf8mb4_unicode_ci\ninnodb-default-row-format=DYNAMIC\n' > /etc/mysql/conf.d/custom.cnf && exec docker-entrypoint.sh mysqld"
steps:
- uses: actions/checkout@v4
- name: Install MySQL client
run: |
sudo apt-get update
sudo apt-get install -y default-mysql-client
timeout-minutes: 2
- 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.11", "3.12", "3.13"]
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"
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