Skip to content

Switch testing/build suite from Nox to Hatch #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4a746be
switch CI to use hatch commands
Archmonger Nov 26, 2024
f3c0ee8
semi-functional test runner with hatch
Archmonger Nov 27, 2024
f7a2923
Add example check workflow
Archmonger Nov 27, 2024
5804c4c
Add JavaScript check
Archmonger Nov 27, 2024
3d46f36
Merge remote-tracking branch 'upstream/main' into switch-from-nox-to-…
Archmonger Nov 27, 2024
a22efb5
Remove `reactpy_django.config.REACTPY_DEBUG_MODE`
Archmonger Nov 27, 2024
2ca4e28
Add runserver command
Archmonger Nov 27, 2024
3353d48
Switch to servestatic
Archmonger Nov 27, 2024
c06ba86
Get the `hatch test` command working
Archmonger Nov 27, 2024
0221585
use head method for the bulk of link checking
Archmonger Nov 27, 2024
437f87f
Auto install playwright in conftest
Archmonger Nov 27, 2024
a75309a
Run multi-db tests
Archmonger Nov 27, 2024
f5976b2
Greater separation of tests
Archmonger Nov 27, 2024
9131a4a
avoid debug keyword
Archmonger Nov 27, 2024
83acfaa
go back to snapshotting Django's debug value
Archmonger Nov 27, 2024
e563287
hatch local builds are fucked, so just re-use the base env
Archmonger Nov 27, 2024
a74c2dd
Add sleep to hello world test
Archmonger Nov 28, 2024
1f1df86
Fix warning on calling DB functions in appconfig.ready
Archmonger Nov 28, 2024
3aac221
Make github test runner more verbose
Archmonger Nov 28, 2024
5178af8
Add docs for new hatch commands
Archmonger Nov 28, 2024
9af272f
Disable link checking
Archmonger Nov 28, 2024
d9eaf07
Put sleep on the correct pyscript file
Archmonger Nov 28, 2024
0e12980
Remove sleep, add longer page timeout for pyscript
Archmonger Nov 28, 2024
4aec1b5
Add notice about ReactPy upper limit change
Archmonger Nov 28, 2024
1048ff3
Rename workflows
Archmonger Nov 28, 2024
1597441
new format for eslint config
Archmonger Nov 28, 2024
0092316
fix javascript:fix command
Archmonger Nov 28, 2024
47cc484
Remove old manifest file
Archmonger Nov 28, 2024
9cb9240
remove duplicates from teardownclass
Archmonger Dec 1, 2024
d4a6649
Increase default timeout
Archmonger Dec 1, 2024
56d0990
self review
Archmonger Dec 1, 2024
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
Next Next commit
switch CI to use hatch commands
  • Loading branch information
Archmonger committed Nov 26, 2024
commit 4a746beaf541986660b9f6661705ca47004aa1e0
6 changes: 3 additions & 3 deletions .github/workflows/publish-develop-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install -r requirements/build-docs.txt
- name: Install dependencies
run: pip install --upgrade pip hatch uv
- name: Publish Develop Docs
run: |
git config user.name github-actions
git config user.email github-actions@github.com
cd docs
mike deploy --push develop
hatch run docs:deploy_develop
concurrency:
group: publish-docs
6 changes: 3 additions & 3 deletions .github/workflows/publish-latest-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install -r requirements/build-docs.txt
- name: Install dependencies
run: pip install --upgrade pip hatch uv
- name: Publish ${{ github.event.release.name }} Docs
run: |
git config user.name github-actions
git config user.email github-actions@github.com
cd docs
mike deploy --push --update-aliases ${{ github.event.release.name }} latest
hatch run docs:deploy_latest ${{ github.ref_name }}
concurrency:
group: publish-docs
6 changes: 2 additions & 4 deletions .github/workflows/publish-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ jobs:
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/build-pkg.txt
run: pip install --upgrade pip hatch uv
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build --sdist --wheel --outdir dist .
hatch build --clean
twine upload dist/*
21 changes: 6 additions & 15 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
# - name: Check docs links
# uses: umbrelladocs/action-linkspector@v1
# with:
# github_token: ${{ secrets.github_token }}
# reporter: github-pr-review
# fail_on_error: false
- name: Install Python Dependencies
run: pip install --upgrade pip hatch uv
- name: Check documentation links
run: hatch run docs:linkcheck
- name: Check docs build
run: |
pip install -r requirements/build-docs.txt
cd docs
mkdocs build --strict
run: hatch run docs:build
- name: Check docs examples
run: |
pip install -r requirements/check-types.txt
pip install -r requirements/check-style.txt
mypy --show-error-codes docs/examples/python/
ruff check docs/examples/python/
run: hatch run docs:check-examples
4 changes: 2 additions & 2 deletions .github/workflows/test-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install -r requirements/test-run.txt
run: pip install --upgrade pip hatch uv
- name: Run Tests
run: nox -t test
run: hatch test --python ${{ matrix.python-version }}
7 changes: 0 additions & 7 deletions .linkspector.yml

This file was deleted.

73 changes: 0 additions & 73 deletions noxfile.py

This file was deleted.

155 changes: 142 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,150 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-build-scripts"]

[tool.mypy]
exclude = ['migrations/.*']
ignore_missing_imports = true
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
[project]
name = "reactpy_django"
description = "It's React, but in Python. Now with Django integration."
readme = "README.md"
keywords = [
"React",
"ReactJS",
"ReactPy",
"components",
"asgi",
"django",
"http",
"server",
"reactive",
"interactive",
]
license = "MIT"
authors = [{ name = "Mark Bakhit", email = "archiethemonger@gmail.com" }]
requires-python = ">=3.9"
classifiers = [
"Framework :: Django",
"Framework :: Django :: 4.0",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Multimedia :: Graphics",
"Topic :: Software Development :: Widget Sets",
"Topic :: Software Development :: User Interfaces",
"Environment :: Web Environment",
"Typing :: Typed",
]
dependencies = [
"channels>=4.0.0",
"django>=4.2.0",
"reactpy>=1.0.0, <2.0.0",
"reactpy-router>=1.0.0, <2.0.0",
"dill>=0.3.5",
"orjson >=3.6.0",
"nest_asyncio>=1.5.0",
"typing_extensions",
]
dynamic = ["version"]
urls.Changelog = "https://reactive-python.github.io/reactpy-django/latest/about/changelog/"
urls.Documentation = "https://reactive-python.github.io/reactpy-django/"
urls.Source = "https://github.com/reactive-python/reactpy-django"

[tool.ruff.lint.isort]
known-first-party = ["src", "tests"]
[tool.hatch.version]
path = "src/reactpy_django/__init__.py"

[tool.ruff.lint]
ignore = ["E501"]
[tool.hatch.build.targets.sdist]
include = ["/src"]
artifacts = ["/src/reactpy_django/static/client.js"]

[tool.hatch.build.targets.wheel]
artifacts = ["/src/reactpy_django/static/client.js"]

[tool.hatch.metadata]
license-files = { paths = ["LICENSE.md"] }

[tool.hatch.envs.default]
installer = "uv"

[[tool.hatch.build.hooks.build-scripts.scripts]]
commands = [
"bun install --cwd src/js",
"bun build src/js/src/index.tsx --outfile src/reactpy_django/static/client.js --minify",
'cd scripts && python copy_dir.py "src/js/node_modules/@pyscript/core/dist" "src/reactpy_django/static/pyscript"',
'cd scripts && python copy_dir.py "src/js/node_modules/morphdom/dist" "src/reactpy_django/static/morphdom"',
]
artifacts = []

# >>> Hatch Test Suite <<<

[tool.hatch.envs.hatch-test]
extra-dependencies = [
"playwright",
"twisted",
"channels[daphne]>=4.0.0",
"tblib",
"whitenoise", # TODO: Switch to ServeStatic
]
matrix-name-format = "{variable}-{value}"

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

# >>> Hatch Documentation Scripts <<<

[tool.hatch.envs.docs]
template = "docs"
detached = true
dependencies = [
"mkdocs",
"mkdocs-git-revision-date-localized-plugin",
"mkdocs-material==9.4.0",
"mkdocs-include-markdown-plugin",
"mkdocs-spellcheck[all]",
"mkdocs-git-authors-plugin",
"mkdocs-minify-plugin",
"mike",
"mypy", # TODO: Replace with ruff perhaps?
"django-stubs[compatible-mypy]",
"linkcheckmd",
"reactpy_django @ {root:uri}",
]

[tool.hatch.envs.docs.scripts]
serve = ["cd docs && mkdocs serve"]
build = ["cd docs && mkdocs build --strict"]
linkcheck = [
"linkcheckMarkdown docs/ -v -r",
"linkcheckMarkdown README.md -v -r",
"linkcheckMarkdown CHANGELOG.md -v -r",
]
deploy_latest = ["cd docs && mike deploy --push --update-aliases {args} latest"]
deploy_develop = ["cd docs && mike deploy --push develop"]

# >>> Generic Tools <<<

[tool.ruff]
extend-exclude = ["*/migrations/*", ".venv/*", ".eggs/*", ".nox/*", "build/*"]
line-length = 120
format.preview = true
lint.extend-ignore = [
"ARG001", # Unused function argument
"ARG002", # Unused method argument
"ARG004", # Unused static method argument
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function definition
"PLR2004", # Magic value used in comparison
"SIM115", # Use context handler for opening files
"SLF001", # Private member accessed
"E501", # Line too long
]
lint.preview = true
lint.isort.known-first-party = ["src", "tests"]

[tool.pytest.ini_options]
addopts = """\
--strict-config
--strict-markers
"""
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements/build-docs.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/build-pkg.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/check-style.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/check-types.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements/dev-env.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements/pkg-deps.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/test-env.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/test-run.txt

This file was deleted.

Loading