Skip to content
Draft
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
13 changes: 0 additions & 13 deletions .coveragerc

This file was deleted.

26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on:
pull_request:
branches:
- "**"
# So the release workflow can run CI before cutting a release.
workflow_call:

jobs:
run_tests:
name: tests
name: ${{ matrix.toxenv }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -27,24 +29,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 }}
# setuptools-scm needs real tag history to compute a version; a default
# shallow/single-commit checkout can't see any tags.
fetch-depth: 0

- name: Install pip
run: pip install -r requirements/pip.txt
- name: Setup uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Install Dependencies
run: pip install -r requirements/ci.txt
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'
id: coverage_comment
if: matrix.python-version == '3.12' && matrix.toxenv == 'django52'
uses: py-cov-action/python-coverage-comment-action@5d8df5979747514c914e1c5a12335a7cf9a2745f # v3
with:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

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

on:
push:
branches: [main]

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

release:
needs: run_ci
runs-on: ubuntu-latest
if: github.ref_name == 'main'
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false

permissions:
contents: write

steps:
- name: Setup | Checkout Repository on Release Branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.ref_name }}

- name: Setup | Force release branch to be at workflow sha
run: |
git reset --hard ${{ github.sha }}

- name: Action | Semantic Version Release
id: release
uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"
changelog: "false"

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

- name: Upload | Distribution Artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: steps.release.outputs.released == 'true'
with:
name: distribution-artifacts
path: dist
if-no-files-found: error

outputs:
released: ${{ steps.release.outputs.released || 'false' }}
version: ${{ steps.release.outputs.version }}

publish_to_pypi:
runs-on: ubuntu-latest
needs: release
if: github.ref_name == 'main' && needs.release.outputs.released == 'true'

permissions:
contents: read
id-token: write

steps:
- name: Setup | Download Build Artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: distribution-artifacts
path: dist

- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ docs/platform_plugin_aspects.*.rst
# Private requirements
requirements/private.in
requirements/private.txt

pii_report/
7 changes: 2 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ build:

python:
install:
- requirements: requirements/doc.txt

# This will pip install this repo into the python environment
# if you are using this in a repo that is not pip installable
# then you should remove the following two lines.
- method: pip
path: .
extra_requirements:
- docs
6 changes: 1 addition & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include LICENSE.txt
include README.rst
include requirements/base.in
include requirements/constraints.txt
recursive-include platform_plugin_aspects *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg
recursive-include src/platform_plugin_aspects *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg
61 changes: 20 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,36 @@ 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

# 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 -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 uv.lock with the latest packages satisfying pyproject.toml constraints
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
uv run tox -e quality

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

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

requirements: clean_tox piptools ## install development environment requirements
pip-sync -q requirements/dev.txt requirements/private.*
requirements: clean_tox ## install development environment requirements
uv sync --group dev
uv tool install tox --with tox-uv

test: clean ## run tests in the current virtualenv
pytest
uv run tox -e py312-django52

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

format:
isort platform_plugin_aspects
isort src/platform_plugin_aspects
black .

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

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

Expand All @@ -90,23 +69,23 @@ selfcheck: ## check that the Makefile is well-formed

extract_translations: ## extract strings to be translated, outputting .mo files
rm -rf docs/_build
cd platform_plugin_aspects && django-admin makemessages -l en -v1 -d django
cd platform_plugin_aspects && django-admin makemessages -l en -v1 -d djangojs
cd src/platform_plugin_aspects && django-admin makemessages -l en -v1 -d django
cd src/platform_plugin_aspects && django-admin makemessages -l en -v1 -d djangojs

compile_translations: ## compile translation files, outputting .po files for each supported language
cd platform_plugin_aspects && i18n_tool generate
cd src/platform_plugin_aspects && i18n_tool generate

detect_changed_source_translations:
cd platform_plugin_aspects && i18n_tool changed
cd src/platform_plugin_aspects && i18n_tool changed

ifeq ($(OPENEDX_ATLAS_PULL),)
pull_translations: ## Pull translations from Transifex
tx pull -t -a -f --mode reviewed --minimum-perc=1
else
# Experimental: OEP-58 Pulls translations using atlas
pull_translations:
find platform_plugin_aspects/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
atlas pull $(OPENEDX_ATLAS_ARGS) translations/platform-plugin-aspects/platform_plugin_aspects/conf/locale:platform_plugin_aspects/conf/locale
find src/platform_plugin_aspects/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
atlas pull $(OPENEDX_ATLAS_ARGS) translations/platform-plugin-aspects/platform_plugin_aspects/conf/locale:src/platform_plugin_aspects/conf/locale
python manage.py compilemessages

@echo "Translations have been pulled via Atlas and compiled."
Expand All @@ -116,7 +95,7 @@ push_translations: ## push source translation files (.po) from Transifex
tx push -s

dummy_translations: ## generate dummy translation (.po) files
cd platform_plugin_aspects && i18n_tool dummy
cd src/platform_plugin_aspects && i18n_tool dummy

build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files

Expand Down
25 changes: 4 additions & 21 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,17 @@
"""

import os
import re
import sys
from datetime import datetime
from importlib.metadata import version as get_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.

Input:
- file_paths: relative path fragments to file with
version string
"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = open(filename, encoding="utf8").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("../platform_plugin_aspects", "__init__.py")
VERSION = get_version("platform-plugin-aspects")
# Configure Django for autodoc usage
os.environ["DJANGO_SETTINGS_MODULE"] = "test_settings"
django_setup()
Expand Down Expand Up @@ -555,8 +538,8 @@ def on_init(app): # pylint: disable=unused-argument
apidoc_path,
"-o",
docs_path,
os.path.join(root_path, "platform_plugin_aspects"),
os.path.join(root_path, "platform_plugin_aspects/migrations"),
os.path.join(root_path, "src", "platform_plugin_aspects"),
os.path.join(root_path, "src", "platform_plugin_aspects", "migrations"),
]
)

Expand Down
Loading
Loading