diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 8df3326..4c0f239 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -10,22 +10,32 @@ jobs: build: runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: [3.9, 3.11] + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: github_actions + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} - - name: Install Dependencies + python-version: 3.9 + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: Run Tests + - name: Run migrations + run: python manage.py migrate + - name: Run tests run: | - cd backend - python manage.py test + cd backend + python manage.py test diff --git a/backend/core/settings.py b/backend/core/settings.py index 65fc5f7..9089633 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -22,7 +22,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = config('SECRET_KEY') +SECRET_KEY = config('SECRET_KEY', default='j5&66&8@b-!3tbq!=w6-dypl($_0zzoi*ilxd1*&$_6s-59il5') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=bool) @@ -158,6 +158,17 @@ DATABASES = { } } +if os.environ.get('GITHUB_WORKFLOW'): + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'github_actions', + 'USER': 'postgres', + 'PASSWORD': 'postgres', + 'HOST': '127.0.0.1', + 'PORT': '5432', + } + } # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators