From 280d7c7c584b3dfb72cf59ba019fb770d3068264 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 13:50:54 +0500 Subject: [PATCH 1/4] chore: add reserved keywords linter --- .github/workflows/ci.yml | 6 ++++++ Makefile | 5 ++++- db_keyword_overrides.yml | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db_keyword_overrides.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf9c69d9..74b00004 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,3 +50,9 @@ jobs: with: flags: unittests fail_ci_if_error: true + - name: Make Check Reserved Keywords + env: + TOXENV: ${{ matrix.toxenv }} + DJANGO_SETTINGS_MODULE: registrar.settings.test + run: | + make check_keywords diff --git a/Makefile b/Makefile index 3483c28e..db7c4a51 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ TOX='' createsuperuser html_coverage extract_translations dummy_translations \ fake_translations pull_translations push_translations \ detect_changed_source_translations validate_translations api_generated \ - validate_api_committed + validate_api_committed check_keywords define BROWSER_PYSCRIPT import os, webbrowser, sys @@ -170,6 +170,9 @@ detect_changed_source_translations: ## check if translation files are up-to-date validate_translations: fake_translations detect_changed_source_translations ## install fake translations and check if translation files are up-to-date +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 + # Docker commands docker_build: 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: From cf96ca9091d80949dc85d8aa87ad59b0a0cf7429 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 15:20:53 +0500 Subject: [PATCH 2/4] chore: add reserved keywords linter --- db_keyword_overrides.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml index dcc39cde..e7221c78 100644 --- a/db_keyword_overrides.yml +++ b/db_keyword_overrides.yml @@ -6,5 +6,7 @@ # - ModelName.field_name --- MYSQL: + - Program.key + - Organization.key SNOWFLAKE: STITCH: From 8b94ae92157ae04759ee07c574362e3b133922db Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 20:34:54 +0500 Subject: [PATCH 3/4] chore: add reserved keywords linter --- db_keyword_overrides.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml index e7221c78..0b9cc7ad 100644 --- a/db_keyword_overrides.yml +++ b/db_keyword_overrides.yml @@ -6,7 +6,6 @@ # - ModelName.field_name --- MYSQL: - - Program.key - Organization.key SNOWFLAKE: STITCH: From 2d4e7ded9817500162efc5d92f1b6ecf51ea7bc2 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Wed, 26 Jan 2022 15:38:11 +0500 Subject: [PATCH 4/4] chore: add reserved keywords linter --- db_keyword_overrides.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml index 0b9cc7ad..e7221c78 100644 --- a/db_keyword_overrides.yml +++ b/db_keyword_overrides.yml @@ -6,6 +6,7 @@ # - ModelName.field_name --- MYSQL: + - Program.key - Organization.key SNOWFLAKE: STITCH: