Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Postgres in test env #41

Merged
merged 9 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ jobs:
python-build:
name: Python 3.12
runs-on: ubuntu-latest

services:
postgres:
# Docker Hub image
image: postgres:14
# Provide the credentials
env:
POSTGRES_USER: github
POSTGRES_PASSWORD: github
POSTGRES_DB: github_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -29,3 +49,5 @@ jobs:
run: |
coverage run manage.py test
coverage report
env:
DJANGO_SETTINGS_MODULE: 'chowist.settings.test'
18 changes: 9 additions & 9 deletions chowist/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Generated by 'django-admin startproject' using Django 2.0.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
https://docs.djangoproject.com/en/5.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
https://docs.djangoproject.com/en/5.1/ref/settings/
"""

import os
Expand All @@ -18,7 +18,7 @@


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET", "dummy")
Expand Down Expand Up @@ -78,7 +78,7 @@


# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
Expand All @@ -89,7 +89,7 @@


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
# https://docs.djangoproject.com/en/5.1/topics/i18n/

LANGUAGE_CODE = "en-us"

Expand All @@ -103,21 +103,21 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
# https://docs.djangoproject.com/en/5.1/howto/static-files/

STATIC_URL = "/static/"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "staticfiles")]
STATIC_ROOT = os.path.join(BASE_DIR, "static")


# Authentication
# https://docs.djangoproject.com/en/4.1/topics/auth/default/
# https://docs.djangoproject.com/en/5.1/topics/auth/default/

LOGIN_REDIRECT_URL = "portal:home"


# Logging
# https://docs.djangoproject.com/en/4.1/topics/logging/
# https://docs.djangoproject.com/en/5.1/topics/logging/

LOGGING = {
"version": 1,
Expand Down Expand Up @@ -173,7 +173,7 @@


# Auto field
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"


Expand Down
3 changes: 1 addition & 2 deletions chowist/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"DATABASE": "postgres",
"USER": "postgres",
"HOST": "db",
"PORT": 5432,
Expand Down
6 changes: 3 additions & 3 deletions chowist/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from chowist.settings.base import * # noqa

# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = []


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
"default": {
Expand All @@ -20,5 +20,5 @@


# Email Backend
# https://docs.djangoproject.com/en/4.1/topics/email/#email-backends
# https://docs.djangoproject.com/en/5.1/topics/email/#email-backends
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
8 changes: 4 additions & 4 deletions chowist/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from chowist.settings.base import * # noqa

# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "circle_test",
"NAME": "github_test",
"USER": "github",
"PASSWORD": "github",
"HOST": "127.0.0.1",
"PORT": "5432",
"USERNAME": "circleci",
"PASSWORD": "circleci",
}
}
Loading