Skip to content

Commit

Permalink
Fix GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Dec 21, 2023
1 parent 3ca9fc8 commit 23a800d
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 87 deletions.
110 changes: 65 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,90 @@ 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@v5
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", "3.12"]
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

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

- name: Install latest pip, Hatch and coveralls
run: pip install --upgrade pip hatch coveralls
# Django 4.2
- python-version: 3.12
django-version: 4.2

- name: Install GDAL binaries
run: |
sudo apt-get update
sudo apt-get install binutils libproj-dev gdal-bin
# 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
- run: coverage combine
- 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
python -m pip install -e .
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
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ VERSION := $(shell hatch version)

.PHONY: test
test:
hatch run test
python manage.py test

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

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

.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:
Expand All @@ -29,7 +30,7 @@ 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 @@ -38,17 +39,20 @@ 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
git tag -a v${VERSION} -m "Release ${VERSION}"
git push origin --tags

.PHONY: clean
clean: docs
rm -rf build dist src/*.egg-info .coverage*
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx>=7.2.6
sphinx-mdinclude>=0.5.3
furo>=2023.05.20
34 changes: 4 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]
build-backend = "setuptools.build_meta"
requires = ["setuptools"]

[project]
authors = [
Expand Down Expand Up @@ -30,13 +30,11 @@ dependencies = [
"beautifulsoup4>=4.8.0",
]
description = "Bootstrap 3 for Django"
dynamic = [
"version",
]
license = "BSD-3-Clause"
license = {file = "LICENSE"}
name = "django-bootstrap3"
readme = "README.md"
requires-python = ">=3.8"
version = "23.5.dev1"

[project.urls]
Changelog = "https://github.com/zostera/django-bootstrap3/blob/main/CHANGELOG.md"
Expand All @@ -45,17 +43,6 @@ Homepage = "https://github.com/zostera/django-bootstrap3"
Issues = "https://github.com/zostera/django-bootstrap3/issues"
Source = "https://github.com/zostera/django-bootstrap3"

[tool.hatch.version]
path = "src/bootstrap3/__about__.py"

[tool.hatch.build.targets.sdist]
include = [
"/src",
]

[tool.hatch.build.targets.wheel]
packages = ["src/bootstrap3"]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=7.2.6",
Expand Down Expand Up @@ -132,19 +119,6 @@ dependencies = [
]
detached = true

[tool.hatch.envs.lint.scripts]
all = [
"style",
]
fmt = [
"ruff --fix {args:.}",
"ruff format {args:.}",
"style",
]
style = [
"ruff {args:.}",
]

[tool.ruff]
fix = false
fixable = [
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r requirements-test.txt
-r docs/requirements.txt
3 changes: 3 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tox==4.11.4
coverage==7.3.3
ruff==0.1.8
1 change: 0 additions & 1 deletion src/bootstrap3/__about__.py

This file was deleted.

5 changes: 4 additions & 1 deletion src/bootstrap3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from .__about__ import __version__
import importlib.metadata

__all__ = [
"__version__",
]


__version__ = importlib.metadata.version("django-bootstrap3")
51 changes: 51 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[tox]
args_are_paths = false
envlist =
py38-{3.2,4.1,4.2},
py39-{3.2,4.1,4.2},
py310-{3.2,4.1,4.2,5.0,main},
py311-{4.1,4.2,5.0,main},
py312-{4.2,5.0,main},
docs,
lint,

[testenv]
basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
usedevelop = true
pip_pre = true
setenv =
PYTHONPATH={toxinidir}
PYTHONWARNINGS=all
commands =
coverage run --source=src manage.py test {posargs}
deps =
3.2: Django==3.2.*
4.0: Django==4.0.*
4.1: Django==4.1.*
4.2: Django==4.2.*
5.0: Django==5.0.*
main: https://github.com/django/django/archive/main.tar.gz
coverage
-r{toxinidir}/requirements-test.txt

[testenv:docs]
basepython = python3.11
allowlist_externals = make
setenv =
PYTHONWARNINGS=default
commands =
make docs
deps =
-r{toxinidir}/docs/requirements.txt

[testenv:lint]
basepython = python3.11
allowlist_externals = ruff
deps = ruff
commands = ruff .

0 comments on commit 23a800d

Please sign in to comment.