# 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: [master, develop] paths-ignore: - "docs/**" pull_request: branches: [master, develop] jobs: test: name: Test runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.10", "3.11"] TESTING_DB: ["sqlite3", "postgresql", "mysql"] include: - python-version: "3.10" TESTING_DB: "sqlite3" coverage-test: true steps: - 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 Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: pip cache-dependency-path: | pyproject.toml - 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] - 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 # For non-coverage tests, run them in parallel. - name: Run test suite if: ${{ ! matrix.coverage-test }} working-directory: testing_mygame run: | evennia test \ --settings=settings \ --keepdb \ --parallel 4 \ --timing \ evennia # 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 # 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/master' || github.ref == 'refs/heads/develop') }} continue-on-error: true env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | cd testing_mygame coveralls deploy: name: Deploy Docker Image needs: test runs-on: ubuntu-latest if: ${{ github.repository == 'evennia/evennia' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') }} 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 master if: ${{ github.ref == 'refs/heads/master' }} id: docker_build_master 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