From bbd2bce7e3b3959377a9db3917afa461b93f0f4f Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 16:15:24 +0500 Subject: [PATCH] chore: add reserved keywords linter --- .github/workflows/ci.yml | 2 +- Makefile | 5 ++++- db_keyword_overrides.yml | 10 ++++++++++ tox.ini | 10 ++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 db_keyword_overrides.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08fe399b..488aa65b 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] + toxenv: [django22, django30, django31, django32, quality, docs, check_keywords] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index d826d4ab..553b00ac 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: clean compile_translations coverage docs dummy_translations \ extract_translations fake_translations help pull_translations push_translations \ - quality requirements selfcheck test test-all upgrade validate + quality requirements selfcheck test test-all upgrade validate check_keywords .DEFAULT_GOAL := help @@ -114,3 +114,6 @@ docker.shell: docker.make.%: docker run --volume $(PWD):/app --entrypoint /bin/bash python:3.6 -c "cd /app && make $*" + +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 bd432c38..54c40633 100644 --- a/tox.ini +++ b/tox.ini @@ -45,3 +45,13 @@ commands = isort --check-only --diff edx_ace manage.py setup.py test_settings.py make selfcheck +[testenv:check_keywords] +whitelist_externals = + make +setenv = + DJANGO_SETTINGS_MODULE = test_settings + PYTHONPATH = {toxinidir} +deps = + -r{toxinidir}/requirements/test.txt +commands = + make check_keywords