diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 263777e..d9dfc1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,21 @@ jobs: matrix: python-version: ['3.6', '3.7', '3.8'] + services: + postgres: + image: postgres:10 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - uses: actions/checkout@v2 @@ -41,6 +56,12 @@ jobs: - name: Tox tests run: | tox -v -- --cov --cov-append --cov-report term-missing --cov-report xml + env: + DB_NAME: postgres + DB_USER: postgres + DB_PASSWORD: postgres + DB_HOST: localhost + DB_PORT: 5432 - name: Upload coverage uses: codecov/codecov-action@v1 diff --git a/tests/settings.py b/tests/settings.py index e34c891..9d23a70 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -7,10 +7,11 @@ INSTALLED_APPS = ( DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", - "NAME": os.environ.get("DJANGO_DATABASE_NAME_POSTGRES", "modelutils"), - "USER": os.environ.get("DJANGO_DATABASE_USER_POSTGRES", 'postgres'), - "PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD_POSTGRES", ""), - "HOST": os.environ.get("DJANGO_DATABASE_HOST_POSTGRES", ""), + "NAME": os.environ.get("DB_NAME", "modelutils"), + "USER": os.environ.get("DB_USER", 'postgres'), + "PASSWORD": os.environ.get("DB_PASSWORD", ""), + "HOST": os.environ.get("DB_HOST", ""), + "PORT": os.envrion.get("DB_PORT", 5432) }, } SECRET_KEY = 'dummy' diff --git a/tox.ini b/tox.ini index 2a98cff..b0f81ac 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ ignore_outcome = passenv = CI GITHUB_* + DB_* usedevelop = True commands = pytest {posargs}