From 9ba86a874e25bd6cdf09c03362feb161ec5d49a4 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 18 Jan 2022 19:26:33 +0500 Subject: [PATCH 1/2] chore: add reserved keywords linter --- .github/workflows/ci.yml | 2 +- Makefile | 5 ++++- db_keyword_overrides.yml | 10 ++++++++++ tox.ini | 8 ++++++++ 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 c1aad0d0..f47753bc 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, docs, without-django] + toxenv: [django22, django30, django31, django32, quality, docs, without-django, check_keywords] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index a4e6d8fa..f73314c1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := test -.PHONY: clean html_coverage quality requirements test upgrade +.PHONY: clean html_coverage quality requirements test upgrade check_keywords clean: ## remove generated byte code, coverage reports, and build artifacts find . -name '*.pyc' -exec rm -f {} + @@ -37,3 +37,6 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy # Let tox control the Django version for tests sed '/^[dD]jango==/d' requirements/django-test.txt > requirements/django-test.tmp mv requirements/django-test.tmp requirements/django-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..84c1b7db --- /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 42efa097..4606d337 100644 --- a/tox.ini +++ b/tox.ini @@ -35,3 +35,11 @@ commands = # -C changes the directory to `docs` before running the command. make -e -C docs clean make -e -C docs html + +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/dev.txt +commands = + make check_keywords From 060d0c3eff3798dabed1c604b8172e7c677d33c3 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 18 Jan 2022 19:34:05 +0500 Subject: [PATCH 2/2] chore: add reserved keywords linter --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4606d337..e0acd4a7 100644 --- a/tox.ini +++ b/tox.ini @@ -40,6 +40,6 @@ commands = whitelist_externals = make deps = - -r{toxinidir}/requirements/dev.txt + -r{toxinidir}/requirements/django-test.txt commands = make check_keywords