Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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.

77 changes: 40 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,58 @@ on:
branches: [master]
pull_request:
branches: [master]
workflow_call:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
django-version: ["pinned", "5.2"]
toxenv:
- "py312-django42"
- "py312-django52"
- "translations"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install requirements
run: make requirements
- name: Upgrade packages
run: |
pip install -U pip wheel codecov -c requirements/constraints.txt
if [[ "${{ matrix.django-version }}" != "pinned" ]]; then
pip install "django~=${{ matrix.django-version }}.0"
pip check # fail if this test-reqs/Django combination is broken
fi
- name: Validate translations
run: make validate_translations
- name: Run tests
run: make test
enable-cache: true
python-version: '3.12'

- name: Install Dependencies
run: uv sync --group ci

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: uv run tox

- name: Codecov
run: codecov
if: startsWith(matrix.toxenv, 'py312-django')
run: uv run --with codecov codecov

quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
toxenv:
- "quality"
- "pii_check"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install requirements
run: make requirements
- name: Upgrade packages
run: pip install -U pip wheel codecov
- name: Run pylint
run: make lint
- name: Run pycodestyle
run: make style
- name: Run isort
run: make isort_check
- name: Run pii check
run: make pii_check
enable-cache: true
python-version: '3.12'

- name: Install Dependencies
run: uv sync --group ci

- name: Run Checks
env:
TOXENV: ${{ matrix.toxenv }}
run: uv run tox
34 changes: 11 additions & 23 deletions .github/workflows/mysql8-migrations-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,29 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- 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: Ubuntu 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
uv pip uninstall mysqlclient
uv pip install --no-binary mysqlclient mysqlclient
uv pip uninstall xmlsec
uv pip install --no-binary xmlsec xmlsec==1.3.13
- name: Initiate services
run: |
sudo /etc/init.d/mysql start
Expand All @@ -74,4 +62,4 @@ jobs:
run: |
echo "CREATE DATABASE IF NOT EXISTS license_manager;" | sudo mysql -u root
echo "Running the migrations"
python manage.py migrate --settings=license_manager.settings.test
uv run python manage.py migrate --settings=license_manager.settings.test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ diff_*.html
*.report
report
venv
.venv
acceptance_tests.*.log
acceptance_tests.*.png

Expand Down
66 changes: 21 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := help

.PHONY: help clean piptools requirements ci_requirements dev_requirements \
.PHONY: help clean compile-requirements requirements ci_requirements dev_requirements \
validation_requirements doc_requirements production-requirements static shell \
test coverage isort_check isort style lint quality pii_check validate \
migrate html_coverage upgrade extract_translation dummy_translations \
Expand Down Expand Up @@ -31,24 +31,24 @@ clean: ## delete generated byte code and coverage reports
rm -rf assets
rm -rf pii_report

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip-tools.txt -c requirements/constraints.txt
compile-requirements: ## generate the uv.lock file without upgrading packages
uv lock

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

ci_requirements: piptools validation_requirements ## sync to requirements needed for CI checks
ci_requirements: validation_requirements ## sync to requirements needed for CI checks

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

validation_requirements: ## sync to requirements for testing & code quality checking
pip-sync -q requirements/validation.txt
uv sync --group test

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
python manage.py collectstatic --noinput
Expand All @@ -59,34 +59,34 @@ django_shell: ## run Django shell
test: clean ## run tests and generate coverage report
## ``--ds`` Has the highest settings precedence:
## https://pytest-django.readthedocs.io/en/latest/configuring_django.html#order-of-choosing-settings
pytest --ds=license_manager.settings.test
uv run pytest --ds=license_manager.settings.test

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

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

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

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

lint: ## run Python code linting
edx_lint write pylintrc # first, write pylintrc in case tweaks have changed
uv run edx_lint write pylintrc # first, write pylintrc in case tweaks have changed
DJANGO_SETTINGS_MODULE=license_manager.settings.test \
pylint --rcfile=pylintrc license_manager *.py
uv run pylint --rcfile=pylintrc license_manager *.py

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

quality_fix: style isort lint ## Check code style, FIX any imports, then lint

pii_check: ## check for PII annotations on all Django models
DJANGO_SETTINGS_MODULE=license_manager.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

Expand All @@ -101,33 +101,9 @@ dev.migrate: app-migrate
html_coverage: ## generate and view HTML coverage report
coverage html && open htmlcov/index.html

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 "$(@)"
echo "$(COMMON_CONSTRAINTS_TEMP_COMMENT)" | cat - $(@) > temp && mv temp $(@)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: piptools $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
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
# Make sure to compile files after any other files they include!
sed 's/Django<4.0//g' requirements/common_constraints.txt > tmp_con; cat tmp_con > requirements/common_constraints.txt; rm tmp_con
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
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
python manage.py makemessages -l en -v1 -d django
Expand Down
Loading
Loading