From a5fc4dad35140ae86798b5de5c8e8eb3ff20c674 Mon Sep 17 00:00:00 2001 From: dvoraen <42825596+dvoraen@users.noreply.github.com> Date: Wed, 30 Nov 2022 05:34:08 -0800 Subject: [PATCH] refactor of unit test workflow; uses new action --- .../workflows/github_action_test_suite.yml | 271 +++++++----------- 1 file changed, 109 insertions(+), 162 deletions(-) diff --git a/.github/workflows/github_action_test_suite.yml b/.github/workflows/github_action_test_suite.yml index aefca993e1..32c823ca4f 100644 --- a/.github/workflows/github_action_test_suite.yml +++ b/.github/workflows/github_action_test_suite.yml @@ -5,188 +5,135 @@ name: test-suite on: push: - branches: [ master, develop ] + branches: [master, develop] paths-ignore: - - 'docs/**' + - "docs/**" pull_request: - branches: [ master, develop ] + branches: [master, develop] jobs: - build: + test: + name: Test runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11'] - TESTING_DB: ['sqlite3', 'postgresql', 'mysql'] + python-version: ["3.9", "3.10", "3.11"] + TESTING_DB: ["sqlite3", "postgresql", "mysql"] + include: + - coverage-test: false + - coverage-test: true + python-version: "3.10" + TESTING_DB: "sqlite3" steps: + - uses: actions/checkout@v3 - - uses: actions/checkout@v3 + - name: Set up database (${{ matrix.TESTING_DB }}) + uses: ./.github/actions/setup-database + with: + database: ${{ matrix.TESTING_DB }} + timeout-minutes: 5 - - name: Set up PostgreSQL server - uses: harmon758/postgresql-action@v1 - if: ${{ matrix.TESTING_DB == 'postgresql' }} - with: - postgresql version: '11' - postgresql db: 'evennia' - postgresql user: 'evennia' - postgresql password: 'password' + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: | + pyproject.toml - - name: Set up MySQL server - uses: mirromutth/mysql-action@v1.1 - if: ${{ matrix.TESTING_DB == 'mysql'}} - with: - host port: 3306 - # character set server: 'utf8mb4' - # collation server: 'utf8mb4_unicode_ci' - character set server: 'utf8' - collation server: 'utf8_general_ci' - mysql database: 'evennia' - mysql user: 'evennia' - mysql password: 'password' - mysql root password: root_password + - 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] - # wait for db to activate - - name: wait for db to activate - if: matrix.TESTING_DB == 'postgresql' || matrix.TESTING_DB == 'mysql' - run: | + - 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 - if [ ${{ matrix.TESTING_DB }} = mysql ] - then - while ! mysqladmin ping -h 127.0.0.1 -u root -proot_password -s >/dev/null 2>&1 - do - sleep 1 - echo -n . - done - echo - else - while ! pg_isready -h 127.0.0.1 -q >/dev/null 2>&1 - do - sleep 1 - echo -n . - done - echo - fi + # 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 \ + --source=../evennia \ + --omit=*/migrations/*,*/urls.py,*/test*.py,*.sh,*.txt,*.md,*.pyc,*.service \ + ../bin/unix/evennia test \ + --settings=settings \ + --timing \ + evennia + coverage xml + coverage --version + coverage report | grep TOTAL - - name: mysql privileges - if: matrix.TESTING_DB == 'mysql' - run: | - - cat <