Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .coveragerc

This file was deleted.

28 changes: 6 additions & 22 deletions .github/workflows/mysql-migrations-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,23 @@ jobs:
- name: Checkout repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}

- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y libxmlsec1-dev
- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip dependencies
id: cache-dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/pip_tools.txt') }}
restore-keys: ${{ runner.os }}-pip-
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Ubunto and sql versions
run: |
lsb_release -a
mysql -V
- name: Install Python Dependencies
run: |
pip install -r requirements/pip-tools.txt
pip install -r requirements/production.txt
pip uninstall -y mysqlclient
pip install --no-binary mysqlclient mysqlclient
pip uninstall -y xmlsec
pip install --no-binary xmlsec xmlsec==1.3.13
uv sync --group production --group mysql8 --no-binary-package mysqlclient --no-binary-package xmlsec
- name: Initiate services
run: |
sudo /etc/init.d/mysql start
Expand All @@ -74,4 +58,4 @@ jobs:
run: |
echo "CREATE DATABASE IF NOT EXISTS enterprise_catalog;" | sudo mysql -u root
echo "Running the migrations"
python manage.py migrate --settings=enterprise_catalog.settings.test
uv run python manage.py migrate --settings=enterprise_catalog.settings.test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ diff_*.html
*.report
report
venv
.venv
acceptance_tests.*.log
acceptance_tests.*.png

Expand Down
71 changes: 19 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DEFAULT_GOAL := help
TOX = ''
.PHONY: help clean piptools requirements dev_requirements \
.PHONY: help clean requirements dev_requirements \
doc_requirements prod_requirements static shell test coverage \
isort_check isort style lint quality pii_check validate \
migrate html_coverage upgrade extract_translation dummy_translations \
Expand All @@ -11,11 +10,6 @@ TOX = ''
dev.up.build dev.down dev.destroy dev.stop docker_build \
shellcheck check_keywords install_transifex_client

COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)"

define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
Expand All @@ -28,33 +22,26 @@ endef
export BROWSER_PYSCRIPT
BROWSER := python3 -c "$$BROWSER_PYSCRIPT"

ifdef TOXENV
TOX := tox -- #to isolate each tox environment if TOXENV is defined
endif

help: ## display this help message
@echo "Please use \`make <target>' where <target> is one of"
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'

clean: ## delete generated byte code and coverage reports
find . -name '*.pyc' -delete
coverage erase
uv run coverage erase
rm -rf assets
rm -rf pii_report

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip-tools.txt

requirements: piptools dev_requirements ## sync to default requirements
requirements: dev_requirements ## sync to default requirements

dev_requirements: ## sync to requirements for local development
pip-sync -q requirements/dev.txt
uv sync --group dev

doc_requirements:
pip-sync -q requirements/doc.txt
uv sync --group doc

production-requirements: piptools ## install requirements for production
pip-sync -q requirements/production.txt
production-requirements: ## install requirements for production
uv sync --group production

static: ## generate static files
python3 manage.py collectstatic --noinput
Expand All @@ -63,61 +50,41 @@ shell: ## run Django shell
python3 manage.py shell

test: clean ## run tests and generate coverage report
$(TOX)python3 -Wd -m pytest
uv run python3 -Wd -m pytest

# To be run from CI context
coverage: clean
pytest --cov-report html
$(BROWSER) htmlcov/index.html
uv run pytest --cov-report html

isort_check: ## check that isort has been run
isort --check-only --diff enterprise_catalog/
uv run isort --check-only --diff enterprise_catalog/

isort: ## run isort to sort imports in all Python files
isort --atomic enterprise_catalog/
uv run isort --atomic enterprise_catalog/

style: ## run Python style checker
pycodestyle enterprise_catalog *.py
uv run pycodestyle enterprise_catalog *.py

lint: ## run Python code linting
pylint --rcfile=pylintrc enterprise_catalog *.py
uv run pylint --rcfile=pylintrc enterprise_catalog *.py

quality: clean style isort_check lint ## check code style and import sorting, then lint

pii_check: ## check for PII annotations on all Django models
DJANGO_SETTINGS_MODULE=enterprise_catalog.settings.test \
code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage
uv run code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage

validate: test quality pii_check ## run tests, quality, and PII annotation checks

migrate: ## apply database migrations
python3 manage.py migrate

html_coverage: ## generate and view HTML coverage report
coverage html && open htmlcov/index.html

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: $(COMMON_CONSTRAINTS_TXT) piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# Make sure to compile files after any other files they include!
sed 's/Django<5.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
sed 's/django-simple-history==3.0.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
pip-compile --allow-unsafe --rebuild --upgrade -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
pip-compile --upgrade -o requirements/doc.txt requirements/doc.in
pip-compile --upgrade -o requirements/quality.txt requirements/quality.in
pip-compile --upgrade -o requirements/validation.txt requirements/validation.in
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in
pip-compile --upgrade -o requirements/production.txt requirements/production.in
# Let tox control the Django version for tests
grep -e "^django==" requirements/base.txt > requirements/django.txt
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt
uv run coverage html && open htmlcov/index.html

upgrade: ## upgrade all packages in uv.lock and sync constraints from edx-lint
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

extract_translations: ## extract strings to be translated, outputting .mo files
python3 manage.py makemessages -l en -v1 -d django
Expand Down
3 changes: 2 additions & 1 deletion enterprise_catalog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
]

if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover
import debug_toolbar
# Disable pylint import error because we don't install django-debug-toolbar for CI build
import debug_toolbar # pylint: disable=import-error
urlpatterns.append(path('__debug__/', include(debug_toolbar.urls)))
Loading
Loading