diff --git a/.github/workflows/check-reserved-keywords.yml b/.github/workflows/check-reserved-keywords.yml new file mode 100644 index 0000000..7c535ad --- /dev/null +++ b/.github/workflows/check-reserved-keywords.yml @@ -0,0 +1,27 @@ +name: Check Reserved Keywords + +on: + - pull_request + +jobs: + check-reserved-keywords: + name: Check Reserved Keywords + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install pip + run: pip install -r requirements/pip.txt + + - name: Install Dependencies + run: pip install -r requirements/dev.txt + + - name: Check Keywords + run: make check_keywords diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc0303f..0399f46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,6 @@ jobs: python-version: ['3.8', '3.11', '3.12'] toxenv: [quality, docs, django42-drf315, django42-drflatest] - steps: - uses: actions/checkout@v2 - name: setup python diff --git a/Makefile b/Makefile index 524e0a5..a958c83 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ endef export BROWSER_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" -.PHONY: clean, coverage, diff_cover, docs, help, dev_requirements, test, test_quality, test_requirements, upgrade +.PHONY: clean, coverage, diff_cover, docs, help, dev_requirements, test, test_quality, test_requirements, upgrade,\ + check_keywords help: ## Display this help message @echo "Please use \`make ' where is one of" @@ -83,6 +84,9 @@ test_quality: ## Run Quality checks isort --check-only submissions manage.py setup.py settings.py --skip migrations pycodestyle . --config=pycodestyle +check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names + python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml + ################## #Devstack commands ################## diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml new file mode 100644 index 0000000..dcc39cd --- /dev/null +++ b/db_keyword_overrides.yml @@ -0,0 +1,10 @@ +# This file is used by the 'check_reserved_keywords' management command to allow specific field names to be overridden +# when checking for conflicts with lists of restricted keywords used in various database/data warehouse tools. +# For more information, see: https://github.com/edx/edx-django-release-util/release_util/management/commands/check_reserved_keywords.py +# +# overrides should be added in the following format: +# - ModelName.field_name +--- +MYSQL: +SNOWFLAKE: +STITCH: diff --git a/requirements/base.in b/requirements/base.in index 18a523f..9d938c3 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -7,3 +7,4 @@ django-model-utils jsonfield pytz djangorestframework +edx-django-release-util diff --git a/requirements/base.txt b/requirements/base.txt index d05b414..dfa7040 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -17,15 +17,22 @@ django==4.2.13 # -r requirements/base.in # django-model-utils # djangorestframework + # edx-django-release-util # jsonfield django-model-utils==4.5.1 # via -r requirements/base.in djangorestframework==3.15.1 # via -r requirements/base.in +edx-django-release-util==1.4.0 + # via -r requirements/base.in jsonfield==3.1.0 # via -r requirements/base.in pytz==2024.1 # via -r requirements/base.in +pyyaml==6.0.1 + # via edx-django-release-util +six==1.16.0 + # via edx-django-release-util sqlparse==0.5.0 # via django typing-extensions==4.11.0 diff --git a/requirements/dev.txt b/requirements/dev.txt index 53df241..af64bbe 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -86,6 +86,7 @@ django==4.2.13 # -r requirements/test.txt # django-model-utils # djangorestframework + # edx-django-release-util # jsonfield django-model-utils==4.5.1 # via @@ -103,6 +104,11 @@ docutils==0.19 # -r requirements/test.txt # pydata-sphinx-theme # sphinx +edx-django-release-util==1.4.0 + # via + # -r requirements/base.txt + # -r requirements/docs.txt + # -r requirements/test.txt edx-lint==5.3.6 # via -r requirements/test.txt exceptiongroup==1.2.1 @@ -247,8 +253,11 @@ pytz==2024.1 # babel pyyaml==6.0.1 # via + # -r requirements/base.txt + # -r requirements/docs.txt # -r requirements/test.txt # code-annotations + # edx-django-release-util requests==2.32.2 # via # -r requirements/docs.txt @@ -256,8 +265,10 @@ requests==2.32.2 # sphinx six==1.16.0 # via + # -r requirements/base.txt # -r requirements/docs.txt # -r requirements/test.txt + # edx-django-release-util # edx-lint # pockets # python-dateutil diff --git a/requirements/docs.txt b/requirements/docs.txt index d943bf8..2257704 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -34,6 +34,7 @@ django==4.2.13 # -r requirements/base.txt # django-model-utils # djangorestframework + # edx-django-release-util # jsonfield django-model-utils==4.5.1 # via -r requirements/base.txt @@ -43,6 +44,8 @@ docutils==0.19 # via # pydata-sphinx-theme # sphinx +edx-django-release-util==1.4.0 + # via -r requirements/base.txt idna==3.7 # via requests imagesize==1.4.1 @@ -74,10 +77,16 @@ pytz==2024.1 # via # -r requirements/base.txt # babel +pyyaml==6.0.1 + # via + # -r requirements/base.txt + # edx-django-release-util requests==2.32.2 # via sphinx six==1.16.0 # via + # -r requirements/base.txt + # edx-django-release-util # pockets # sphinxcontrib-napoleon snowballstemmer==2.2.0 diff --git a/requirements/test.txt b/requirements/test.txt index 2a69172..8ad0ce5 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -66,6 +66,7 @@ dill==0.3.8 # -r requirements/docs.txt # django-model-utils # djangorestframework + # edx-django-release-util # jsonfield django-model-utils==4.5.1 # via @@ -79,6 +80,10 @@ docutils==0.19 # -r requirements/docs.txt # pydata-sphinx-theme # sphinx +edx-django-release-util==1.4.0 + # via + # -r requirements/base.txt + # -r requirements/docs.txt edx-lint==5.3.6 # via -r requirements/test.in exceptiongroup==1.2.1 @@ -188,14 +193,20 @@ pytz==2024.1 # -r requirements/docs.txt # babel pyyaml==6.0.1 - # via code-annotations + # via + # -r requirements/base.txt + # -r requirements/docs.txt + # code-annotations + # edx-django-release-util requests==2.32.2 # via # -r requirements/docs.txt # sphinx six==1.16.0 # via + # -r requirements/base.txt # -r requirements/docs.txt + # edx-django-release-util # edx-lint # pockets # python-dateutil diff --git a/settings.py b/settings.py index 26c5344..d718f05 100644 --- a/settings.py +++ b/settings.py @@ -28,6 +28,9 @@ }, } +# New DB primary keys default to an IntegerField. +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', @@ -54,6 +57,7 @@ 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', + 'release_util', # Submissions 'submissions' diff --git a/tox.ini b/tox.ini index c4785c6..4696224 100644 --- a/tox.ini +++ b/tox.ini @@ -29,3 +29,10 @@ deps = commands = python setup.py build_sphinx +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/dev.txt +commands = + make check_keywords