Skip to content

Commit

Permalink
Update package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Dec 24, 2023
1 parent 6a9340f commit b4b1466
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 165 deletions.
103 changes: 63 additions & 40 deletions .github/workflows/test.yml
Expand Up @@ -6,65 +6,88 @@ concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:

static_tests:
name: Static Tests
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install latest pip and Hatch
run: pip install --upgrade pip hatch
- name: Lint
run: hatch run lint:all
- name: Docs
run: hatch run docs:build
- name: Build
run: hatch build
- uses: chartboost/ruff-action@v1

tests_matrix:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
django-version: [3.2, 4.1, 4.2, 5.0, "main"]
exclude:
# Django 3.2
- python-version: "3.10"
django-version: 3.2
- python-version: 3.11
django-version: 3.2
- python-version: 3.12
django-version: 3.2

steps:
- uses: actions/checkout@v4
# Django 4.1
- python-version: 3.12
django-version: 4.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Django 4.2
- python-version: 3.12
django-version: 4.2

- name: Install latest pip, Hatch and coveralls
run: pip install --upgrade pip hatch coveralls
# Django 5.0
- python-version: 3.8
django-version: 5.0
- python-version: 3.9
django-version: 5.0

- name: Run tests
run: hatch run test-cov
# Django main
- python-version: 3.8
django-version: "main"
- python-version: 3.9
django-version: "main"

- name: Coverage combine
run: coverage combine
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: requirements-test.txt
- run: python -m pip install -r requirements-test.txt
- run: python -m pip install -U Django==${{ matrix.django-version }}
if: matrix.django-version != 'main'
- run: python -m pip install -U https://github.com/django/django/archive/master.tar.gz
if: matrix.django-version == 'main'
- run: python -m pip install -e .
- run: coverage run manage.py test
- run: python -m pip install -U coveralls
- name: Upload coveralls (parallel)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
run: coveralls --service=github

- name: Upload coveralls (parallel)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
run: coveralls --service=github
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: docs/requirements.txt
- name: Install and build
run: |
python -m pip install -r docs/requirements.txt
make docs
tests:
if: always()
runs-on: ubuntu-latest
needs: [ static_tests, tests_matrix ]
needs: [ tests_matrix, ruff, docs ]
steps:
- name: Check tests matrix status
if: needs.tests_matrix.result != 'success'
Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yml
Expand Up @@ -5,6 +5,7 @@ build:
tools:
python: "3.11"
commands:
- pip install -U pip hatch
- hatch run docs:build
- pip install -U pip
- pip install -U -r docs/requirements.txt
- make docs
- mv docs/_build $READTHEDOCS_OUTPUT
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Expand Up @@ -45,8 +45,6 @@ Ready to contribute? Here\'s how to set up `django-icons` for local development.

You will need some knowledge of git, github, and Python/Django development. Using a Python virtual environment is advised.

This project uses [Hatch](https://github.com/pypa/hatch) for environments and builds.

### Local installation

This section assumes you know about local Python versions and virtual environments.
Expand All @@ -56,7 +54,7 @@ To clone the repository and install the requirements for local development:
```console
git clone git://github.com/zostera/django-icons.git
cd django-icons
pip install -U pip hatch
pip install -U pip -r requirements-dev.txt
pip install -e .
```

Expand Down
38 changes: 26 additions & 12 deletions Makefile
@@ -1,31 +1,37 @@
VERSION := $(shell hatch version)
VERSION := $(shell sed -n 's/^ *version.*=.*"\([^"]*\)".*/\1/p' pyproject.toml)

.PHONY: test
test:
hatch run test
coverage run manage.py test
coverage report

.PHONY: tests
tests:
hatch run all:test
tox

.PHONY: reformat
reformat:
hatch run lint:fmt
ruff format .
ruff --fix .

.PHONY: lint
lint:
hatch run lint:style
ruff .

.PHONY: docs
docs:
hatch run docs:build
docs: clean
cd docs && sphinx-build -b html -d _build/doctrees . _build/html

.PHONY: example
example:
cd example && python manage.py runserver

.PHONY: porcelain
porcelain:
ifeq ($(shell git status --porcelain),)
@echo "Working directory is clean."
else
@echo "Error - working directory is dirty. Commit those changes!";
@echo "Error - working directory is dirty. Commit your changes.";
@exit 1;
endif

Expand All @@ -34,17 +40,25 @@ branch:
ifeq ($(shell git rev-parse --abbrev-ref HEAD),main)
@echo "On branch main."
else
@echo "Error - Not on branch main!"
@echo "Error - Not on branch main."
@exit 1;
endif

.PHONY: build
build: docs
rm -rf build dist src/*.egg-info
hatch build
python -m build

.PHONY: publish
publish: porcelain branch build
hatch publish
twine check dist/*
twine upload dist/*
git tag -a v${VERSION} -m "Release ${VERSION}"
git push origin --tags

.PHONY: clean
clean: docs
rm -rf build dist src/*.egg-info .coverage*

.PHONY: version
version:
@echo ${VERSION}
11 changes: 1 addition & 10 deletions docs/conf.py
@@ -1,4 +1,3 @@
import importlib
from datetime import datetime

import tomllib
Expand All @@ -7,15 +6,7 @@
pyproject = tomllib.load(f)

project = pyproject["project"]["name"]
conf = {"module": project.replace("-", "_")}

try:
conf.update(pyproject["tool"]["sphinx"]["x-conf"])
except KeyError:
pass

module = importlib.import_module(conf["module"])
release = module.__version__
release = pyproject["project"]["version"]
version = ".".join(release.split(".")[:2])
author = ", ".join(author["name"] for author in pyproject["project"]["authors"])
year = datetime.now().year
Expand Down
6 changes: 3 additions & 3 deletions docs/requirements.txt
@@ -1,3 +1,3 @@
sphinx==7.2.6
sphinx_rtd_theme==1.3.0
sphinx-mdinclude==0.5.3
sphinx>=7.2.6
sphinx-mdinclude>=0.5.3
furo>=2023.05.20

0 comments on commit b4b1466

Please sign in to comment.