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
41 changes: 10 additions & 31 deletions .github/workflows/ci.yml
Comment thread
farhan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,14 @@ on:
workflow_call:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
python-version: "3.12"

- name: Install dependencies
run: uv sync --extra dev

- name: Run linting
run: make lint

test:
name: Test (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
run_tests:
name: ${{ matrix.toxenv }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
django-version: ["4.2", "5.2"]
toxenv: [lint, docs, django42, django52]

steps:
- name: Checkout repository
Expand All @@ -46,18 +27,16 @@ jobs:
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Install dependencies
run: |
uv lock --upgrade-package "django==${{ matrix.django-version }}.*"
uv sync --extra test
- name: Install CI dependencies
run: uv sync --group ci

- name: Run tests with coverage
run: make test-with-coverage
- name: Run tox
run: uv run tox -e ${{ matrix.toxenv }}

- name: Upload coverage to Codecov
if: matrix.django-version == '4.2'
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
if: matrix.toxenv == 'django42'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: false
fail_ci_if_error: true
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help requirements upgrade lint format test test-with-coverage docs clean
.PHONY: help requirements upgrade lint format test docs clean
.PHONY: extract_translations


Expand All @@ -15,26 +15,23 @@ help: ## Show this help message

requirements: ## Sync dev dependencies
uv sync
uv tool install tox --with tox-uv

upgrade: ## Upgrade python dependencies
uv lock --upgrade

lint: ## Run linting checks
uv run ruff check .
uv run ruff format --check .
tox -e lint

format: ## Auto-fix formatting issues
uv run ruff check --fix .
uv run ruff format .

test: ## Run tests with pytest
uv run pytest

test-with-coverage: ## Run tests with coverage reporting
uv run pytest --cov=$(SRC_DIRECTORY) --cov-report=xml
test: ## Run tests against all supported Python/Django combinations
tox -e "py312-django{42,52}"

docs: ## Build documentation
$(MAKE) -C docs html
tox -e docs

clean: ## Clean build artifacts
rm -rf build/
Expand Down
29 changes: 27 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ dev = [
"ruff",
"edx-i18n-tools",
]
test = [

[dependency-groups]
# Base test packages, no Django version pinned
test-base = [
"coverage",
"ddt",
"edx-lint",
Expand All @@ -59,10 +62,26 @@ test = [
"pytest>=7.0",
"xblock-sdk",
]
docs = [
# Default test group: current supported Django version
# Update Django pin here when bumping the default; add a legacy group for older versions
test = [
{include-group = "test-base"},
"Django>=5.2,<6.0",
]
# Legacy Django 4.2 support
django42 = [
{include-group = "test-base"},
"Django>=4.2,<5.0",
]
doc = [
{include-group = "test"},
"sphinx",
"sphinx-book-theme",
]
ci = [
"tox",
"tox-uv",
]

[project.entry-points."xblock.v1"]
audio = "audio:AudioXBlock"
Expand Down Expand Up @@ -173,6 +192,12 @@ directory = "htmlcov"
# https://docs.astral.sh/uv/reference/settings/
[tool.uv]
package = true
conflicts = [
[
{group = "test"},
{group = "django42"},
],
]

# Setuptools SCM configuration
# https://setuptools-scm.readthedocs.io/
Expand Down
26 changes: 26 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tox]
envlist = py312-django{42,52}, lint, docs
requires = tox-uv>=1

[testenv:lint]
runner = uv-venv-lock-runner
extras = dev
commands =
ruff check .
ruff format --check .

[testenv]
runner = uv-venv-lock-runner
dependency_groups =
django42: django42
django52: test
commands = pytest --cov=src --cov-report=xml {posargs}

[testenv:docs]
runner = uv-venv-lock-runner
basepython = python3.12
changedir = {toxinidir}/docs
dependency_groups = doc
allowlist_externals = make
commands =
make html
Loading