From 52b99b9399b4152509cec525d12d4eef1d736e38 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Wed, 26 Jan 2022 15:16:52 +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 8f02501..fefec36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: matrix: os: [ubuntu-20.04] python-version: ['3.8'] - toxenv: [quality, django32, django40] + toxenv: [quality, django32, django40, check_keywords] steps: - uses: actions/checkout@v2 - name: setup python diff --git a/Makefile b/Makefile index afcf3bc..ef95aa3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean coverage help quality requirements test test-all upgrade validate selfcheck +.PHONY: clean coverage help quality requirements test test-all upgrade validate selfcheck check_keywords .DEFAULT_GOAL := help @@ -66,3 +66,6 @@ validate: quality test ## run tests and quality checks selfcheck: ## check that the Makefile is well-formed @echo "The Makefile is well-formed." + +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 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/tox.ini b/tox.ini index f399f0c..a39ae01 100644 --- a/tox.ini +++ b/tox.ini @@ -42,3 +42,10 @@ commands = isort --check-only tests help_tokens manage.py setup.py test_settings.py make selfcheck +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/test.txt +commands = + make check_keywords