Skip to content

Commit

Permalink
#4 | Workflow failing for migrations (#5)
Browse files Browse the repository at this point in the history
* Fix: Included `DATABASE_URL` at correct location

* Chore: Update lock

* Chore: Update actions version

* Chore: Removed unparsable values in env.ci

* Fix: Failing migrations

* Fix: Remove drf_yasg

* Chore: Renamed tests file, added pytest to pyproject file

* Chore: Added sample test

* Chore: Changed command internals for formatting

* Chore: Ran formatting

---------

Co-authored-by: lordsarcastic <>
  • Loading branch information
lordsarcastic authored Jan 24, 2024
1 parent f77a22a commit 2c7c74b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 143 deletions.
4 changes: 1 addition & 3 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
SECRET_KEY=django-insecure-!y1)0r+77*tn34q46z$c_rpb5%3qjtsltx#))lz38s%9e5&qx9
DEBUG=1
ALLOWED_HOSTS='["localhost", "127.0.0.1"]'
ENVIRONMENT=dev
PIPENV_NOSPIN: 'true'
WORKON_HOME: ~/.pipenv/virtualenvs
ENVIRONMENT=dev
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python 3.12
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: '3.12'

- name: Install Pipenv
uses: dschep/install-pipenv-action@v1
run: |
pip install pipenv
pipenv --version
- name: Cache Pipenv Virtualenv
uses: actions/cache@v1
uses: actions/cache@v4
id: pipenv-cache
with:
path: ~/.local/share/virtualenvs
Expand All @@ -50,12 +52,16 @@ jobs:
- name: Lint and format checks
run: |
pipenv run ruff check .
pipenv run ruff format --check .
- name: Set environment variables
run: |
cp .env.ci .env
- name: Running Django migrations check to ensure that there are no migrations left to create
env:
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/test?sslmode=disable'

run: |
pipenv run python manage.py makemigrations --check --dry-run
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ flush-db:

format:
@docker compose run --rm app ruff format .
@docker compose run --rm app ruff check . --fix --select I001
@docker compose run --rm app ruff check . --fix --select I

install:
@pipenv install --dev
Expand All @@ -46,7 +46,7 @@ shell:
@docker compose run --rm app python manage.py shell

test:
@docker compose run --rm app py.test
@docker compose run --rm app py.test tests

testcase:
@docker compose run --rm app py.test $(test)
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pillow = "*"
psycopg2-binary = "*"
django-anymail = {extras = ["mailgun"], version = "*"}
pydantic = "*"
drf-yasg = "*"
pydantic-settings = "*"
dj-database-url = "*"

Expand Down
89 changes: 4 additions & 85 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class GeneralSettings(BaseSettings):
"djoser",
"anymail",
"corsheaders",
"drf_yasg",
"django_extensions",
]

CUSTOM_APPS = []
Expand Down Expand Up @@ -126,12 +126,7 @@ class GeneralSettings(BaseSettings):
"UserAttributeSimilarityValidator"
),
},
{
"NAME": (
"django.contrib.auth.password_validation."
"MinimumLengthValidator"
)
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{
"NAME": (
"django.contrib.auth.password_validation."
Expand Down Expand Up @@ -182,5 +177,3 @@ class GeneralSettings(BaseSettings):
SIMPLE_JWT = {
"AUTH_HEADER_TYPES": ("JWT",),
}

EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
15 changes: 0 additions & 15 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
"""config URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

Expand Down
39 changes: 16 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
[tool.black]
line-length = 79
target-version = ['py39']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| migrations
)/
'''

[tool.isort]
skip = [".gitignore", ".dockerignore"]
skip_glob = ["*/dist/*", "*/migrations/*"]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "config.settings"
pythonpath = ["src", "tests"]
python_files = [
"test_*.py",
"*_test.py",
"testing/python/*.py"
]
norecursedirs = [
"scripts",
"node_modules",
"py-requirements",
"webpack",
".*",
"{args}"
]


[tool.ruff]
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/test_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_addition():
assert 1 + 1 == 2

0 comments on commit 2c7c74b

Please sign in to comment.