mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
103 lines
3.4 KiB
YAML
103 lines
3.4 KiB
YAML
# evennia/run-tests
|
|
|
|
# Use this action to run the Evennia test suite after database setup.
|
|
# This action handles Python setup, dependency installation, evennia initialization,
|
|
# and test execution with optional coverage.
|
|
|
|
name: Run Evennia tests
|
|
description: "Sets up Python, installs dependencies, initializes Evennia, and runs the test suite."
|
|
|
|
inputs:
|
|
python-version:
|
|
description: "Python version to use for testing."
|
|
required: true
|
|
testing-db:
|
|
description: "Database type being tested (sqlite3, mysql, postgresql)."
|
|
required: true
|
|
coverage-test:
|
|
description: "Whether to run tests with coverage (true/false)."
|
|
required: false
|
|
default: "false"
|
|
needs-mysql-package:
|
|
description: "Whether to install mysqlclient package (true/false)."
|
|
required: false
|
|
default: "false"
|
|
needs-postgres-package:
|
|
description: "Whether to install psycopg2-binary package (true/false)."
|
|
required: false
|
|
default: "false"
|
|
coveralls-token:
|
|
description: "Coveralls repository token (optional, only needed for coverage tests)."
|
|
required: false
|
|
default: ""
|
|
|
|
runs:
|
|
using: "composite"
|
|
|
|
steps:
|
|
- name: Set up Python ${{ inputs.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
cache: pip
|
|
cache-dependency-path: |
|
|
pyproject.toml
|
|
|
|
- name: Install package dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install wheel
|
|
if [ "${{ inputs.needs-postgres-package }}" == "true" ]; then
|
|
pip install psycopg2-binary==2.9.5 # req by postgresql
|
|
fi
|
|
if [ "${{ inputs.needs-mysql-package }}" == "true" ]; then
|
|
pip install mysqlclient
|
|
fi
|
|
pip install coveralls
|
|
pip install tblib
|
|
pip install .
|
|
pip install .[extra]
|
|
shell: bash
|
|
|
|
- name: Initialize evennia
|
|
run: |
|
|
evennia --init testing_mygame
|
|
cp .github/workflows/${{ inputs.testing-db }}_settings.py testing_mygame/server/conf/settings.py
|
|
cd testing_mygame
|
|
evennia migrate
|
|
evennia collectstatic --noinput
|
|
shell: bash
|
|
|
|
# For non-coverage tests, run them in parallel.
|
|
- name: Run test suite
|
|
if: ${{ inputs.coverage-test != 'true' }}
|
|
working-directory: testing_mygame
|
|
run: |
|
|
evennia test --settings=settings --keepdb --timing evennia
|
|
shell: bash
|
|
|
|
# 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: ${{ inputs.coverage-test == 'true' }}
|
|
working-directory: testing_mygame
|
|
run: |
|
|
coverage run --rcfile=../pyproject.toml ../bin/unix/evennia test --settings=settings --timing evennia
|
|
coverage combine
|
|
coverage xml
|
|
coverage --version
|
|
coverage report | grep TOTAL
|
|
shell: bash
|
|
|
|
# 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: ${{ inputs.coverage-test == 'true' && github.ref == 'refs/heads/main' && inputs.coveralls-token != '' }}
|
|
continue-on-error: true
|
|
env:
|
|
COVERALLS_REPO_TOKEN: ${{ inputs.coveralls-token }}
|
|
working-directory: testing_mygame
|
|
run: |
|
|
coveralls
|
|
shell: bash
|