mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 22:06:30 +01:00
Test refactor CI test workflow, re-adding postgres
This commit is contained in:
parent
0b92202ae6
commit
a652cbea61
4 changed files with 224 additions and 97 deletions
168
.github/workflows/github_action_test_suite.yml
vendored
168
.github/workflows/github_action_test_suite.yml
vendored
|
|
@ -12,98 +12,146 @@ on:
|
|||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
test-sqlite:
|
||||
name: Test (SQLite)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.11", "3.12", "3.13"]
|
||||
TESTING_DB: ["sqlite3", "mysql"]
|
||||
include:
|
||||
- python-version: "3.11"
|
||||
TESTING_DB: "sqlite3"
|
||||
coverage-test: true
|
||||
|
||||
timeout-minutes: 35
|
||||
|
||||
env:
|
||||
UNIT_TEST_SETTINGS: "--settings=settings --keepdb --timing"
|
||||
COVERAGE_TEST_SETTINGS: "--settings=settings --timing"
|
||||
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"
|
||||
|
||||
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
|
||||
--character-set-server=utf8mb4
|
||||
--collation-server=utf8mb4_unicode_ci
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up database (${{ matrix.TESTING_DB }})
|
||||
- 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: ${{ matrix.TESTING_DB }}
|
||||
database: mysql
|
||||
timeout-minutes: 5
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run-tests
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: pip
|
||||
cache-dependency-path: |
|
||||
pyproject.toml
|
||||
testing-db: mysql
|
||||
coverage-test: "false"
|
||||
needs-postgres-package: "false"
|
||||
needs-mysql-package: "true"
|
||||
|
||||
- name: Install package dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install wheel
|
||||
pip install psycopg2-binary==2.9.5 # req by postgresql
|
||||
pip install mysqlclient
|
||||
pip install coveralls
|
||||
pip install tblib
|
||||
pip install .
|
||||
pip install .[extra]
|
||||
test-postgresql:
|
||||
name: Test (PostgreSQL)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
- name: Initialize evennia
|
||||
run: |
|
||||
evennia --init testing_mygame
|
||||
cp .github/workflows/${{ matrix.TESTING_DB }}_settings.py testing_mygame/server/conf/settings.py
|
||||
cd testing_mygame
|
||||
evennia migrate
|
||||
evennia collectstatic --noinput
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.11", "3.12", "3.13"]
|
||||
|
||||
# For non-coverage tests, run them in parallel.
|
||||
- name: Run test suite
|
||||
if: ${{ ! matrix.coverage-test }}
|
||||
working-directory: testing_mygame
|
||||
run: |
|
||||
evennia test ${{ env.UNIT_TEST_SETTINGS }} evennia
|
||||
timeout-minutes: 35
|
||||
|
||||
# OBS - it's important to not run the coverage tests with --parallel, it messes up the coverage
|
||||
# calculation!
|
||||
- name: Run test suite with coverage
|
||||
if: ${{ matrix.coverage-test }}
|
||||
working-directory: testing_mygame
|
||||
run: |
|
||||
coverage run --rcfile=../pyproject.toml ../bin/unix/evennia test ${{ env.COVERAGE_TEST_SETTINGS }} evennia
|
||||
coverage combine
|
||||
coverage xml
|
||||
coverage --version
|
||||
coverage report | grep TOTAL
|
||||
|
||||
# we only want to run coverall once, so we only do it for the designated matrix combination(s)
|
||||
# it's also not critical if pushing to either service fails (happens for PRs since env is not
|
||||
# available outside of the evennia org)
|
||||
- name: Send data to Coveralls
|
||||
if: ${{ matrix.coverage-test && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
|
||||
continue-on-error: true
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13
|
||||
env:
|
||||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
||||
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: |
|
||||
cd testing_mygame
|
||||
coveralls
|
||||
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
|
||||
needs: [test-sqlite, test-mysql, test-postgresql]
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'evennia/evennia' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
|
||||
if: ${{ github.repository == 'evennia/evennia' && github.ref == 'refs/heads/main' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue