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

chore: add reserved keywords linter #154

Merged
merged 3 commits into from
May 30, 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
27 changes: 27 additions & 0 deletions .github/workflows/check-reserved-keywords.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <target>' where <target> is one of"
Expand Down Expand Up @@ -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
##################
Expand Down
10 changes: 10 additions & 0 deletions db_keyword_overrides.yml
Original file line number Diff line number Diff line change
@@ -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:
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ django-model-utils
jsonfield
pytz
djangorestframework
edx-django-release-util
7 changes: 7 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -247,17 +253,22 @@ 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
# -r requirements/test.txt
# 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
Expand Down
9 changes: 9 additions & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -54,6 +57,7 @@
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'release_util',

# Submissions
'submissions'
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading