From 60c9c2c9f1d7cf455fd0d5de8a5cd0b30909dbfb Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Mon, 24 Jan 2022 18:28:26 +0500 Subject: [PATCH] chore: add reserved keywords linter --- .github/workflows/ci.yml | 2 +- Makefile | 5 ++++- db_keyword_overrides.yml | 10 ++++++++++ tox.ini | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 db_keyword_overrides.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46ae4e42..6314c339 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: matrix: os: [ubuntu-20.04] python-version: ['3.8'] - toxenv: [django22, django30, django31, django32, quality] + toxenv: [django22, django30, django31, django32, quality, check_keywords] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 400e97d7..8998881e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean quality requirements test upgrade +.PHONY: clean quality requirements test upgrade check_keywords clean: coverage erase @@ -43,3 +43,6 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with # Let tox control the Django version for tests sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp mv requirements/test.tmp requirements/test.txt + +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 diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml new file mode 100644 index 00000000..dcc39cde --- /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/tox.ini b/tox.ini index 77f4e157..dbdae8db 100644 --- a/tox.ini +++ b/tox.ini @@ -19,3 +19,10 @@ commands = pycodestyle --config=.pep8 auth_backends pylint --rcfile=pylintrc auth_backends +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/test.txt +commands = + make check_keywords