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
6 changes: 0 additions & 6 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ Check off if complete *or* not applicable:
- [ ] All reviewers approved
- [ ] Reviewer tested the code following the testing instructions
- [ ] CI build is green
- [ ] Changelog entry added using scriv with short description of the change
- [ ] Documentation updated (not only docstrings)
- [ ] Code dependencies reviewed
- [ ] Fixup commits are squashed away
- [ ] Unit tests added/updated
- [ ] Noted any: Concerns, dependencies, migration issues, deadlines, tickets

**Post Merge:**
- [ ] Trigger the release workflow to create a new GitHub release.
- [ ] Check new version is pushed to PyPI after tag-triggered build is finished.
- [ ] Delete working branch (if not needed anymore)
- [ ] Upgrade the package in the Open edX platform requirements (if applicable)
33 changes: 20 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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:
os: [ubuntu-latest]
python-version: ['3.12']
Expand All @@ -28,21 +30,26 @@ jobs:

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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 }}
# Pinned to match the `uv` package version locked in uv.lock (a
# transitive dependency of tox-uv/tox-uv-bare). Keep this in sync
# whenever `make upgrade` changes that pinned version, otherwise
# tox-uv's internal `--locked` check can disagree with this
# workflow's own `uv sync`/`uv run` calls.
version: "0.11.32"

- 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
run: uv run tox -e ${{ matrix.toxenv }}

- name: Run coverage
if: matrix.python-version == '3.12' && matrix.toxenv == 'django42'
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

119 changes: 64 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,72 @@
name: Create a new GitHub Release
name: Release

on:
workflow_dispatch:
inputs:
tag:
description: "The type of version bump"
required: true
type: choice
options:
- "major"
- "minor"
- "patch"
push:
branches: [main]

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

release:
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.inputs.tag }}
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
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"

- name: Publish | Upload to GitHub Release Assets
uses: python-semantic-release/publish-action@v10.6.1
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}

- 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:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3.12

- name: Install requirements
run: pip install scriv bump-my-version

- name: Install pandoc for scriv
run: sudo apt install -y pandoc

- name: Set up Git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'

- name: Get current and new version
id: version
run: |
echo "CURRENT_VERSION=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
echo "NEW_VERSION=$(bump-my-version show --increment $TAG new_version)" >> $GITHUB_OUTPUT

- name: Bump version
run: bump-my-version bump $TAG

- name: Collect changelog
run: make changelog

- name: Commit changes and create tag
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
with:
branch: ${{ github.ref }}
commit_message: "chore: bump version ${{ steps.version.outputs.CURRENT_VERSION }} → ${{ steps.version.outputs.NEW_VERSION }}"
tagging_message: "v${{ steps.version.outputs.NEW_VERSION }}"

- name: Create GitHub release
run: scriv github-release --repo=openedx/openedx-filters
env:
GITHUB_TOKEN: ${{ github.token }}
- 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
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ sphinx:

python:
install:
- requirements: requirements/doc.txt
- method: uv
command: sync
groups:
- doc
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. changelog-insertion-marker

Change Log
==========

Expand Down
6 changes: 2 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include CHANGELOG.rst
include LICENSE.txt
include README.rst
include requirements/base.in
recursive-include openedx_filters *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg *.py
include openedx_filters/py.typed
include requirements/constraints.txt
recursive-include src/openedx_filters *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg *.py
include src/openedx_filters/py.typed
44 changes: 11 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ coverage: clean ## generate and view HTML coverage report
$(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

changelog-entry: ## Create a new changelog entry
Expand All @@ -36,45 +36,23 @@ changelog-entry: ## Create a new changelog entry
changelog: ## Collect changelog entries in the CHANGELOG.rst file
scriv collect

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

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## 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 --rebuild -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 -i.tmp '/^[d|D]jango==/d' requirements/test.txt
sed -i.tmp '/^djangorestframework==/d' requirements/test.txt
rm requirements/test.txt.tmp
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
pylint openedx_filters test_utils *.py
pylint src/openedx_filters test_utils *.py
mypy
pycodestyle openedx_filters *.py
ruff check openedx_filters *.py
isort --check-only --diff --recursive test_utils openedx_filters *.py test_settings.py
python setup.py bdist_wheel
pycodestyle src/openedx_filters *.py
ruff check src/openedx_filters *.py
isort --check-only --diff --recursive test_utils src/openedx_filters *.py test_settings.py
python -m build --wheel
twine check dist/*
make selfcheck


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

test: clean ## run tests in the current virtualenv
pytest
Expand All @@ -83,7 +61,7 @@ diff_cover: test ## find diff lines that need test coverage
diff-cover coverage.xml

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

validate: quality test ## run tests and quality checks

Expand Down
1 change: 0 additions & 1 deletion changelog.d/scriv.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[scriv]
version = literal: openedx_filters/__init__.py: __version__
format = rst
entry_title_template = file: changelog.d/scriv/entry_title.${config:format}.j2
new_fragment_template = file: changelog.d/scriv/new_fragment.${config:format}.j2
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ coverage:
default:
enabled: yes
target: auto
# The old .coveragerc's `omit = tests` didn't actually match any file
# paths (coverage.py omit patterns need a wildcard, e.g. `*/tests/*`),
# so test modules were inadvertently included in the coverage
# measurement pre-migration and inflated the reported project %
# (test files execute almost all of their own lines). The new
# [tool.coverage.run] omit patterns in pyproject.toml correctly
# exclude them, which drops the reported total by ~0.25 percentage
# points as a one-time discontinuity in this PR's own base-vs-head
# comparison, not an actual regression in production code coverage.
# No threshold added: `target: auto` compares against each PR's own
# base commit, so once this PR merges, the new percentage becomes
# the baseline for every future comparison -- there's no lingering
# gap to accommodate, and this status check isn't required for
# merging anyway.
patch:
default:
enabled: yes
Expand Down
7 changes: 5 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
from os.path import dirname, relpath

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../src'))

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -218,7 +218,10 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None:

import openedx_filters

start_dir = os.path.abspath(os.path.join(dirname(openedx_filters.__file__), ".."))
# openedx_filters.__file__ is src/openedx_filters/__init__.py under the
# src/ layout, so go up two levels (out of src/) to reach the repo root
# that GitHub blob URLs are relative to.
start_dir = os.path.abspath(os.path.join(dirname(openedx_filters.__file__), "..", ".."))
file_path = relpath(file_path, start=start_dir).replace(os.path.sep, "/")

return f"{REPO_URL}/{file_path}{linespec}"
Loading
Loading