Skip to content
Open
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.

27 changes: 13 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Python CI

on:
push:
branches: [ main ]
workflow_call:
pull_request:
branches:
- '**'


jobs:
run_tests:
name: tests
name: ${{ matrix.toxenv }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
Expand All @@ -37,19 +38,17 @@ jobs:
--health-retries 3
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
fetch-depth: 0

- name: Install pip
run: pip install -r requirements/pip.txt
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: pip install -r requirements/ci.txt
- name: Install CI dependencies
run: uv sync --group ci

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

run: uv run tox -e ${{ matrix.toxenv }}
15 changes: 8 additions & 7 deletions .github/workflows/lint-imports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
lint-imports:
name: Lint Python Imports
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0

- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
python-version: '3.12'

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -e . -r requirements/quality.txt
run: uv sync --group quality

- name: Analyze imports
run: lint-imports
run: uv run lint-imports
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
push:
branches: [main]

jobs:
run_tests:
uses: ./.github/workflows/ci.yml
secrets: inherit
permissions:
contents: read

release:
runs-on: ubuntu-latest
needs: run_tests
if: github.ref_name == 'main'
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
outputs:
released: ${{ steps.release.outputs.released || 'false' }}
version: ${{ steps.release.outputs.version }}

steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.ref_name }}
fetch-depth: 0

- run: git reset --hard ${{ github.sha }}

- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v10.6.1
with:
github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "github-actions@github.com"
changelog: "false"

- name: Upload dist artifacts
if: steps.release.outputs.released == 'true'
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/

publish_to_pypi:
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.released == 'true'
permissions:
contents: read
id-token: write

steps:
- name: Download dist artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ docs/modules.rst
docs/openedx_content.rst
docs/openedx_content.*.rst

# Private requirements
requirements/private.in
requirements/private.txt

# database file
dev.db*

Expand Down
11 changes: 9 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ version: 2
sphinx:
configuration: docs/conf.py

build:
os: ubuntu-lts-latest
tools:
python: "3.12"

python:
version: 3.12
install:
- requirements: requirements/doc.txt
- method: uv
command: sync
groups:
- doc
7 changes: 5 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ build:
tools:
python: "3.12"

# Optionally install extra requirements required to build your docs
# Install dependencies via uv, using the "doc" dependency group from pyproject.toml
python:
install:
- requirements: requirements/doc.txt
- method: uv
command: sync
groups:
- doc
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include CHANGELOG.rst
include LICENSE.txt
include README.rst
include requirements/base.in
recursive-include src *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg *.py *.yaml *.json *.csv
46 changes: 12 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,35 @@ clean: ## remove generated byte code, coverage reports, and build artifacts
rm -fr *.egg-info

coverage: clean ## generate and view HTML coverage report
pytest --cov-report html
uv run pytest --cov-report html
$(BROWSER)htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
tox -e docs
uv run tox -e docs
$(BROWSER)docs/_build/html/index.html

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --rebuild $(PIP_COMPILE_OPTS)

compile-requirements: export CUSTOM_COMPILE_COMMAND=make upgrade
compile-requirements: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
pip install -qr requirements/pip.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/doc.txt requirements/doc.in
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
# Let tox control the Django version for tests
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt

upgrade: ## update the pip requirements files to use the latest releases satisfying our constraints
make compile-requirements PIP_COMPILE_OPTS="--upgrade"
upgrade: ## update the uv.lock file with the latest packages satisfying pyproject.toml
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

quality: ## check coding style with pycodestyle and pylint
tox -e quality
lint-imports
uv run tox -e quality
uv run lint-imports

pii_check: ## check for PII annotations on all Django models
tox -e pii_check
uv run tox -e pii_check

requirements: ## install development environment requirements
pip install -qr requirements/pip-tools.txt
pip-sync requirements/dev.txt requirements/private.*
uv sync --group dev

test: clean ## run tests in the current virtualenv
pytest tests
uv run pytest tests

diff_cover: test ## find diff lines that need test coverage
diff-cover coverage.xml
uv run diff-cover coverage.xml

test-all: quality pii_check ## run tests on every supported Python/Django combination
tox
uv run tox

validate: quality pii_check test ## run tests and quality checks

Expand Down
23 changes: 5 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,17 @@
serve to show the default.
"""
import os
import re
import sys
from datetime import datetime
from importlib.metadata import PackageNotFoundError, version as get_distribution_version
from subprocess import check_call

from django import setup as django_setup


def get_version(*file_paths):
"""
Extract the version string from the file at the given relative path fragments.
"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to find version string.')


REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(REPO_ROOT)

VERSION = get_version('../src/openedx_core', '__init__.py')
try:
VERSION = get_distribution_version('openedx-core')
except PackageNotFoundError:
VERSION = '0.0.0'

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
Loading