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
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
ignore = E128
max-line-length = 96
exclude =
.tox,
.git,
docs,
docs/conf.py,
src/enmerkar_underscore/vendor,
*.egg*
51 changes: 28 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,39 @@ on:
push:
branches: [master]
pull_request:
branches:
- '**'
# Allow this workflow to be called from other workflows
workflow_call:


jobs:
run_tests:
name: tests
runs-on: ${{ matrix.os }}
name: ${{ matrix.toxenv }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.11', '3.12']
toxenv: ['django42', 'django52']
python-version: ["3.12"]
toxenv: [quality, docs, py312-django42, py312-django52]

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

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

- name: Install tox
run: pip install tox

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

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

- name: Install CI dependencies
run: uv sync --group ci

- name: Run tox
run: uv run tox -e ${{ matrix.toxenv }}

- name: Upload coverage to Codecov
if: matrix.toxenv == 'py312-django42'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
with:
flags: unittests
fail_ci_if_error: true
31 changes: 0 additions & 31 deletions .github/workflows/publish_pypi.yml

This file was deleted.

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

on:
push:
branches: [master]

jobs:
run_tests:
uses: ./.github/workflows/ci.yml

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

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.ref_name }}

- name: Force branch to workflow sha
run: git reset --hard ${{ github.sha }}

- name: Run Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@39dd2052f2ce8282a5d932c31d58a2ca06d2550e # v10.6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"
changelog: "false"

- name: Upload to GitHub Release Assets
uses: python-semantic-release/publish-action@5a5718ce47b892ef699f2972dae122297771d641 # v10.6.1
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 == 'master' && needs.release.outputs.released == 'true'

permissions:
contents: read
id-token: write

steps:
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: distribution-artifacts
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat
include requirements/constraints.txt
52 changes: 12 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
help:
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "lint - check style with flake8"
@echo "quality - check style with flake8"
@echo "test - run tests quickly with the default Python"
@echo "test-all - run tests on every Python version with tox"
@echo "coverage - check code coverage quickly with the default Python"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "release - package and upload a release"
@echo "dist - package"
@echo "upgrade update the pip requirements files to use the latest releases satisfying our constraints"
@echo "upgrade - update the pip requirements files to use the latest releases satisfying our constraints"

clean: clean-build clean-pyc
rm -fr htmlcov/
Expand All @@ -25,47 +22,22 @@ clean-pyc:
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

lint:
flake8 django-babel-underscore tests
quality:
uv run tox -e quality

test:
py.test tests/
uv run tox -e py312-django52

test-all:
tox

coverage:
coverage run --source django-babel-underscore setup.py test
coverage report -m
coverage html
open htmlcov/index.html
uv run tox

docs:
rm -f docs/django-babel-underscore.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ django-babel-underscore
$(MAKE) -C docs clean
$(MAKE) -C docs html
open docs/_build/html/index.html

release: clean
python setup.py sdist upload
python setup.py bdist_wheel upload
uv run tox -e docs

dist: clean
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
requirements:
uv sync --group dev
uv tool install tox --with tox-uv

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade:
pip install -qr requirements/pip-tools.txt
pip-compile --upgrade --allow-unsafe --rebuild -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/dev.txt requirements/dev.in
# Let tox control the Django version for tests
sed '/^[dD]jango==/d' requirements/test.txt > requirements/tox.txt
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Codecov configuration
# https://docs.codecov.com/docs/codecov-yaml
26 changes: 7 additions & 19 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,7 @@

import sys
import os

# 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 documentation root, use os.path.abspath to make it
# absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
project_root = os.path.dirname(cwd)

# Insert the project root dir as the first element in the PYTHONPATH.
# This lets us ensure that the source package is imported, and that its
# version is used.
sys.path.insert(0, project_root)

import django-babel-underscore
from importlib.metadata import version as get_version, PackageNotFoundError

# -- General configuration ---------------------------------------------

Expand Down Expand Up @@ -62,9 +46,13 @@
# the built documents.
#
# The short X.Y version.
version = django-babel-underscore.__version__
try:
_pkg_version = get_version("enmerkar-underscore")
except PackageNotFoundError:
_pkg_version = "0.0.0"
version = _pkg_version
# The full version, including alpha/beta/rc tags.
release = django-babel-underscore.__version__
release = _pkg_version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Loading