From 4183031560423a3d2a96b5ecdc57bcf551d0d8a9 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Mon, 24 Jan 2022 18:36:10 +0500 Subject: [PATCH] chore: add reserved keywords linter --- .github/workflows/ci.yml | 2 +- Makefile | 6 +++++- db_keyword_overrides.yml | 10 ++++++++++ tox.ini | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 db_keyword_overrides.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 442226f7..2c29644c 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-drf312, django30-drf312, django31-drf312, django32-drf312, django32-drflatest, quality, docs] + toxenv: [django22-drf312, django30-drf312, django31-drf312, django32-drf312, django32-drflatest, quality, docs, check_keywords] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index e97ec1f0..f5e33528 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" @@ -69,6 +70,9 @@ test_quality: ## Run Quality checks isort --check-only submissions manage.py setup.py settings.py 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 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 54d07cf8..d7f2f0cd 100644 --- a/tox.ini +++ b/tox.ini @@ -32,3 +32,10 @@ deps = commands = python setup.py build_sphinx +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/dev.txt +commands = + make check_keywords