Skip to content

Commit

Permalink
chore: add reserved keywords linter (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbabkhalil authored Jan 12, 2024
1 parent 87f7c03 commit 7b29084
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [quality, django32, django42]
toxenv: [quality, django32, django42, check_keywords]
steps:
- uses: actions/checkout@v4
- name: setup python
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -75,3 +75,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
10 changes: 10 additions & 0 deletions db_keyword_overrides.yml
Original file line number Diff line number Diff line change
@@ -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:
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
pytest-catchlog # Show log output for test failures
pytest-cov # pytest extension for code coverage statistics
pytest-django # pytest extension for better Django support
edx-django-release-util # Contains the reserved keyword check
7 changes: 7 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ coverage[toml]==7.3.3
# via
# -c requirements/common_constraints.txt
# -r requirements/base.in
# edx-django-release-util
edx-django-release-util==1.3.0
# via -r requirements/test.in
exceptiongroup==1.2.0
# via pytest
iniconfig==2.0.0
Expand All @@ -36,6 +39,10 @@ pytest-django==4.7.0
# via -r requirements/test.in
pytz==2023.3.post1
# via django
pyyaml==6.0.1
# via edx-django-release-util
six==1.16.0
# via edx-django-release-util
sqlparse==0.4.4
# via django
tomli==2.0.1
Expand Down
1 change: 1 addition & 0 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def root(*args):
'django.contrib.auth',
'django.contrib.contenttypes',
'help_tokens',
'release_util',
)

LOCALE_PATHS = [
Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ commands =
twine check dist/*
isort --check-only tests help_tokens manage.py setup.py test_settings.py
make selfcheck

[testenv:check_keywords]
allowlist_externals =
make
deps =
-r{toxinidir}/requirements/test.txt
commands =
make check_keywords

0 comments on commit 7b29084

Please sign in to comment.